// ==UserScript== // @name 获取淘宝商品链接 // @version v1.0 // @namespace Violentmonkey Scripts // @description 通过关键词搜索出来的商品列表,点击某个商品的添加按钮,添加到右侧的链接列表,支持一键复制所有链接,并支持导出链接列表文件 // @author Finn // @license MIT // @match https://s.taobao.com/search // @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js // @downloadURL none // ==/UserScript== ;(function () { 'use strict'; var urlList = []; var txtbox = document.getElementsByClassName('grid-left'); var newTxtBox = document.createElement('div'); var newTxtBoxTitle = document.createElement('p'); var oneClickCopy = document.createElement('a'); setTimeout(function(){ newTxtBox.class = "myNewTxtBox"; newTxtBox.style = "width:200px;min-height:50px;max-height:500px;position:fixed;background:#f5f5f5;border-radius:4px;padding:10px;overflow:auto;top:10%;right:20px"; newTxtBoxTitle.innerHTML = "商品URL列表:"; newTxtBoxTitle.style = "font-weight:bold;" oneClickCopy.innerHTML = "一键复制"; oneClickCopy.style = "width:60px;height:25px;line-height:25px;text-align:center;display:block;position:fixed;background:#f5f5f5;border-radius:4px;top:7%;right:20px;cursor:pointer;"; oneClickCopy.id = "copyBtn" oneClickCopy.addEventListener('click',copyClick); newTxtBox.appendChild(newTxtBoxTitle); txtbox[1].appendChild(newTxtBox); txtbox[1].appendChild(oneClickCopy); console.log("加载成功"); },500); $(function (){ getCommoditiesList(); monitorJump(); }) function getCommoditiesList() { var list = document.getElementsByClassName('row row-2 title'); setTimeout(function(){ for(var i=1; i<=list.length-1; i++){ var newnode = document.createElement("b"); newnode.innerHTML = "添加"; newnode.class = "myAddButton"; newnode.style = "width: 50px;height: 30px;display: block;position: absolute;background: #ccc;text-align: center;line-height: 30px;border-radius: 4px;margin-top: -24px;margin-left: 70px;cursor: pointer;user-select: none;"; newnode.id=i; var sb = list[i].parentNode; sb.appendChild(newnode); sb.onclick = function(e){ urlList.push(e.target.parentNode.children[1].children[0].href); adddTxtBox(e.target.parentNode.children[1].children[0].href); } } },1000) } function addTxtBox(){ var test = document.getElementsByClassName('myNewTxtBoxP'); for(var i=0;i