suika8melon / Add link Amazon seller central

// ==UserScript==
// @name        Add link  Amazon seller central
// @namespace  https://openuserjs.org/users/suika8melon
// @version      0.1
// @description  keepa add link
// @author       You
// @match        https://keepa.com/
// @icon         https://www.google.com/s2/favicons?domain=keepa.com
// @grant        none
// @license MIT
// @copyright 2021, suika8melon (https://openuserjs.org/users/suika8melon)
// ==/UserScript==

(function () {
  'use strict';

  function getASIN(a) {
    var b;
    if (!b) {
      b = a.match(/\/#!product\/\d-(\w{10})/i);
    }
    if (!b) {
      b = a.match(/\/iframe_addon.html#\d-0-(\w{10})/i);
    }
    if (!b) {
      return null;
    }
    return b[1].toUpperCase();
  }

  let interval = setInterval(() => {
    let tabHead = document.querySelector('#tabHead');
    if (tabHead) {
      console.log('exists tabHead!');
      let newLI = document.createElement("li");
      newLI.className = 'tabItem';
      let newA = document.createElement("a");
      newA.href = `https://sellercentral.amazon.co.jp/product-search/search?q=${getASIN(location.href)}`;
      newA.target = "_blank";
      const newContent = document.createTextNode("セラーセントラル");
      newA.appendChild(newContent);
      newLI.appendChild(newA);
      tabHead.appendChild(newLI);
      clearInterval(interval);
    }
  }, 1000);
})();