Amazon 购买数量高亮

[EN] Highlights purchase quantity on Amazon | [CN] 高亮显示Amazon商品购买数量

  1. // ==UserScript==
  2. // @name Amazon 购买数量高亮
  3. // @namespace https://gf.qytechs.cn/zh-CN/users/your-profile-id
  4. // @version 1.1.0
  5. // @description [EN] Highlights purchase quantity on Amazon | [CN] 高亮显示Amazon商品购买数量
  6. // @author 再见梵高 <wwxhqq739810171@gmail.com>
  7. // @license MIT
  8. // @match *://www.amazon.com/*
  9. // @match *://www.amazon.ca/*
  10. // @match *://www.amazon.co.uk/*
  11. // @match *://www.amazon.de/*
  12. // @match *://www.amazon.fr/*
  13. // @match *://www.amazon.it/*
  14. // @match *://www.amazon.es/*
  15. // @icon https://www.amazon.com/favicon.ico
  16. // @grant GM_addStyle
  17. // @supportURL mailto:wwxhqq739810171@gmail.com
  18. // ==/UserScript==
  19.  
  20. (function() {
  21. 'use strict';
  22.  
  23. const CONFIG = {
  24. highlightClass: 'amz-pq-highlight',
  25. styleRules: {
  26. color: '#FF4444',
  27. fontSize: '18px',
  28. fontWeight: '900',
  29. textShadow: '0 0 3px rgba(255,68,68,0.4)',
  30. animation: 'pulse 1s ease-in-out infinite'
  31. },
  32. textPatterns: [
  33. /\d+\+?\s?(?:bought|purchased|sold)/i,
  34. /multiple\s+times/i,
  35. /past\s+(?:month|week)/i
  36. ]
  37. };
  38.  
  39. GM_addStyle(`
  40. .${CONFIG.highlightClass} {
  41. color: ${CONFIG.styleRules.color} !important;
  42. font-size: ${CONFIG.styleRules.fontSize} !important;
  43. font-weight: ${CONFIG.styleRules.fontWeight} !important;
  44. text-shadow: ${CONFIG.styleRules.textShadow} !important;
  45. animation: ${CONFIG.styleRules.animation} !important;
  46. }
  47. @keyframes pulse {
  48. 0%,100% { transform: scale(1); }
  49. 50% { transform: scale(1.05); }
  50. }
  51. .social-proofing-faceout-title-text .${CONFIG.highlightClass} {
  52. display: inline-block;
  53. }
  54. `);
  55.  
  56. function checkText(text) {
  57. return CONFIG.textPatterns.some(p => p.test(text));
  58. }
  59.  
  60. function processElement(el) {
  61. if (el.classList.contains(CONFIG.highlightClass)) return;
  62. const text = el.textContent.trim();
  63. if (!checkText(text)) return;
  64.  
  65. const parent = el.closest([
  66. '.a-row.a-size-base',
  67. '#socialProofingAsinFaceout_feature_div',
  68. '.social-proofing-faceout'
  69. ].join(','));
  70. if (!parent) return;
  71.  
  72. const wrapper = document.createElement('span');
  73. wrapper.className = CONFIG.highlightClass;
  74. wrapper.innerHTML = el.innerHTML;
  75. el.parentNode.replaceChild(wrapper, el);
  76. }
  77.  
  78. function applyHighlight() {
  79. document.querySelectorAll([
  80. 'span.a-color-secondary',
  81. 'span.a-text-bold',
  82. 'span.social-proofing-faceout-title-text'
  83. ].join(',')).forEach(processElement);
  84. }
  85.  
  86. applyHighlight();
  87.  
  88. const observer = new MutationObserver(mutations => {
  89. mutations.some(m => m.addedNodes.length && applyHighlight());
  90. });
  91.  
  92. observer.observe(document.documentElement, {
  93. childList: true,
  94. subtree: true,
  95. attributes: false
  96. });
  97.  
  98. const events = ['page:change', 'spa-navigate', 'DOMContentLoaded'];
  99. events.forEach(e => window.addEventListener(e, applyHighlight));
  100. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址