Simple Amazon Shortcuts

Check price history and review authenticity

目前為 2022-04-19 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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://greasyfork.org/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();
    }
})();