blob: 0edf4fd7752773f5a5c0f0bd596083ade8bdc3b4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// ==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
// @downloadURL https://update.greasyfork.org/scripts/416590/Amazon%20CamelCamelCamel%20%2B%20Keepa%20Price%20Charts.user.js
// @updateURL https://update.greasyfork.org/scripts/416590/Amazon%20CamelCamelCamel%20%2B%20Keepa%20Price%20Charts.meta.js
// ==/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);
|