Created
November 24, 2017 23:09
-
-
Save rksm/a46229cef1620f3a82e3906a325b8820 to your computer and use it in GitHub Desktop.
spiegel.de fixes
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
// ==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