// ==UserScript== // @name 获取商品链接并复制到剪贴板 // @namespace http://tampermonkey.net/ // @version 0.5 // @description 获取当前页面所有商品链接并复制到剪贴板 // @author Rayu // @license MIT // @match https://*.taobao.com/* // @match https://*.tmall.com/* // @match https://*.pinduoduo.com/* // @match https://*.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); })();