
function copylink() {

    var copyText = 'chrome://flags/#unsafely-treat-insecure-origin-as-secure';
    navigator.clipboard.writeText(copyText);

    // Alert the copied text
    alert("Copied the text: " + copyText);

}



function domReady(fn) {
    if (
        document.readyState === "complete" ||
        document.readyState === "interactive"
    ) {
        setTimeout(fn, 1000);
    } else {
        document.addEventListener("DOMContentLoaded", fn);
    }
}

function setCookie(cname, cvalue, exdays) {
    const d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    let expires = "expires=" + d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

domReady(function () {

    // If found you qr code
    function onScanSuccess(decodeText, decodeResult) {

        if (decodeText != "") {
            swal(
            'Success',
             decodeText,
            'success'
            );
            setCookie('qrcode', decodeText, 5);
            setTimeout(function () {
                window.close();
            }, 1000);
        }
 
    }

    let htmlscanner = new Html5QrcodeScanner(
        "my-qr-reader",
        { fps: 10, qrbos: 250 }
    );
    htmlscanner.render(onScanSuccess);
});
