Hide elements with child text containing numbers less than threshold

92 Views Asked by At

I am trying to get this to work to hide items on amazon under 100 reviews. I don't know what I am doing wrong. I use TamperMonkey/GreaseMonkey addon/extension. I should add these are items from searches then choosen categories, if you try to replicate it, if that makes a difference.

$('LI.s-result-item SPAN + A')
    .filter( function(){ return parseInt($(this).text())<100; } )
    .parent().css({ "opacity": "0.25" });

Screenshot of items I am trying to hide: screenshot

1

There are 1 best solutions below

0
On

parseInt doesn't parse grouping commas in numbers so strip them first:

parseInt($(this).text().replace(/,/g, ""))

P.S. regexp is used to process items with more than a million reviews (well, that might happen).