Greasy Fork 还支持 简体中文。

Amazon CamelCamelCamel + Keepa Price Charts

Add a CamelCamelCamel and Keepa price charts to Amazon product pages.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            Amazon CamelCamelCamel + Keepa Price Charts
// @version         1.0.8
// @description     Add a CamelCamelCamel and Keepa price charts to Amazon product pages.
// @author          miki.it
// @namespace       null
// @homepage        https://github.com/mikispag/userscripts/
// @include         https://www.amazon.*/*
// @include         https://smile.amazon.*/*
// @run-at          document-end
// ==/UserScript==

function getASIN() {
    var asinElement = document.getElementById("ASIN") || document.evaluate("//@data-asin", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
    if (!asinElement) {
        throw new Error("Amazon CamelCamelCamel + Keepa Price Charts: unable to find ASIN!");
    }
    return asinElement.value;
}

window.addEventListener("load", function() {
    var tld = document.domain.split(".").pop();
    var country = tld;
    if (tld == "com") {
        country = "us";
    }

    var asin = getASIN();
    if (!asin) {
        throw new Error("Amazon CamelCamelCamel + Keepa Price Charts: unable to get ASIN!");
    }

    var parentElement = document.getElementById("unifiedPrice_feature_div") || document.getElementById("MediaMatrix");
    if (!parentElement) {
        throw new Error("Amazon CamelCamelCamel + Keepa Price Charts: unable to get parent element!");
    }

    var camelChartContainer = document.createElement("div");
    var camelLink = document.createElement("a");
    camelLink.target = "_blank";
    camelLink.href = "https://" + country + ".camelcamelcamel.com/product/" + asin;
    var camelChart = new Image(500, 400);
    camelChart.src = "https://charts.camelcamelcamel.com/" + country + "/" + asin + "/amazon-new-used.png?force=1&zero=0&w=500&h=400&desired=false&legend=1&ilt=1&tp=all&fo=0";
    camelLink.appendChild(camelChart);
    camelChartContainer.appendChild(camelLink);

    var keepaChartContainer = document.createElement("div");
    var keepaLink = document.createElement("a");
    keepaLink.target = "_blank";
    keepaLink.href = "https://keepa.com/#!product/8-" + asin;
    var keepaChart = new Image(500, 200);
    keepaChart.src = "https://graph.keepa.com/pricehistory.png?used=1&asin=" + asin + "&domain=" + tld;
    keepaLink.appendChild(keepaChart);
    keepaChartContainer.appendChild(keepaLink);

    var chartsContainer = document.createElement("div");
    chartsContainer.appendChild(camelChartContainer);
    chartsContainer.appendChild(keepaChartContainer);
    parentElement.appendChild(chartsContainer);
}, false);