// ==UserScript==
// @name AdBlock for IGG-Games domains
// @namespace https://greasyfork.org/scripts?set=439787
// @homepage https://greasyfork.org/scripts/420072-adblock-for-igg-games-domains/
// @version 1.2.5
// @description Removes annoyances.
// @author V. H.
// @defaulticon https://igg-games.com/wp-content/uploads/2019/10/AdblockDetected.png
// @match http*://pcgamestorrents.com/*
// @match http*://*.pcgamestorrents.com/*
// @match http*://igg-games.com/*
// @match http*://*.igg-games.com/*
// @match http*://igg-games.cc/*
// @match http*://*.igg-games.cc/*
// @match http*://bluemediafiles.com/*
// @match http*://*.bluemediafiles.com/*
// @match http*://bluemediafiles.eu/*
// @match http*://*.bluemediafiles.eu/*
// @match http*://bluemediafile.sbs/*
// @match http*://*.bluemediafile.sbs/*
// @match http*://get-url.com/*
// @match http*://*.get-url.com/*
// @match http*://pcgamestorrents.org/*
// @match http*://*.pcgamestorrents.org/*
// @match http*://*.moonicorn.network/*
// @include /^(?:.{3,5}:\/\/)(.+?\.)?mega?(?=\.)/
// @grant unsafeWindow
// @grant window.close
// @grant window.onurlchange
// @grant GM_log
// @grant GM_addStyle
// @webRequest [{"selector":"*://drda5yf9kgz5p.cloudfront.net/*","action":"cancel"},{"selector":"*://dita6jhhqwoiz.cloudfront.net/*","action":"cancel"},{"selector":"*://d1ev866ubw90c6.cloudfront.net/*","action":"cancel"},{"selector":"*://dmmzkfd82wayn.cloudfront.net/*","action":"cancel"},{"selector":"*://d3vw4uehoh23hx.cloudfront.net/*","action":"cancel"},{"selector":"*://*.moonicorn.network/*","action":"cancel"},{"selector":"*://*.bebi.com/*","action":"cancel"},{"selector":"*://*.xyz/*","action":"cancel"},{"selector":"*://*.space/*","action":"cancel"},{"selector":"*://*.club/*","action":"cancel"},{"selector":"*://*.info/*","action":"cancel"},{"selector":"*://*.biz/*","action":"cancel"},{"selector":"*://*.live/*","action":"cancel"}]
// @require https://greasyfork.org/scripts/419588-uniq/code/UniQ.js
// @run-at document-start
// @compatible Chrome
// @license AFL-3.0
// ==/UserScript==
void async function _script() {
"use strict";
//console.clear = () => GM_log("Clear attempted.");
await (async function styling() {
await unsafeWindow.try_until(() => {
if (unsafeWindow.document.readyState == "interactive" || unsafeWindow.document.readyState == "complete") {
GM_addStyle(`
hidecss, #overlay, .nav-overlay, .download-overlay, #pageholder, #tooltip, #popnotifications, .dark-overlay, .light-overlay, #idModal, #ads-left #ads-right, #anti-adblock, .fm-dialog-overlay, .adskeeper-holder, #sdwfe1, #dkwids98s, *[z-index=2147483647], *[style*="z-index: 2147483647"], .imgAds {
opacity: 0 !important;
visibility: hidden !important;
display: none !important;
width: 0 !important;
height: 0 !important;
pointer-events: none !important;
touch-callout: none !important;
user-select: none !important;
top: -1 !important;
left: -1 !important;
position: absolute !important;
}
`);
GM_log("Style injected.");
return true;
} else return false;
}, 100);
})(); //styling
const a = /(bluemediafile|get-url|mega|dl\.pcgamestorrents)/i,
e = e => {
e.stopImmediatePropagation();
e.stopPropagation();
if (a.test(unsafeWindow.location.hostname)) e.preventDefault();
return false;
},
banlinks = /(?<=[\_\.\-\/\b\W=])(ads?|bebi|drda5yf9kgz5p|dita6jhhqwoiz|club|moonicorn|adskeeper)(?=[\_\.\-\/\b=])/gi,
bantypes = /(([A-Z]|\d){2,}|^[aA][dD])/;
var _clean, widstr = "div.widget-advads-ad-widget, div.games-after-content, .taxonomy-description, .adskeeper-holder, #sdwfe1, #dkwids98s";
unsafeWindow.interInter();
unsafeWindow.interWrite();
unsafeWindow.interWrite.add(() => {
GM_log("document.write Intercepted.");
return true;
});
if (unsafeWindow.location.hostname.includes("mega")) {
widstr += ", #overlay, .nav-overlay, .download-overlay, #pageholder, #tooltip, #popnotifications, .dark-overlay, .light-overlay, .metaRedirectWrapperTopAds, .metaRedirectWrapperBottomAds, .imgAds";
}
//INTERVAL
const int = unsafeWindow.interInter.interOrig(_clean = async function _clean() {
if (!(unsafeWindow.document.readyState == "interactive" || unsafeWindow.document.readyState == "complete")) return false;
const ad = unsafeWindow.document.getElementById("idModal"),
adl = unsafeWindow.document.getElementById("ads-left"),
adr = unsafeWindow.document.getElementById("ads-right"),
adc = unsafeWindow.document.getElementById("ads-center"),
anti = unsafeWindow.document.getElementById("anti-adblock"),
kqc = unsafeWindow.document.getElementById("kqc"),
nut = unsafeWindow.document.getElementById("nut"),
cntdown = unsafeWindow.document.querySelector("#cntdwn > a"),
imgp = unsafeWindow.document.querySelector("form[action='get-url.php'] > input[name='url']");
unsafeWindow._cookies = unsafeWindow.parseCookies();
unsafeWindow.google_ad_status = 0;
unsafeWindow._cookies.erase().set();
//unsafeWindow.parseCookies().erase("sle").set();
unsafeWindow.document.querySelectorAll("iframe").forEach(e => {
if (e.style.zIndex == 2147483647 || (!e.src && a.test(unsafeWindow.location.hostname)) || (e.src && !/(disqus|graphcomment|igg-games|fastcomments)/.test(e.src))) {
e.remove();
e.style = "display: none;";
e.classList.add("hidecss");
GM_log(`Removed frame:\n\t${e.src}`);
}
});
unsafeWindow.document.querySelectorAll(widstr).forEach(wid => {
wid.remove();
GM_log("Removed:", wid);
});
unsafeWindow.document.querySelectorAll("div.bb-icon-hover").forEach(bebi => {
bebi.parentNode.parentNode.remove();
GM_log("Removed:", bebi);
});
if (ad) {
ad.remove();
GM_log("Removed:", ad);
}
if (adl) {
adl.remove();
GM_log("Removed:", adl);
}
if (adr) {
adr.remove();
GM_log("Removed:", adr);
}
if (adc) {
adc.remove();
GM_log("Removed:", adc);
}
if (anti) {
anti.remove();
GM_log("Removed:", anti);
}
if (kqc && kqc.value && (location.hostname.includes("get-url") || location.hostname.includes("pcgamestorrents"))) {
GM_log("Download clicked. (get-url/pcgamestorrents)");
kqc.click();
kqc.parentNode && kqc.parentNode.submit();
await unsafeWindow.sleep(1000);
} else if (cntdown && location.hostname.includes("bluemediafile")) {
GM_log("Download clicked. (bluemedia)");
cntdown.click();
cntdown.parentNode && cntdown.parentNode.submit();
await unsafeWindow.sleep(1000);
} else if (imgp && imgp.value) {
GM_log("Download clicked. (form)");
nut && nut.click();
imgp.parentNode && imgp.parentNode.submit();
await unsafeWindow.sleep(1000);
} else if (unsafeWindow.location.hostname.includes("mega")) {
unsafeWindow.document.getElementsByClassName("download-file").forEach(e => {
if (!e.getAttribute("data-clicked")) e.click();
e.setAttribute("data-clicked", true);
});
await unsafeWindow.sleep(1000);
}
unsafeWindow.urlCleanup && unsafeWindow.urlCleanup();
}, 500);
function urlCleanup() {
for (const elm of unsafeWindow.document.all) {
if ((elm.href && banlinks.test(elm.href)) || (elm.src && banlinks.test(elm.src)) || (elm.id && banlinks.test(elm.id))) {
GM_log("Broke:", elm);
if (elm.href) elm.href = elm.href.replace(banlinks, "a0a");
if (elm.src) elm.src = elm.src.replace(banlinks, "a0a");
if (elm.id) elm.id = elm.id.replace(banlinks, "a0a");
elm.classList.add("hidecss");
elm.remove();
}
}
} //urlCleanup
unsafeWindow.urlCleanup = urlCleanup;
GM_log("intr", int);
//EVENT/WINDOW
unsafeWindow.interEvent();
unsafeWindow.interEvent.add(function addEventListener(type, fn, capture) { //Monitoring mouse events.
const f = this ? unsafeWindow.interEvent.interOrig.bind(this) : unsafeWindow.interEvent.interOrig;
if (banlinks.test(fn.toString())) {
const args = (fn.toString().match(/(?<=^.*?(function)?\W*?\()(.*?)(?=\))/i) || [ "a0a" ])[0].split(',');
GM_log("BanLink Fn", fn);
fn = (new Function(...args, fn.toString().replace(/(^.*?(function ?.*?)?\(.*?\)(\s|=>)*?\{)|(\}\W*?$)/gms, '').replace(banlinks, "a0a1")));
if (this) fn = fn.bind(this);
}
if ((this == unsafeWindow.document || this == unsafeWindow) && (type == "mousedown" || type == "contextmenu" || type == "mouseup" || type == "mousemove" || type == "dblclick" || type == "click")) {
GM_log(`Blocked: ${type} ${capture}`, fn, this);
return fn;
} else if ((this.tagName == "A" || this.tagName == "DIV" || this.tagName == "BUTTON") && (type == "mousedown" || type == "mouseup")) {
GM_log(`Remapped: ${type}->click ${false}`, fn);
return f("click", fn, false);
} else if (!(type == "mousedown" || type == "contextmenu" || type == "mouseup" || type == "mousemove" || type == "dblclick")) {
if (bantypes.test(type)) GM_log(`Blocked: ${type} ${capture}`, fn);
else {
GM_log(`Allowed: ${type} ${capture}`, fn);
return f(type, fn, capture);
}
} else GM_log(`Blocked: ${type} ${capture}`, fn, this);
return f(type, (...a) => GM_log(`Intercepted: ${type} ${capture}`, a, this), capture);
});
unsafeWindow.interWinopen();
unsafeWindow.interWinopen.add(function open(url, windowName, windowFeatures) { //Monitoring windows.
GM_log(`Windown Open: ${url} ${windowName}`, windowFeatures);
if (banlinks.test(url) || a.test(location.hostname) || (location.hostname.includes("igg") && !a.test(location.hostname))) return this;
return this ? unsafeWindow.interWinopen.interOrig.call(this, url, windowName, windowFeatures) : unsafeWindow.interWinopen.interOrig(url, windowName, windowFeatures);
});
//DL
if (a.test(unsafeWindow.location.hostname)) {
let o, ign;
unsafeWindow.oncontextmenu = unsafeWindow.onclick = unsafeWindow.onmousedown = unsafeWindow.ondbclick = null;
unsafeWindow.interXHR();
unsafeWindow.interFetch();
/*unsafeWindow.document.addEventListener("contextmenu", ign = e => {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
return false;
}, true);
unsafeWindow.document.addEventListener("click", ign, true);*/
unsafeWindow.interXHR.add(o = function open(method, url, ...rest) {
if (banlinks.test(url) || (this && this.__sentry_xhr__)) {
GM_log(`Blocked: ${method} ${url}`);
return this ? unsafeWindow.interXHR.interOrig.call(this, method, "data:text/html,Blocked", ...rest) : unsafeWindow.interXHR.interOrig(method, "data:text/html,Blocked", ...rest);
}
});
unsafeWindow.interFetch.add(function fetch(url, ...rest) {
if (banlinks.test(url) || (this && this.__sentry_xhr__)) {
GM_log(`Blocked: ${url} ${rest[0]}`);
return this ? unsafeWindow.interFetch.interOrig.call(this, "data:text/html,Blocked", ...rest) : unsafeWindow.interXHR.interOrig("data:text/html,Blocked", ...rest);
}
});
}
}(); //_script