Amazon CPU Tamer

It reduces CPU usage on Amazon shopping pages. Enjoy your snappy shopping.

04.11.2020 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Amazon CPU Tamer
// @name:ja     Amazon CPU Tamer
// @name:zh-CN  Amazon CPU Tamer
// @namespace   knoa.jp
// @description It reduces CPU usage on Amazon shopping pages. Enjoy your snappy shopping.
// @description:ja AmazonのショッピングページでのCPU使用率を削減します。お買いものをサクサク楽しみましょう。
// @description:zh-CN 减少Amazon购物页面上的CPU利用率。顺利地享受买东西吧。
// @include     https://www.amazon.*
// @exclude     https://www.amazon.co.jp/*/cart/*
// @exclude     https://www.amazon.co.jp/*/buy/*
// @version     1.1.1
// @grant       none
// @run-at      document-start
// ==/UserScript==

/*
[update] 1.1.1
minor fix.

*/
(function(){
  const SCRIPTNAME = 'Amazon Cpu Tamer';
  console.log(SCRIPTNAME);
  const TAMEDINTERVAL = 60*1000;
  /* tame quick intervals */
  window.originalSetInterval = window.setInterval;
  window.setInterval = function(f, interval, ...args){
    if(interval < TAMEDINTERVAL){
      console.log(SCRIPTNAME, 'interval:', interval, 'to', TAMEDINTERVAL);
      interval = TAMEDINTERVAL;
    }
    return window.originalSetInterval(f, interval, ...args);
  };
  /* add an associate tag */
  switch(location.host){
    case('www.amazon.com'):
      addTag('knoa-20');
      break;
    case('www.amazon.co.jp'):
      addTag('knoa-22');
      break;
  }
  function addTag(tag){
    const url = new URL(location.href);
    if(url.searchParams.get('tag') !== null) return;/* do not overwrite */
    const separator = (url.search === '') ? '?' : '&';
    console.log(SCRIPTNAME, 'associate tag:', tag);
    history.replaceState(null, document.title, location.href + separator + 'tag=' + tag);
  }
})();