Created
April 8, 2018 16:15
-
-
Save ermand/ab1c56ddd8a46b32695679bb0adf04b1 to your computer and use it in GitHub Desktop.
Highlight links
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
javascript: (function () { | |
var i, x; | |
for (i = 0; (x = document.links[i]); ++i) { | |
let color = ['blue', 'red', 'orange'][ | |
sim(x, location) | |
]; | |
x.style.setProperty('color', color, 'important'); | |
x.style.setProperty('text-decoration', 'underline', 'important'); | |
x.style.setProperty('font-weight', '700', 'important'); | |
x.style.setProperty('border', '3px solid green', 'important'); | |
} | |
function sim(a, b) { | |
if (a.hostname != b.hostname) return 0; | |
if (fixPath(a.pathname) != fixPath(b.pathname) || a.search != b.search) | |
return 1; | |
return 2; | |
} | |
function fixPath(p) { | |
p = (p.charAt(0) == '/' ? '' : '/') + p; | |
/*many browsers*/ p = p.split('?')[0]; | |
/*opera*/ return p; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment