150 lines
5.5 KiB
JavaScript
150 lines
5.5 KiB
JavaScript
// ==UserScript==
|
|
// @name MuchoHentai: Popup-Blocker
|
|
// @namespace https://git.ponywave.de/Akamaru/Userscripts
|
|
// @version 1.0
|
|
// @description Blockiert nervige Popup-Werbung die sich bei jedem Klick öffnet
|
|
// @author Akamaru
|
|
// @match *://muchohentai.com/*
|
|
// @match *://*.muchohentai.com/*
|
|
// @grant none
|
|
// @run-at document-start
|
|
// @updateURL https://git.ponywave.de/Akamaru/Userscripts/raw/branch/master/muchohentai-popup-blocker.user.js
|
|
// @downloadURL https://git.ponywave.de/Akamaru/Userscripts/raw/branch/master/muchohentai-popup-blocker.user.js
|
|
// ==/UserScript==
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
// Liste der bekannten Ad-Domains die blockiert werden sollen
|
|
const adDomains = [
|
|
'browsecoherentunrefined.com',
|
|
'guidepaparazzisurface.com',
|
|
'earmuffpostnasalrisotto.com',
|
|
'szubtepzaka.com'
|
|
];
|
|
|
|
// ===== STRATEGIE 1: Globale Ad-Funktionen überschreiben =====
|
|
// Diese Funktionen werden von den Ad-Scripts aufgerufen
|
|
window.kjjzn = function() { console.log('[Popup-Blocker] kjjzn blocked'); };
|
|
window.inwwhfk = function() { console.log('[Popup-Blocker] inwwhfk blocked'); };
|
|
window.vaujj = function() { console.log('[Popup-Blocker] vaujj blocked'); };
|
|
|
|
// ===== STRATEGIE 2: window.open() überschreiben =====
|
|
const originalOpen = window.open;
|
|
window.open = function(url, name, features) {
|
|
// Prüfe ob die URL zu einer Ad-Domain gehört
|
|
if (url) {
|
|
const urlStr = url.toString().toLowerCase();
|
|
for (const domain of adDomains) {
|
|
if (urlStr.includes(domain)) {
|
|
console.log('[Popup-Blocker] Blocked popup to:', url);
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Erlaube nur window.open() Aufrufe mit explizitem User-Intent
|
|
// (z.B. wenn es keine Features angegeben sind, ist es vermutlich ein Popup)
|
|
if (!features && name !== '_blank') {
|
|
console.log('[Popup-Blocker] Blocked suspicious window.open()');
|
|
return null;
|
|
}
|
|
|
|
// Erlaube legitime window.open() Aufrufe
|
|
return originalOpen.call(window, url, name, features);
|
|
};
|
|
|
|
// ===== STRATEGIE 3: Click-Event-Schutz =====
|
|
// Fange alle Click-Events in der Capture-Phase ab und prüfe auf verdächtiges Verhalten
|
|
let lastClickTime = 0;
|
|
let clickCount = 0;
|
|
|
|
document.addEventListener('click', function(event) {
|
|
const now = Date.now();
|
|
|
|
// Reset Counter nach 1 Sekunde
|
|
if (now - lastClickTime > 1000) {
|
|
clickCount = 0;
|
|
}
|
|
|
|
lastClickTime = now;
|
|
clickCount++;
|
|
|
|
// Wenn mehrere window.open() Aufrufe in kurzer Zeit erfolgen, blockiere sie
|
|
const originalOpen = window.open;
|
|
let openCallCount = 0;
|
|
|
|
window.open = function(...args) {
|
|
openCallCount++;
|
|
|
|
if (openCallCount > 1) {
|
|
console.log('[Popup-Blocker] Multiple window.open() calls detected and blocked');
|
|
window.open = originalOpen;
|
|
return null;
|
|
}
|
|
|
|
// Wiederherstellung nach kurzem Timeout
|
|
setTimeout(() => {
|
|
window.open = originalOpen;
|
|
openCallCount = 0;
|
|
}, 100);
|
|
|
|
return originalOpen.apply(this, args);
|
|
};
|
|
}, true); // true = Capture-Phase (vor normalen Event-Handlern)
|
|
|
|
// ===== STRATEGIE 4: Ad-Scripts blockieren =====
|
|
// MutationObserver um dynamisch eingefügte Scripts zu entfernen
|
|
const observer = new MutationObserver(function(mutations) {
|
|
mutations.forEach(function(mutation) {
|
|
mutation.addedNodes.forEach(function(node) {
|
|
if (node.nodeName === 'SCRIPT' && node.src) {
|
|
const src = node.src.toLowerCase();
|
|
|
|
// Prüfe ob das Script von einer Ad-Domain kommt
|
|
for (const domain of adDomains) {
|
|
if (src.includes(domain)) {
|
|
console.log('[Popup-Blocker] Blocked script from:', node.src);
|
|
node.remove();
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Prüfe auf verdächtige Data-Attribute (von Ad-Networks verwendet)
|
|
if (node.hasAttribute('data-clocid') || node.hasAttribute('data-clbaid')) {
|
|
console.log('[Popup-Blocker] Blocked ad script with data attributes');
|
|
node.remove();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
// Starte Observer sobald das DOM verfügbar ist
|
|
if (document.documentElement) {
|
|
observer.observe(document.documentElement, {
|
|
childList: true,
|
|
subtree: true
|
|
});
|
|
} else {
|
|
window.addEventListener('DOMContentLoaded', function() {
|
|
observer.observe(document.documentElement, {
|
|
childList: true,
|
|
subtree: true
|
|
});
|
|
});
|
|
}
|
|
|
|
// ===== STRATEGIE 5: Popunder-Schutz =====
|
|
// Verhindere dass das aktuelle Fenster im Hintergrund verschoben wird (Popunder-Technik)
|
|
window.addEventListener('blur', function() {
|
|
// Wenn ein neues Fenster geöffnet wurde und das aktuelle in den Hintergrund geht,
|
|
// hole den Fokus zurück
|
|
setTimeout(function() {
|
|
window.focus();
|
|
}, 100);
|
|
});
|
|
|
|
console.log('[Popup-Blocker] MuchoHentai Popup-Blocker aktiviert');
|
|
})();
|