Created
December 9, 2014 13:52
-
-
Save kelunik/255a092c6fe5264c9def to your computer and use it in GitHub Desktop.
Remove w3schools.com from Google Search results
This file contains hidden or 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 w3schools.com from Google | |
// @namespace https://www.kelunik.com | |
// @include https://www.google.com/* | |
// @include https://www.google.de/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
function forEach(list, callback) { | |
Array.prototype.forEach.call(list, callback); | |
} | |
var cleanupResults = function() { | |
forEach(document.getElementsByTagName('cite'), function(o) { | |
if(o.textContent.indexOf("w3schools.com") > 0) { | |
var node = o.parentNode.parentNode.parentNode.parentNode.parentNode; | |
node.parentNode.removeChild(node); | |
} | |
}); | |
}; cleanupResults(); | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
cleanupResults(); | |
}); | |
}); | |
observer.observe(document.body, { childList: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This wasn't working for me as is so I added a gross timeout: