Last active
February 7, 2021 17:57
-
-
Save J00MZ/efe94184ce36f27c7f84a124d2cfbc1e to your computer and use it in GitHub Desktop.
NF WhatsApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
const iframe = document.createElement("iframe"); | |
function sendMessageToWaServer(qr) { | |
iframe.contentWindow.postMessage({ qr }, "*"); | |
} | |
function getQrFromCanvas() { | |
let canvas = document.querySelectorAll('[role="img"]')[0]; | |
let qrUrl = canvas.toDataURL(); | |
sendMessageToWaServer(qrUrl); | |
} | |
function observeQrChange() { | |
let qrElement = document.querySelectorAll('[data-ref]')[0].parentElement; | |
let mutationObserver = new MutationObserver(mutations => { | |
for (let mutation of mutations) { | |
if (mutation.attributeName === 'data-ref') { | |
getQrFromCanvas(); | |
return; | |
} | |
} | |
}); | |
mutationObserver.observe(qrElement, { | |
attributes: true, | |
characterData: false, | |
childList: true, | |
subtree: true, | |
attributeOldValue: true, | |
//characterDataOldValue: true | |
}); | |
getQrFromCanvas(); | |
} | |
function setIframe() { | |
iframe.src = "https://netfree.link/misc/whatsapp-web"; | |
iframe.style.width = "100%" | |
var elm = document.querySelectorAll('.landing-title')[0].parentElement; | |
elm.querySelectorAll("li").forEach(i => i.parentElement.removeChild(i)); | |
elm.appendChild(iframe); | |
iframe.addEventListener('load',x => observeQrChange()); | |
} | |
function waitLoad() { | |
let mutationObserver = new MutationObserver(function (mutations) { | |
if (document.querySelectorAll('[data-ref]').length > 0) { | |
mutationObserver.disconnect(); | |
setIframe(); | |
} | |
}); | |
mutationObserver.observe(document, { | |
attributes: true, | |
characterData: false, | |
childList: true, | |
subtree: true, | |
attributeOldValue: true, | |
characterDataOldValue: true | |
}); | |
} | |
waitLoad(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment