Amazon Camel Graph

Add a CamelCamelCamel graph with link to Amazon product pages.

当前为 2020-11-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Amazon Camel Graph
  3. // @version 1.0.0
  4. // @description Add a CamelCamelCamel graph with link to Amazon product pages.
  5. // @author miki.it
  6. // @namespace null
  7. // @include https://www.amazon.*/*
  8. // @include https://smile.amazon.*/*
  9. // ==/UserScript==
  10.  
  11. var chartType = "amazon-new"; // Possible other values are "amazon", "new", "used", "new-used", & "amazon-new-used"
  12.  
  13. var country = document.domain.split(".").pop();
  14. if (country == "com") {
  15. country = "us";
  16. }
  17.  
  18. var asin = document.getElementById("ASIN").value;
  19. if (!asin) {
  20. throw new Error("Amazon Camel Graph: unable to get ASIN!");
  21. }
  22.  
  23. var parentElement = document.getElementById("unifiedPrice_feature_div");
  24. if (!parentElement) {
  25. throw new Error("Amazon Camel Graph: unable to get parent element!");
  26. }
  27.  
  28. var link = document.createElement("a");
  29. link.target = "_blank";
  30. link.href = "https://" + country + ".camelcamelcamel.com/product/" + asin;
  31.  
  32. var chart = new Image(400, 250);
  33. chart.src = "https://charts.camelcamelcamel.com/" + country + "/" + asin + "/" + chartType + ".png?force=1&zero=0&w=400&h=250&desired=false&legend=1&ilt=1&tp=all&fo=0";
  34. link.appendChild(chart);
  35.  
  36. parentElement.appendChild(link);