Amazon CPU Tamer

减少Amazon购物页面上的CPU利用率。顺利地享受买东西吧。

目前为 2020-11-04 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Amazon CPU Tamer
  3. // @name:ja Amazon CPU Tamer
  4. // @name:zh-CN Amazon CPU Tamer
  5. // @namespace knoa.jp
  6. // @description It reduces CPU usage on Amazon shopping pages. Enjoy your snappy shopping.
  7. // @description:ja AmazonのショッピングページでのCPU使用率を削減します。お買いものをサクサク楽しみましょう。
  8. // @description:zh-CN 减少Amazon购物页面上的CPU利用率。顺利地享受买东西吧。
  9. // @include https://www.amazon.*
  10. // @exclude https://www.amazon.co.jp/*/cart/*
  11. // @exclude https://www.amazon.co.jp/*/buy/*
  12. // @version 1.1.1
  13. // @grant none
  14. // @run-at document-start
  15. // ==/UserScript==
  16.  
  17. /*
  18. [update] 1.1.1
  19. minor fix.
  20.  
  21. */
  22. (function(){
  23. const SCRIPTNAME = 'Amazon Cpu Tamer';
  24. console.log(SCRIPTNAME);
  25. const TAMEDINTERVAL = 60*1000;
  26. /* tame quick intervals */
  27. window.originalSetInterval = window.setInterval;
  28. window.setInterval = function(f, interval, ...args){
  29. if(interval < TAMEDINTERVAL){
  30. console.log(SCRIPTNAME, 'interval:', interval, 'to', TAMEDINTERVAL);
  31. interval = TAMEDINTERVAL;
  32. }
  33. return window.originalSetInterval(f, interval, ...args);
  34. };
  35. /* add an associate tag */
  36. switch(location.host){
  37. case('www.amazon.com'):
  38. addTag('knoa-20');
  39. break;
  40. case('www.amazon.co.jp'):
  41. addTag('knoa-22');
  42. break;
  43. }
  44. function addTag(tag){
  45. const url = new URL(location.href);
  46. if(url.searchParams.get('tag') !== null) return;/* do not overwrite */
  47. const separator = (url.search === '') ? '?' : '&';
  48. console.log(SCRIPTNAME, 'associate tag:', tag);
  49. history.replaceState(null, document.title, location.href + separator + 'tag=' + tag);
  50. }
  51. })();

QingJ © 2025

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