[Home] [Catalog] [Search] [Inbox] [Write PM] [Admin]
[Return] [Bottom]

Posting mode: Reply

(for deletion)
  • Allowed file types are: gif, jpg, jpeg, png, bmp, swf, webm, mp4
  • Maximum file size allowed is 50000 KB.
  • Images greater than 200 * 200 pixels will be thumbnailed.





File: new_script.png
(203 KB, 1442x964)[ImgOps]
208673
I modified Anonymous san's yeah highlighter script to make it more gradual

It's my first time programming in javascript, so please tell me if there's anything st00pid ヽ(´ー`)ノ


// ==UserScript==


// @name Heyuri Yeah Highlighter (better)


// @namespace heyuri-yeah-highlight-better


// @version 1.0


// @description Highlights reply posts based on Yeah count (like a Futaba★Channel userscript)


// @author Heyuri Applicable Research & Development


// @match https://img.heyuri.net/*


// @grant none


// ==/UserScript==



(function () {
"use strict";

const red_initial = 235;
const green_initial = 224;
const blue_initial = 210;

const red_reach = 0;
const green_reach = 239;
const blue_reach = 55;
const reach = 15; //how many "Yeah" needed to make the post go from color initial to color reach


function applyHighlighting() {
document.querySelectorAll(".post.reply").forEach(post => {
post.removeAttribute("style");

const sod = post.querySelector(".sod");
if (!sod) return;

const match = sod.textContent.match(/\d+/);
if (!match) return;

const count = parseInt(match[0], 10);

const red = Math.round(red_initial - (((red_initial - red_reach) / reach) * count));
const green = Math.round(green_initial - (((green_initial - green_reach) / reach) * count));
const blue = Math.round(blue_initial - (((blue_initial - blue_reach) / reach) * count));
const color = "rgb(" + red + ", " + green + ", " + blue + ")";

post.style.backgroundColor = color;
});
}

const observer = new MutationObserver(() => {
applyHighlighting();
});

observer.observe(document.body, {
childList: true,
subtree: true,
characterData: true
});

applyHighlighting();

})();


[Top]
Delete post: []
First
[0]
Last