Created
January 8, 2020 14:40
-
-
Save michaelotto/cb18ad83f46f7a76da3cbf510f5cece7 to your computer and use it in GitHub Desktop.
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 Remove Z+ stories from zeit.de | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Remove bento.de stories from spiegel.de | |
// @author Michael Otto | |
// @match https://www.zeit.de/* | |
// @match http://www.zeit.de/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var search_string = [ | |
"//article" | |
]; | |
function parse_and_remove(xpath) { | |
for (var i = 0; i < xpath.snapshotLength; i++) { | |
var el = xpath.snapshotItem(i); | |
var uses = el.getElementsByTagName('use'); | |
for (var j=0; j < uses.length; j++) { | |
if (uses[j].href.baseVal == "#svg-zplus") { | |
console.log("Removing element "+el); | |
el.parentNode.removeChild(el); | |
break; | |
} | |
} | |
} | |
} | |
for (var j = 0; j < search_string.length; j++) { | |
parse_and_remove(document.evaluate(search_string[j], document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null)); | |
} | |
;})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment