Last active
August 26, 2021 17:14
-
-
Save vyznev/29e814707baf8e1fa6e6 to your computer and use it in GitHub Desktop.
Reveal nofollow links on Stack Exchange
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 Reveal nofollow links on Stack Exchange | |
// @version 1.3 | |
// @namespace http://vyznev.net/ | |
// @description Colors all links with rel=nofollow red on the Stack Exchange network. (Works on other sites too, if you edit the includes.) | |
// @author Ilmari Karonen | |
// @license ISC (http://opensource.org/licenses/ISC) | |
// @match *://*.stackexchange.com/* | |
// @match *://*.stackoverflow.com/* | |
// @match *://*.superuser.com/* | |
// @match *://*.serverfault.com/* | |
// @match *://*.stackapps.com/* | |
// @match *://*.mathoverflow.net/* | |
// @match *://*.askubuntu.com/* | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
// Yes, that's all there really is to it: | |
var css = 'a[rel*=nofollow] { color: red !important; }'; | |
// Inject style into page: | |
var style = document.createElement('style'); | |
style.textContent = css; | |
var parent = (document.head || document.documentElement); | |
if (parent) parent.appendChild(style); | |
else { | |
// work-around for https://github.com/greasemonkey/greasemonkey/issues/2996 | |
var obs = new MutationObserver(function () { | |
var parent = (document.head || document.documentElement); | |
if (parent) { obs.disconnect(); parent.appendChild(style); } | |
}); | |
obs.observe(document, {childList: true}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment