mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-19 18:36:25 +00:00
Fix adblock message (#684)
This commit is contained in:
parent
1b433e6858
commit
e7694cf870
1 changed files with 8 additions and 13 deletions
21
index.html
21
index.html
|
@ -189,27 +189,22 @@
|
|||
if (window.location.hostname === "demo.emulatorjs.org") {
|
||||
window.EJS_AdUrl = "https://ads.emulatorjs.org/";
|
||||
window.EJS_ready = function() {
|
||||
detectAdBlock("https://ads.emulatorjs.org/?blocked");
|
||||
detectAdBlock("data:text/html;base64,PGh0bWw+PHN0eWxlPiNhZGJsb2Nre2JhY2tncm91bmQtY29sb3I6cmdiYSgwLDAsMCwuOCk7cG9zaXRpb246Zml4ZWQ7d2lkdGg6MTAwJTtoZWlnaHQ6MTAwJTt0b3A6MDtsZWZ0OjA7ei1pbmRleDoxMDAwO3RleHQtYWxpZ246Y2VudGVyO2NvbG9yOiNmZmZ9Ym9keSxodG1se2JhY2tncm91bmQtY29sb3I6dHJhbnNwYXJlbnR9PC9zdHlsZT48Ym9keSBzdHlsZT0ibWFyZ2luOjAiPjxkaXYgaWQ9ImFkYmxvY2siPjxoMT5IaSBBZGJsb2NrIFVzZXIhPC9oMT48cD5BZHMgb24gdGhpcyBwYWdlIG1heSBjb21lIGFuZCBnbyBkZXBlbmRpbmcgb24gaG93IG1hbnkgcGVvcGxlIGFyZSBmdW5kaW5nIHRoaXMgcHJvamVjdC48YnI+WW91IGNhbiBoZWxwIGZ1bmQgdGhpcyBwcm9qZWN0IG9uPGEgaHJlZj0iaHR0cHM6Ly9wYXRyZW9uLmNvbS9FbXVsYXRvckpTIj5wYXRyZW9uPC9hPjwvcD48L2Rpdj48L2JvZHk+PC9odG1sPg==");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
script.src = "data/loader.js";
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
async function detectAdBlock(url) {
|
||||
let adBlockEnabled = false
|
||||
const googleAdUrl = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'
|
||||
function detectAdBlock(url) {
|
||||
let adBlockEnabled = false;
|
||||
try {
|
||||
await fetch(new Request(googleAdUrl)).catch(_ => adBlockEnabled = true)
|
||||
window.EJS_AdUrl = document.querySelector('iframe[src="'+window.EJS_AdUrl+'"]').src;
|
||||
} catch (e) {
|
||||
adBlockEnabled = true
|
||||
} finally {
|
||||
window.EJS_ready = function() {
|
||||
if (adBlockEnabled) {
|
||||
window.EJS_adBlocked("https://emulatorjs.org/?blocked");
|
||||
}
|
||||
}
|
||||
adBlockEnabled = true;
|
||||
}
|
||||
if (adBlockEnabled) {
|
||||
window.EJS_adBlocked(url);
|
||||
}
|
||||
}
|
||||
box.ondragover = () => box.setAttribute("drag", true);
|
||||
|
|
Loading…
Reference in a new issue