Skip to content

Instantly share code, notes, and snippets.

@paulbaker3
Last active August 13, 2016 17:21
Show Gist options
  • Save paulbaker3/6b93e3622b8ece694b04 to your computer and use it in GitHub Desktop.
Save paulbaker3/6b93e3622b8ece694b04 to your computer and use it in GitHub Desktop.
Amazon Top 20 Scanner
// ==UserScript==
// @name Amazon Top 20 Scanner
// @namespace http://www.paulbaker3.com
// @version 1.0
// @description Scans Amazon bestseller urls similar to http://www.amazon.com/gp/bestsellers/*
// @author Paul Baker
// @grant MIT License
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @include https://www.amazon.com/*
// @include http://www.amazon.com/*
// ==/UserScript==
var max_price, max_reviews, min_price, min_reviews, nr_700plus_revs, price, prices, rating, ratings, _fn, _fn1, _i, _j, _len, _len1;
console.log("Scanning page for Amazon Top 20 data...");
prices = $(".price").contents();
ratings = $(".crAvgStars").children("a");
max_price = 0;
min_price = 999999999999;
max_reviews = 0;
min_reviews = 999999999999;
nr_700plus_revs = 0;
_fn = function() {
price = parseFloat(price.data.replace(/\$|,/g, ''));
if (price > max_price) {
max_price = price;
}
if (price < min_price) {
return min_price = price;
}
};
for (_i = 0, _len = prices.length; _i < _len; _i++) {
price = prices[_i];
_fn();
}
_fn1 = function() {
var rt;
rt = parseFloat(rating.textContent.replace(/\$|,/g, ''));
if (rt > max_reviews) {
max_reviews = rt;
}
if (rt < min_reviews) {
min_reviews = rt;
}
if (rt > 700) {
return nr_700plus_revs += 1;
}
};
for (_j = 0, _len1 = ratings.length; _j < _len1; _j++) {
rating = ratings[_j];
_fn1();
}
msg = '';
msg += "Max Price: " + max_price + '\n\n'
msg += "Min Price: " + min_price + '\n\n'
msg += "Nr with 700 Reviews: " + nr_700plus_revs + '\n\n'
msg += "Max Reviews: " + max_reviews + '\n\n'
msg += "Min Reviews: " + min_reviews + '\n\n'
if (min_price < 999999999999) {
alert(msg);
} else {
console.log("Scan complete. Nothing to report.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment