3 ms·
The following code snippet in a grease-monkey-script with // @include https://news.ycombinator.com/* https://news.ycombinator.com/* in the header will color t
by stragies 7y ago
The following code snippet in a grease-monkey-script with
// @include https://news.ycombinator.com/* https://news.ycombinator.com/*
in the header will color the top-bar on HN pages with the color given in the URL such like https://news.ycombinator.com#MYC=lime https://news.ycombinator.com#MYC=lime or
https://news.ycombinator.com#MYC=#ce1c01 https://news.ycombinator.com#MYC=#ce1c01 .
(function() {
if (color=document.location.href.match(/#MYC=(.)/)[1]) {
document.querySelector("#hnmain>tbody>tr:first-of-type>td").setAttribute("bgcolor",color);
document.querySelectorAll('a[href^="https://news.ycomb" https://news.ycomb"],a:not([href="/"])')
.forEach(e => {e.href+="#MYC="+color});
}
})();
This script colors the top bar, and adds the custom colour to all HN-internal links, so until you manually change the URL, further navigation in that tab within news.ycombinator.com will retain your chosen top-bar colour.
(I hope the code comes out formatted in a legible way)