Skip to content

Instantly share code, notes, and snippets.

@harsilspatel
Last active February 25, 2022 13:07
Show Gist options
  • Save harsilspatel/1b5226a33e0d5c613fb6e6588e419eae to your computer and use it in GitHub Desktop.
Save harsilspatel/1b5226a33e0d5c613fb6e6588e419eae to your computer and use it in GitHub Desktop.
accent parts of my frequent websites
// ==UserScript==
// @name highlighter
// @namespace harsilspatel
// @version 0.2
// @description accent parts of website
// @author harsilspatel
// @require https://cdn.jsdelivr.net/npm/rainbowvis.js@1.0.1/rainbowvis.min.js
// @match https://news.ycombinator.com/*
// @downloadURL https://gist.github.com/harsilspatel/1b5226a33e0d5c613fb6e6588e419eae/raw/highligher.user.js
// @updateURL https://gist.github.com/harsilspatel/1b5226a33e0d5c613fb6e6588e419eae/raw/highligher.user.js
// @icon https://www.google.com/s2/favicons?domain=google.com
// @grant none
// ==/UserScript==
(function () {
"use strict";
const hnScores = Array.from(document.querySelectorAll("span[class='score']")).map(element => ({element, score: parseInt(element.innerText, 10)}))
const hnScoresHm = new Rainbow();
hnScoresHm.setSpectrum('#e6f2e9', '#00e639');
const maxScore = Math.max.apply(Math, hnScores.map(x => x.score));
hnScoresHm.setNumberRange(0, maxScore)
console.log('maxScore', maxScore)
hnScores.forEach(x => {x.element.style.backgroundColor = hnScoresHm.colorAt(x.score)})
console.log("hnScores", hnScores.slice(10))
console.log("highligher script loaded");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment