Skip to content

Instantly share code, notes, and snippets.

@michaelotto
Created January 8, 2020 14:40
Show Gist options
  • Save michaelotto/cb18ad83f46f7a76da3cbf510f5cece7 to your computer and use it in GitHub Desktop.
Save michaelotto/cb18ad83f46f7a76da3cbf510f5cece7 to your computer and use it in GitHub Desktop.
// ==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