您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add a button to the page; clicking it extracts all ASIN values, combines them with Amazon product URL, displays for easy copying, and auto-closes the display on copy.
当前为
// ==UserScript== // @name Extract ASIN // @namespace http://tampermonkey.net/ // @version 1.0 // @description Add a button to the page; clicking it extracts all ASIN values, combines them with Amazon product URL, displays for easy copying, and auto-closes the display on copy. // @author You // @match https://www.amazon.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to create the display element for Amazon product links and ASIN count function createDisplayElement(asinLinks) { const container = document.createElement('div'); container.style.position = 'fixed'; container.style.top = '10px'; container.style.right = '10px'; container.style.padding = '10px'; container.style.backgroundColor = 'white'; container.style.border = '1px solid black'; container.style.zIndex = '10000'; container.style.overflow = 'auto'; container.style.maxHeight = '90vh'; // Display the count of ASINs found const countDisplay = document.createElement('p'); countDisplay.textContent = `ASINs found: ${asinLinks.length}`; container.appendChild(countDisplay); const textArea = document.createElement('textarea'); textArea.value = asinLinks.join('\n'); textArea.rows = '20'; textArea.cols = '50'; textArea.style.marginTop = '10px'; // Add some space between the count and the text area const copyButton = document.createElement('button'); copyButton.textContent = 'Copy to Clipboard'; copyButton.onclick = function() { textArea.select(); document.execCommand('copy'); container.remove(); // This line closes the container after copying }; container.appendChild(textArea); container.appendChild(copyButton); document.body.appendChild(container); } // Function to extract ASIN values and generate Amazon product links function generateAmazonLinks() { const targetElements = document.querySelectorAll('[data-asin]'); const asinLinks = []; targetElements.forEach(element => { const asin = element.getAttribute('data-asin'); if (asin) { const amazonLink = `https://www.amazon.com/gp/product/${asin}`; asinLinks.push(amazonLink); } }); if (asinLinks.length > 0) { createDisplayElement(asinLinks); } } // Function to create the button that will trigger the generation of Amazon links function createExtractionButton() { const button = document.createElement('button'); button.textContent = 'Generate Amazon Links'; button.style.position = 'fixed'; button.style.bottom = '10px'; button.style.right = '10px'; button.style.padding = '10px'; button.style.backgroundColor = '#4CAF50'; button.style.color = 'white'; button.style.border = 'none'; button.style.cursor = 'pointer'; button.onclick = generateAmazonLinks; document.body.appendChild(button); } // Add the button to the page createExtractionButton(); })();