4 ms·
I wrote a quick userscript for you: colorLinks("blue"); function colorLinks(hex) { var links = document.getElementsByTagName("a");
by notRobot 5y ago
I wrote a quick userscript for you:
colorLinks("blue");
function colorLinks(hex)
{
var links = document.getElementsByTagName("a");
for(var i=0;i<links.length;i++)
{
if(links[i].href)
{
links[i].style.color = hex;
links[i].style.textDecoration = "underline";
links[i].style.textDecorationStyle = "solid";
links[i].style.textDecorationColor = hex;
}
}
}
Will make all links blue and underlined.
You can use this tool to convert it into a handy bookmarklet: https://caiorss.github.io/bookmarklet-maker/ https://caiorss.github.io/bookmarklet-maker/
Alternatively, you can paste it into the JS console, or install it with an extension like greasemonkey.
Hope this helps!
- chrismorgan 5y agoThis is more easily, faster and better done as a user stylesheet: a { color: blue !important; text-decoration: underline !important; text-decoration-style: solid !important; text-decoration-color: blue !important; } (Unfortunately, extensions like Stylus <https://github.com/openstyles/stylus https://github.com/openstyles/stylus> don’t handle user stylesheet priorities correctly: !important in a user stylesheet should override absolutely all site stylesheets, including inline style attributes. But because of lousy technical limitations, they load stylesheets at the site priority rather than the user priority. But then, what you presented doesn’t conquer a site !important spec anyway. See https://wattenberger.com/blog/css-cascade#origin https://wattenberger.com/blog/css-cascade#origin for a really good explanation of all this stuff.)
- dylan604 5y agoThis is an example of "naming this is hard". You call a function passing a string of "blue", but the fuction's variable is named hex implying it will hold something formated "0000FF". yes, it's still a string, but.... I don't mean to be overly critical of pseudo code examples. I just wanted to point out how naming things is hard even in quicky code. We now return to your regularly scheduled discussion already in progress.
- squeaky-clean 5y agoThe html color attribute can be given either a hexadecimal string or a named html color keyword. I'm on my phone so I can't run their code, but it looks like it should work with both "blue" or "0000FF" (it might need to be "#0000FF"?). So that actually makes naming it even more difficult, in my opinion :P
- notRobot 5y agoIt will take either an HTML colour name, or a hex value. I agree that it could be named better.