Last active
March 29, 2016 22:03
-
-
Save toddself/dd731a6f68f756e6c0d0775089d4d602 to your computer and use it in GitHub Desktop.
Prevent any of the genius annotations from running on your site
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
var genius = /genius/i | |
// prevent genius.it/[your site] | |
if (genius.test(document.referrer) || genius.test(window.location.href)) { | |
document.location = 'https://stopitgenius.xyz' | |
} | |
// prevent the bookmarklet | |
var setAttribute = window.HTMLElement.prototype.setAttribute | |
window.HTMLElement.prototype.setAttribute = function (attr, val) { | |
if ((attr === 'src' || attr === 'href') && genius.test(val)) { | |
console.log('genius denied') | |
return | |
} else { | |
setAttribute.call(this, attr, val) | |
} | |
} | |
// prevent the extension | |
var observer = new window.MutationObserver(function (mutations) { | |
for (var i = 0, len = mutations.length; i < len; i++) { | |
var mutation = mutations[i] | |
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) { | |
for (var j = 0, jlen = mutation.addedNodes.length; j < jlen; j++) { | |
var node = mutation.addedNodes[j] | |
if (genius.test(node.nodeName)) { | |
node.remove() | |
} | |
} | |
} | |
} | |
}) | |
observer.observe(document.body, {childList: true}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment