Skip to content

Instantly share code, notes, and snippets.

@rksm
Created November 24, 2017 23:09
Show Gist options
  • Save rksm/a46229cef1620f3a82e3906a325b8820 to your computer and use it in GitHub Desktop.
Save rksm/a46229cef1620f3a82e3906a325b8820 to your computer and use it in GitHub Desktop.
spiegel.de fixes
// ==UserScript==
// @name spiegel no ad-blocker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description removes no-ad-blocker popups and makes spiegel plus readable
// @author You
// @match http://www.spiegel.de/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
setInterval(removeAdBlockPopup, 100);
fixSpiegelPlus();
function removeAdBlockPopup() {
var blocker = document.querySelector("body > div.ua-detected.ua-webkit"),
wrapperContent = document.querySelector("#wrapper-content");
if (!blocker) return;
blocker.remove();
wrapperContent.style = "";
}
function fixSpiegelPlus() {
var obfIntro = document.querySelector(".js-spiegelplus-obfuscated-intro");
if (!obfIntro) return;
obfIntro.remove();
let obf = document.querySelectorAll(".obfuscated"),
obfParent = document.querySelector(".obfuscated-content");
Array.from(obf).forEach(el => {
el.className = el.className.replace(/obfuscated/g, "");
el.textContent = Array.from(el.textContent).map(ea =>
ea === " " ? ea : String.fromCharCode(ea.charCodeAt(0)-1)).join("");
});
let obfWrapper = obfParent;
while (true) {
if (!obfWrapper || !obfWrapper.parentNode || obfWrapper.parentNode.className.includes("article-section")) break;
obfWrapper = obfWrapper.parentNode;
}
obfWrapper.parentNode.replaceChild(obfParent, obfWrapper);
obfParent.className = "";
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment