Last active
March 15, 2023 18:55
-
-
Save im-noob/837bbff3c660f8832459cc81f5dcad2f to your computer and use it in GitHub Desktop.
Amazon Best Seller Page filter for temper monkey
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 Filter Amazon | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.amazon.in/gp/bestsellers/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.in | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.onload = function(){ | |
window.scrollTo(0, document.body.scrollHeight); | |
window.document.body.scrollTo(0, document.body.scrollHeight); | |
setTimeout(function(){ | |
window.document.body.scrollTo(0, document.body.scrollHeight); | |
var input_rate = parseFloat(prompt('Ratting:')) | |
var input_review_count = parseInt(prompt('Review Count:')) | |
var boxes = document.getElementsByClassName('zg-grid-general-faceout') | |
for(var i=0; i<boxes.length; i ++){ | |
let box = boxes[i]; | |
try{ | |
let star_text = box.getElementsByTagName('a')[2].text; | |
let star_text_split = star_text.replace(',','').split(' out of 5 stars '); | |
let ratting = parseFloat(star_text_split[0]); | |
let review_count = parseFloat(star_text_split[1]); | |
// Which has no rattings | |
if (isNaN(ratting) || isNaN(review_count)){ | |
box.parentElement.hidden = true; | |
} | |
console.log( | |
i, ratting, review_count,ratting>=input_rate,review_count >= input_review_count, (ratting>=input_rate && review_count >= input_review_count), | |
(!(ratting>=input_rate && review_count >= input_review_count)) | |
) | |
if (!(ratting>=input_rate && review_count >= input_review_count)){ | |
box.parentElement.hidden = true; | |
} | |
} | |
catch{ | |
box.parentElement.hidden = true; | |
} | |
} | |
}, 2000) | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment