Last active
February 22, 2022 06:47
-
-
Save trent2/4f1198a173019103478cbefbcaf4c744 to your computer and use it in GitHub Desktop.
Unobfuscate SPIEGEL plus articles with greasemonkey
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 unobfuscate spiegel plus | |
// @namespace obfuscate | |
// @include http://www.spiegel.de/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
if(document.getElementsByClassName('obfuscated-content')[0] != undefined) { | |
document.getElementsByClassName('obfuscated-content')[0].setAttribute("class", ""); | |
var elems = document.getElementsByClassName('obfuscated'), t, or, c, i, cc; | |
for(i in elems) { | |
or = elems[i].innerHTML; | |
t = ""; | |
inElement = false; | |
openTag = -1; | |
isATag = false; | |
closingTag = false; | |
dontTranslate = false; | |
if(or != undefined) | |
for(c=0; c<or.length; ++c) { | |
if(openTag>-1) | |
openTag++; | |
cc = or.charCodeAt(c); | |
if(cc == 60) { // "<" | |
dontTranslate = true; | |
inElement = true; | |
openTag = 0; | |
} | |
if(cc>33 && !dontTranslate) { | |
switch(cc) { | |
case 180: t += ";"; break; | |
case 178: t += "!"; break; | |
case 177: t += "&"; break; | |
default: | |
t += String.fromCharCode(cc-1); | |
} | |
} | |
else | |
t += or.charAt(c); | |
if(openTag==1 && cc == 97) // <a ... | |
isATag = true; | |
if(openTag==1 && cc == 47) // "</" | |
closingTag = true; | |
if(inElement && cc == 62) { // "<...>" | |
dontTranslate = isATag && !closingTag; | |
isATag = false; | |
inElement = closingTag = false; | |
openTag = -1; | |
} | |
} | |
elems[i].innerHTML = t; | |
} | |
} |
Funktioniert auch heute noch einwandfrei. Vielen Dank.
Ab heute nicht mehr :-)
Is there any option left?
What kind of option?
About four years ago, Spiegel online changed the way Spiegel plus pages are displayed. Before, they send all content of the articel to the user, pretty lamely encrypted (rather obfuscated) for those not logged in, very easily to decypher.
From then on 95% of the article's text is not send to the web client at all if you're not logged in as a paying user, not even obfuscated or encrypted. This (old) script is purely running on your client, i.e. probably your web browser. You cannot decrypt anything from nothing.
Makes sense, those fuckers...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't exactly understand what you mean by "vanilla javascript". You're right that greasemonkey apparently kicks in before any other SO-JS is executed and removes the blurring of the subsequent element.
When you don't have GM running, SO loads and executes a script from laterpay.net. This wraps the "obfuscated-content"-div-element in another div-element with a random class-name with the associated blurring CSS-code effectively preventing any JS-code run afterwards from accessing the element with the associated blurring CSS. So if you execute your bookmarklet after the laterpay-script has been executed you won't be able to undo the blurring with the line you quoted.
Possible fixes:
var p = document.getElementsByClassName('obfuscated-content')[0].parentElement;
p.setAttribute("class", "");
p.nextElementSibling.style.display = "none";
to access the parent element created by the laterpay.net-script (and the following element). I have run this through the closure compile service at google and get something like this which works for me as a bookmarklet (with "javascript"-prefix):
var a=document.getElementsByClassName("obfuscated-content")[0].parentElement;a.setAttribute("class","");a.nextElementSibling.style.display="none";var b=document.getElementsByClassName("obfuscated"),c,d,e,f,g; for(f in b){d=b[f].innerHTML;c="";inElement=!1;openTag=-1;dontTranslate=closingTag=isATag=!1;for(e=0;e<d.length;++e){-1<openTag&&openTag++;g=d.charCodeAt(e);60==g&&(inElement=dontTranslate=!0,openTag=0);if(33<g&&!dontTranslate)switch(g){case 180:c+=";";break;case 178:c+="!";break;case 177:c+="&";break;default:c+=String.fromCharCode(g-1)}else c+=d.charAt(e);1==openTag&&97==g&&(isATag=!0);1==openTag&&47==g&&(closingTag=!0);inElement&&62==g&&(dontTranslate=isATag&&!closingTag,inElement=closingTag=isATag= !1,openTag=-1)}b[f].innerHTML=c};
Have fun!