// ==UserScript== // @name XHS-Toys // @version 1.0 // @description 提取小红书用户主页作品和搜索结果作品链接。 // @author WitYue // @match https://www.xiaohongshu.com/* // @grant GM_setClipboard // @grant GM_registerMenuCommand // @grant unsafeWindow // @license GNU General Public License v3.0 // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPUAAAD1CAYAAACIsbNlAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABUuSURBVHhe7d0JjJXlvcfxP8O+DDCICIgsgiAuoKKAIoKiBtSoxVwb16JYtbXxXqMRY71Uk6ata27SpLYGE2lutIpSigsgVkVBUaMii4KC7Mgq27DODOc+3+c9rxymwzDAnHPtf36f5GTOMnPOEc/v/f+f533e99TLBCYibhRlf4qIEwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDMKtYgzCrWIMwq1iDP1MkH2ulSHf6Z9+8K/WL3sHQHXc2+L/Ago1NUpLzfbscNs61azFSuSS+PGZs2aJQFv08asY0ezkpLkvgYNsn9YHf65tSGQ/FGoq8I/yebNZh98YDZ9utm8eWbLlpmtXWvWsKFZkybJ77Rsadali1nfvmaD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BFgWnNwKCcr3mjHWa7K+dBmzJgR14NXdaio5JdCTZvNt2SMHWt28cUWPrnJ19nWNir00KFmTz1lNm6c2ejRyZcD/IhRgQkuY3HacY4Eo0pzBlLOIU7rTdDZx00rTvj5fSbfmIhj+WhVh4pKftXtAzpSBDs9p3efPsl3UxPC3LOM0JYf6fQDM9xDhiTj5/CBj2P2f4MZZw7UoL1moQrh5at3OMab3WRUYFpyKjPr07lwm7E0JzCk0tOic4AI428pHE2UVYW2klMDc/QWB3UwicZJAMKHOc6SM+ZmfMrGgCO9GHtzO70gvU7Vv/DCpMWn1Wdj8W+CjwZjY2azGSunh1BStXmM4FLN+R02AASa36Oyp49r5rvwFOpDCR/ouN+aI7oINTPiXAhsbqjBB7iqULObTCcKkAJRqEWcUW8k4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3ijEIt4oxCLeKMQi3iitn/AR16saj4nNpbAAAAAElFTkSuQmCC // @run-at document-end // ==/UserScript== (function() { 'use strict'; const createButton = () => { const container = document.createElement('div'); container.id = 'xhsToys'; container.innerHTML = ` `; document.body.appendChild(container); }; const extractNotes = (notes) => { try { if (!Array.isArray(notes)) { throw new Error("无效的作品数据格式"); } const urls = notes.map(item => { if ((!item?.id || !item?.xsecToken) || item.id.includes("-")) { console.warn("异常数据项:", item); return null; } return `https://www.xiaohongshu.com/explore/${item.id}?xsec_token=${item.xsecToken}&xsec_source=pc_user`; }).filter(Boolean).join('\n'); if (!urls) { throw new Error("未找到有效作品链接"); } GM_setClipboard(urls, 'text', () => alert('已成功复制作品链接!')); } catch (e) { alert(`提取失败: ${e.message}`); } }; const handleButtonClick = () => { if (location.href.includes('search_result')) { extractNotes(unsafeWindow.__INITIAL_STATE__.search.feeds._rawValue); } else if (location.href.includes('/user/profile/')) { extractNotes(unsafeWindow.__INITIAL_STATE__.user.notes._rawValue[0]); } else { alert('请先进入搜索页或用户主页后再点击复制!\n加个广告:本人提供头条、公众号等采集AI改写及在线存草稿软件,欢迎地球联系:yue415426'); } }; setTimeout(() => { createButton(); document.getElementById('extractNotes').onclick = handleButtonClick; }, 1500); })();