Keepa for Amazon Mobile

Insert Keepa chart into Amazon mobile. Tested on Adguard for Android.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Keepa for Amazon Mobile
// @namespace   https://p1kachu.net
// @description Insert Keepa chart into Amazon mobile. Tested on Adguard for Android.
// @author      pikatenor
// @version     0.1.0
// @supportURL  https://github.com/pikatenor/keepa-mobile
// @include     https://www.amazon.tld/dp/*
// @include     https://www.amazon.tld/*/dp/*
// @include     https://www.amazon.tld/gp/product/*
// @include     https://www.amazon.tld/gp/aw/d/*
// @include     https://www.amazon.*/dp/*
// @include     https://www.amazon.*/*/dp/*
// @include     https://www.amazon.*/gp/product/*
// @include     https://www.amazon.*/gp/aw/d/*
// @grant       GM_info
// ==/UserScript==

(function(){

  const domainIdMap = {
    'com':   1,
    'uk':    2,
    'de':    3,
    'fr':    4,
    'co.jp': 5,
    'ca':    6,
    'in':    10,
  }

  const isMobile = document.documentElement.classList.contains('a-mobile');
  const asin = document.getElementById('a')?.value || document.getElementById('twister-plus-asin')?.value; // #a ってマジかよ
  const domainId = domainIdMap[document.location.hostname.match('.*\.amazon\.(.*)$')[1]];
  const targetElement = document.getElementById('olpLinkWidget_feature_div');

  if (isMobile && asin && domainId && targetElement) {
    targetElement.insertAdjacentHTML(
      'afterend',
      `<a href="https://keepa.com/#!product/${domainId}-${asin}"><img style="width:100%; height:100%; margin-bottom:0.5em;" src="https://graph.keepa.com/pricehistory.png?type=2&width=658&height=450&amazon=1&new=1&used=1&salesrank=1&range=365&fba=0&fbm=0&bb=0&ld=1&wd=1&asin=${asin}&domain=${domainId}" id="keepa"></a>`
    );
  }

})();