// ==UserScript== // @name 提取百度网盘链接和提取码(追新番专用) // @namespace http://tampermonkey.net/ // @version 1.3 // @description 一键提取追新番网页中的百度网盘链接和提取码,用于批量转存,支持一键复制 // @author CNOS // @match https://*.fanxinzhui.com/rr/* // @grant none // @downloadURL https://update.greasyfork.icu/scripts/529944/%E6%8F%90%E5%8F%96%E7%99%BE%E5%BA%A6%E7%BD%91%E7%9B%98%E9%93%BE%E6%8E%A5%E5%92%8C%E6%8F%90%E5%8F%96%E7%A0%81%EF%BC%88%E8%BF%BD%E6%96%B0%E7%95%AA%E4%B8%93%E7%94%A8%EF%BC%89.user.js // @updateURL https://update.greasyfork.icu/scripts/529944/%E6%8F%90%E5%8F%96%E7%99%BE%E5%BA%A6%E7%BD%91%E7%9B%98%E9%93%BE%E6%8E%A5%E5%92%8C%E6%8F%90%E5%8F%96%E7%A0%81%EF%BC%88%E8%BF%BD%E6%96%B0%E7%95%AA%E4%B8%93%E7%94%A8%EF%BC%89.meta.js // ==/UserScript== (function() { 'use strict'; // 提取百度网盘链接和提取码的函数 function extractBaiduLinks() { const links = document.querySelectorAll('a[href*="pan.baidu.com/s/"]'); const results = []; links.forEach(link => { const href = link.getAttribute('href'); const passwordElement = link.parentElement.querySelector('.password'); const password = passwordElement ? passwordElement.textContent.trim() : ''; if (href && password) { results.push(`${href} ${password}`); } }); return results; } // 创建一个按钮用于触发提取操作 const button = document.createElement('button'); button.textContent = '提取百度网盘链接'; button.style.position = 'fixed'; button.style.top = '10px'; button.style.right = '10px'; button.style.zIndex = '999999'; button.style.padding = '5px 10px'; button.style.fontSize = '14px'; button.style.backgroundColor = '#4CAF50'; button.style.color = 'white'; button.style.border = 'none'; button.style.borderRadius = '5px'; button.style.cursor = 'pointer'; // 添加按钮点击事件 button.addEventListener('click', () => { const links = extractBaiduLinks(); if (links.length === 0) { alert('未找到百度网盘链接!'); return; } // 在原页面中显示结果 const resultDiv = document.createElement('div'); resultDiv.id = 'extracted-links'; resultDiv.style.position = 'fixed'; resultDiv.style.top = '60px'; resultDiv.style.right = '10px'; resultDiv.style.width = '300px'; resultDiv.style.height = 'auto'; resultDiv.style.backgroundColor = '#f9f9f9'; resultDiv.style.padding = '10px'; resultDiv.style.border = '1px solid #ccc'; resultDiv.style.borderRadius = '5px'; resultDiv.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)'; resultDiv.style.zIndex = '999998'; const resultText = document.createElement('pre'); resultText.textContent = links.join('\n'); resultText.style.whiteSpace = 'pre-wrap'; resultText.style.wordWrap = 'break-word'; const copyButton = document.createElement('button'); copyButton.textContent = '一键复制'; copyButton.style.display = 'block'; copyButton.style.margin = '10px 0'; copyButton.style.padding = '5px 10px'; copyButton.style.fontSize = '14px'; copyButton.style.backgroundColor = '#007bff'; copyButton.style.color = 'white'; copyButton.style.border = 'none'; copyButton.style.borderRadius = '5px'; copyButton.style.cursor = 'pointer'; // 复制功能实现(使用现代剪贴板 API) copyButton.addEventListener('click', async () => { try { await navigator.clipboard.writeText(links.join('\n')); alert('已复制到剪贴板!'); } catch (err) { console.error('复制失败:', err); alert('复制失败,请手动复制内容。'); } }); resultDiv.appendChild(resultText); resultDiv.appendChild(copyButton); document.body.appendChild(resultDiv); }); // 将按钮添加到页面中 document.body.appendChild(button); })();