Greasy Fork 还支持 简体中文。

Add Keepa Links

Amazon商品ページにKeepaの価格履歴のリンクを追加

  1. // ==UserScript==
  2. // @name Add Keepa Links
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.1
  5. // @description Amazon商品ページにKeepaの価格履歴のリンクを追加
  6. // @author himuro_majika
  7. // @match https://www.amazon.co.jp/*dp/*
  8. // @match https://www.amazon.co.jp/*gp/*
  9. // @icon https://www.google.com/s2/favicons?domain=keepa.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. init();
  17. function init() {
  18. insertButton();
  19. }
  20. function getProduct() {
  21. const url = location.href;
  22. const patternList = [
  23. /dp\/([^/?]+)/,
  24. /\/gp\/product\/([^/?]+)/
  25. ];
  26. let product = null;
  27. patternList.forEach(pattern => {
  28. const match = url.match(pattern);
  29. if (match) {
  30. product = match[1];
  31. return;
  32. }
  33. });
  34. return product;
  35. }
  36. function getTargetElement() {
  37. return document.getElementById("buybox");
  38. }
  39. function createKeepaLinkButton() {
  40. const button = document.createElement("div");
  41. const a = document.createElement("a");
  42. const keepaUrl = "https://keepa.com/#!search/5-";
  43. a.setAttribute("target", "_blank");
  44. a.innerText = "📉Keepaで価格を確認する.";
  45. a.addEventListener("click", (e) => {
  46. e.target.setAttribute("href", keepaUrl + getProduct());
  47. })
  48. button.appendChild(a);
  49. return button;
  50. }
  51. function insertButton() {
  52. const tEle = getTargetElement();
  53. tEle.parentNode.parentNode.appendChild(createKeepaLinkButton());
  54. }
  55. })();