Last active
February 25, 2022 13:07
-
-
Save harsilspatel/1b5226a33e0d5c613fb6e6588e419eae to your computer and use it in GitHub Desktop.
accent parts of my frequent websites
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
// ==UserScript== | |
// @name highlighter | |
// @namespace harsilspatel | |
// @version 0.2 | |
// @description accent parts of website | |
// @author harsilspatel | |
// @require https://cdn.jsdelivr.net/npm/[email protected]/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