// ==UserScript== // @name 快捷键采集与复制商品链接 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 在淘宝、天猫、1688 和拼多多页面按 F3 触发“开始采集”按钮,并提供一个按钮复制所有商品链接 // @author Rayu // @license MIT // @match *://*.taobao.com/* // @match *://*.tmall.com/* // @match *://*.1688.com/* // @match *://*.yangkeduo.com/* // @grant GM_setClipboard // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 创建按钮 let button = document.createElement('button'); button.innerHTML = '复制商品链接'; button.style.position = 'fixed'; button.style.top = '10px'; button.style.left = '10px'; // 修改位置到左上角 button.style.zIndex = 1000; button.style.padding = '10px'; button.style.backgroundColor = '#ff4500'; button.style.color = '#fff'; button.style.border = 'none'; button.style.borderRadius = '5px'; button.style.cursor = 'pointer'; // 按钮点击事件 button.onclick = function() { // 获取所有商品链接 let links = document.querySelectorAll('a[href*="item.taobao.com/item.htm"], a[href*="detail.tmall.com/item.htm"], a[href*="mobile.yangkeduo.com/goods.html"]'); let linkArray = Array.from(links).map(link => link.href); // 将链接复制到剪贴板 GM_setClipboard(linkArray.join('\n')); alert('商品链接已复制到剪贴板!'); }; // 将按钮添加到页面 document.body.appendChild(button); // 监听键盘事件 document.addEventListener('keydown', function (e) { if (e.key === 'F3') { // 检测是否按下 F3 键 const button = document.querySelector('.dxmFetchBtn'); // 找到“开始采集”按钮 if (button) { button.click(); // 触发按钮点击 console.log('“开始采集”按钮已触发!'); } else { console.log('未找到“开始采集”按钮!'); } } }); })();