Discussions » Creation Requests

A Script that Highlights specific Numbers in custom Colors

§
Posted: 2021-10-01

Hello everybody!
I´m very new in here. And thats my first Post. So please be nice!^^

I´m now looking for weeks to find a Script or something else, that would help me find specific Numbers in a wall of Numbers.
i.e. I would like to see every Number between 1 and 2000 in green, every Number between 2001 and 4000 in yellow, and everything above 4001 in red.
It would be amazing if this would work on every page i visit. But for my needs i would be happy if it only works on the blocks.io/live -feed. I´m not good in coding... but i believe, it would be easy to write, because the numbers i would like to colorize are ALLWAYS behind the same Prefix and it is allways in the same Box! But not every time in the same location...
But maybe i´m thinking to far, and its more easy to colorize all Numbers on every Website.

After weeks of searching and trying to learn coding by myself, i´m stucked and dont know how to go on... so this is the first time i´m asking public for help. normally i solve my problems self or helping others solve there problems, but asking for help is something new for me^^
So i´m full of hope that someone is willing to help me! :)

§
Posted: 2021-10-02

You could use markjs.io to mark all numbers with the same color.
Or do something like this

for (var i = element.length; i--;) { //Starts the for condition (or use forEach)
if (element[i].innerText.match(regex to match the numbers you want here)) //If the Result match the numbers you want
{ //Starts the else condition
element[i].style.backgroundColor = 'rgba(255, 0, 0, 0.2)'; //Change the element background to Red
} //Finishes the else condition
}

§
Posted: 2021-10-02

Cool! Thanks for your answer! :)

Both Tipps are looking very good! especially your codelines, because they are short but look strong :D I´ll try to learn how to write it in the following days.
I´ll let you know how i´m going!

Thanks again, and have a nice day! :)

Post reply

Sign in to post a reply.