Amazon Camel Syringe

previous price charts on amazon pages

  1. // ==UserScript==
  2. // @name Amazon Camel Syringe
  3. // @description previous price charts on amazon pages
  4. // @match https://www.amazon.it/*
  5. // @match https://www.amazon.de/*
  6. // @match https://www.amazon.co.uk/*
  7. // @match https://www.amazon.fr/*
  8. // @match https://www.amazon.es/*
  9. // @match https://www.amazon.com/*
  10. // @grant none
  11. // @version 1.0
  12. // @author J-Bird
  13. // @grant GM_xmlhttpRequest
  14. // @namespace https://greasyfork.org/en/users/729550-sugimoto
  15. // ==/UserScript==
  16.  
  17. (async () => {
  18. let locale = "us";
  19. const URL = window.location.href;
  20. if (URL.includes(".it")) locale = "it";
  21. if (URL.includes(".de")) locale = "de";
  22. if (URL.includes(".fr")) locale = "fr";
  23. if (URL.includes(".es")) locale = "es";
  24. if (URL.includes(".co.uk")) locale = "uk";
  25.  
  26. if (URL.includes("/dp/") || URL.includes("/gp/product/")) {
  27. let itemId = URL;
  28. if (URL.includes("?")) itemId = itemId.split("?")[0];
  29. if (URL.includes("/dp/")) itemId = itemId.split("/dp/")[1];
  30. if (URL.includes("/gp/product/")) itemId = itemId.split("/gp/product/")[1];
  31. if (itemId.includes('/')) itemId = itemId.split("/")[0];
  32.  
  33. const graphImageURL = `https://charts.camelcamelcamel.com/${locale}/${itemId}/amazon-new.png?force=1&zero=0&w=700&h=700&desired=false&legend=1&ilt=1&tp=all&fo=0&lang=en`;
  34. const camelPageURL = (locale === "us")
  35. ? `https://camelcamelcamel.com/product/${itemId}`
  36. : `https://${locale}.camelcamelcamel.com/product/${itemId}`;
  37.  
  38. const camelGraph = document.createElement("img");
  39. camelGraph.src = graphImageURL;
  40. camelGraph.style.filter = "invert(100%)";
  41. const camelLink = document.createElement("a");
  42. camelLink.href = camelPageURL;
  43. const camelWidget = document.createElement("div");
  44. camelWidget.style.paddingLeft = "40px";
  45.  
  46. camelLink.append(camelGraph);
  47. camelWidget.append(camelLink);
  48.  
  49. const target = document.getElementById("leftCol");
  50. target.append(camelWidget);
  51. }
  52. })();