Simple Amazon Shortcuts dev2

Quickly check price history and review authenticity

当前为 2022-04-19 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Simple Amazon Shortcuts dev2
// @namespace   flightless22.SAS
// @description Quickly 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();
    }
})();