Skip to content

Instantly share code, notes, and snippets.

@JiriMachacek
Last active May 6, 2021 11:45
Show Gist options
  • Save JiriMachacek/dd1ed755526d5075c5d5399fb5a3309e to your computer and use it in GitHub Desktop.
Save JiriMachacek/dd1ed755526d5075c5d5399fb5a3309e to your computer and use it in GitHub Desktop.
1.4
var sites = [
'idnes.cz',
'blesk.cz',
'novinky.cz',
'ct24.cz',
'ihned.cz',
'ceskenoviny.cz',
'tyden.cz',
'centrum.cz',
'seznam.cz',
'lidovky.cz',
'super.cz',
'prozeny.cz',
'parlamentnilisty.cz',
'denikn.cz',
'aktualne.cz',
'irozhlas.cz',
'atlas.centrum.cz',
'ahaonline.cz',
'respekt.ihned.cz',
'reflex.cz',
'tyden.cz',
'pravo.cz',
'halonoviny.cz', // :)
'protiproud.cz',
'zdroj.cz',
'echo24.cz',
'forum24.cz',
'spoz.cz',
'hrad.cz'
];
var wordsVzorPan = ['Zloser','Kokot', 'Vepřočlověk','Vepřolídr','Ovar','Bumbál','Tuzeman','Čínolízal','Vlezputin'];
var wordsOther = ['Kunda','Profesor Bumbál','Pussáček ovcí','Prasident Zeman','Kapitán popelníček'];
var wordsAll = wordsVzorPan.concat(wordsOther);
var selectedPrvniPad = wordsAll[Math.floor((Math.random()*wordsAll.length))];
var selectedJinePady = wordsVzorPan.includes(selectedPrvniPad) ? selectedPrvniPad : wordsVzorPan[Math.floor((Math.random()*wordsVzorPan.length))];
if(sites.some(site => window.location.hostname.includes(site))) {
var arr = getTextNodesIn(document.getElementsByTagName('body')[0], false);
for (var i = 0; i < arr.length; i++) {
arr[i].textContent = arr[i].textContent.replace(/Zeman\b/g, selectedPrvniPad);
arr[i].textContent = arr[i].textContent.replace(/Zeman/g, selectedJinePady);
}
}
function getTextNodesIn(node, includeWhitespaceNodes) {
var textNodes = [], whitespace = /^\s*$/;
function getTextNodes(node) {
if (node.nodeType == 3) {
if (includeWhitespaceNodes || !whitespace.test(node.nodeValue)) {
textNodes.push(node);
}
} else {
for (var i = 0, len = node.childNodes.length; i < len; ++i) {
getTextNodes(node.childNodes[i]);
}
}
}
getTextNodes(node);
return textNodes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment