Greasy Fork is available in English.

速卖通获取商品链接/店铺id

获取商品链接/店铺id

질문, 리뷰하거나, 이 스크립트를 신고하세요.
// ==UserScript==
// @name         速卖通获取商品链接/店铺id
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  获取商品链接/店铺id
// @author       menkeng
// @match        https://www.aliexpress.com/*
// @grant        none
// ==/UserScript==
//定制服务 QQ:605011383
//定制服务 QQ:605011383
//定制服务 QQ:605011383

(function() {
    'use strict';
    const textBox = document.createElement('textarea');
    textBox.style.cssText="width: 100%; height: 100px; position: fixed; bottom: 10px; z-index: 999;";
    document.body.appendChild(textBox);
    const regex = /www\.aliexpress\.com\/item\/[0-9]+\.html/;
    const regex_store = /\/store\/([0-9]+)/
    window.addEventListener('load', () => {
      const elements = document.querySelectorAll('a[href]');
      elements.forEach(element => {
        if (regex.test(element.href)) {
          element.style.position = 'relative';
          element.style.overflow = 'visible';
          const productButton = document.createElement('button');
          const storeButton = document.createElement('button');
          productButton.innerText = '商品';
          storeButton.innerText = '店铺';
          productButton.style.cssText = 'position: absolute; top: 0; left: -66px; height: 50px; width: 50px; z-index: 999;';
          storeButton.style.cssText = 'position: absolute; top: 0; right: -66px; height: 50px; width: 50px; z-index: 999;';
          productButton.addEventListener('click', event => {
            event.preventDefault();
            textBox.value += element.href + '\n';
          });
          storeButton.addEventListener('click', event => {
            event.preventDefault();
            const storeLink = element.querySelector('div:nth-child(2) > span > a ');
            if (storeLink) {
              const storeIdMatch = storeLink.href.match(regex_store);
              if (storeIdMatch) {
                const storeId = storeIdMatch[1];
                textBox.value += storeId + '\n';
              }
            }
          });
          element.appendChild(productButton);
          element.appendChild(storeButton);
        }
      });
    });
})();