// ==UserScript==
// @name Simple Amazon Shortcuts
// @namespace flightless22.SAS
// @description Check price history and review authenticity
// @version 2022.04.18
// @author flightless22
// @license MIT
// @homepageURL https://gf.qytechs.cn/en/scripts/427433
// @icon none
// @include https://*.amazon.*/*
// @match https://*.amazon.*/*
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// ==/UserScript==
(function() {
'use strict';
// [1] TLD / [2] ASIN
const amazonsrc = /^https:\/\/[a-zA-Z]+\.amazon\.([.a-zA-Z]+).*\/([a-zA-Z0-9]{10})/.exec(location.href);
if (amazonsrc !== null && amazonsrc.length > 2) {
var service = {
"Keepa": {
"desc": "Price History",
"tld": {"com":"Default", "co.uk": 2, "de": 3, "fr": 4, "co.jp": 5, "ca": 6, "it": 8, "es": 9, "in": 10,
"com.mx": 11, "com.br": 12}, ///TODODO
"durl": "https://keepa.com/#!product/1-$asin$",
"url": "https://keepa.com/#!product/$tld$-$asin$",
"f" : function() { getservice("Keepa") }
},
"Camel Camel Camel": {
"desc": "Price History",
"tld": {"au":"au", "ca":"ca", "com":"Default", "co.uk":"uk", "de":"de", "es":"es", "fr":"fr"},
"durl": "https://camelcamelcamel.com/product/$asin$",
"url": "https://$tld$.camelcamelcamel.com/product/$asin$",
"f" : function() { getservice("Camel Camel Camel") }
},
"Review Meta": {
"desc": "Review Analysis",
"tld": {"ca":"ca", "com.au":"au", "com.br":"br","com.mx":"mx", "cn":"cn", "com":"Default", "co.jp":"jp",
"co.uk":"uk", "de":"de", "es":"es", "fr":"fr", "it":"it", "in":"in", "nl":"nl"},
"durl": "https://reviewmeta.com/amazon/$asin$",
"url": "https://reviewmeta.com/amazon-$tld$/$asin$",
"f" : function() { getservice("Review Meta") }
},
"Fake Spot": {
"desc": "Review Analysis",
"tld": {"ca":"ca", "com.au":"com.au", "co.jp":"co.jp", "com":"Default", "co.uk":"co.uk", "de":"de", "es":"es",
"fr":"fr", "in":"in", "it":"it"},
"durl": "https://www.fakespot.com/analyze?url=http://amazon.com/dp/$asin$",
"url": "https://www.fakespot.com/analyze?url=http://amazon.$tld$/dp/$asin$",
"f" : function() { getservice("Fake Spot") }
}
};
function getservice(name) {
var url, tld = service[name]["tld"][amazonsrc[1]];
if (tld === "Default") {
url = service[name]["durl"].replace("$asin$", amazonsrc[2]);
} else {
if (tld === undefined) {
var p = confirm(`${name} may not support "amazon.${amazonsrc[1]}".\n Do you want to continue anyway?`);
if (p === false) return;
tld = amazonsrc[1];
}
url = service[name]["url"].replace("$tld$", tld);
url = url.replace("$asin$", amazonsrc[2]);
}
GM_openInTab(url);
};
function setup() {
for (var name in service) {
GM_registerMenuCommand(
`${name} : ${service[name]["desc"]} ${service[name]["tld"][amazonsrc[1]] === undefined ?
` ( "amazon.${amazonsrc[1]}" may be unsupported.` : ""}`,
service[name]["f"]
);
}
}
setup();
}
})();