您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Combined tools for Ximalaya Information Extraction and Auto Selection
当前为
// ==UserScript== // @name CRABPT Combined Tools(发种和有声书) // @namespace http://tampermonkey.net/ // @version 1.0 // @description Combined tools for Ximalaya Information Extraction and Auto Selection // @author Crabpt // @license Crabpt // @match https://www.ximalaya.com/* // @match *://*/* // @icon https://www.google.com/s2/favicons?sz=64&domain=crabpt.vip // @grant none // @run-at document-end // ==/UserScript== (function() { 'use strict'; // ===== Ximalaya Information Extractor ===== // Create copy button function createCopyButton() { // Only create button on Ximalaya pages if (!window.location.hostname.includes('ximalaya.com')) return; const button = document.createElement('button'); button.textContent = '复制信息'; button.style.position = 'fixed'; button.style.top = '20px'; button.style.right = '20px'; button.style.zIndex = '9999'; button.style.padding = '10px'; button.style.backgroundColor = '#fc5832'; button.style.color = 'white'; button.style.border = 'none'; button.style.borderRadius = '5px'; button.style.cursor = 'pointer'; button.addEventListener('click', extractAndCopyInfo); document.body.appendChild(button); } // Process text content function processText(text) { if (!text) return ''; // Split into sections and process each const sections = text.split('\n\n'); const processedSections = []; let skipSection = false; for (let i = 0; i < sections.length; i++) { const section = sections[i].trim(); // Skip empty sections if (!section) continue; // Skip purchase information section if (section.includes('购买须知') || section.includes('本作品为付费有声书') || section.includes('版权归原作者所有') || section.includes('如在充值/购买环节遇到问题') || section.includes('在购买过程中')) { skipSection = true; continue; } // Reset skip flag when reaching a new major section if (section === 'staff' || section === 'cast' || section.includes('内容简介')) { skipSection = false; } // Skip sections if flag is true if (skipSection) continue; // Special formatting for sections if (section.includes('【冒泡有奖】')) { processedSections.push(`[quote][color=#FF6B6B]${section}[/color][/quote]`); } else if (section.startsWith('版权方:') || section.startsWith('作 者:') || section.startsWith('策 划:') || section.startsWith('画 本:')) { processedSections.push(`[*]${section}`); } else if (section.startsWith('男:') || section.startsWith('女:')) { // Keep cast information in a more compact format const lines = section.split('\n').filter(line => line.trim()); processedSections.push(lines.join('\n')); } else { processedSections.push(section); } } // Join sections with single newline return processedSections.join('\n'); } // Extract and format information function extractAndCopyInfo() { // Get current page URL const currentUrl = window.location.href; // Get main image const mainImage = document.querySelector('.img.z_i'); const mainImageUrl = mainImage ? mainImage.src : ''; // Get display image from article const articleImage = document.querySelector('article.intro img'); const displayImageUrl = articleImage ? articleImage.src : ''; // Get title const title = document.querySelector('h1.title.z_i'); const titleText = title ? title.textContent.trim() : ''; // Get introduction content const article = document.querySelector('article.intro'); let introText = ''; if (article) { const paragraphs = article.querySelectorAll('p'); introText = Array.from(paragraphs) .map(p => p.textContent.trim()) .filter(text => text) .join('\n\n'); } // Format the output const formattedText = `[center][size=6][color=#FC5832][b]${titleText}[/b][/color][/size][/center] [center][size=5][color=#2C3E50][b]━━━━━ 封面展示 ━━━━━[/b][/color][/size][/center] [center][img]${mainImageUrl}[/img][/center] [center][size=5][color=#2C3E50][b]━━━━━ 详情介绍 ━━━━━[/b][/color][/size][/center] [center][img]${displayImageUrl}[/img][/center] [quote][size=4][color=#2C3E50][b]内容简介[/b][/color][/size] ${processText(introText)}[/quote] [size=4][color=#2C3E50][b]资源信息[/b][/color][/size] [quote][color=#666666]原网址:[url=${currentUrl}]${currentUrl}[/url][/color][/quote] [center][size=3][color=#999999]━━━━━ CRABPT ━━━━━[/color][/size][/center]`; // Copy to clipboard navigator.clipboard.writeText(formattedText).then(() => { alert('信息已复制到剪贴板!'); }).catch(err => { console.error('复制失败:', err); alert('复制失败,请手动复制'); }); } // ===== Auto Selector ===== // 目标配置 const TARGETS = [ { selector: 'select[name="team_sel[6]"]', targetValue: "", // 红叶的实际value值需补充 targetText: "红叶", eventName: "change" }, { selector: 'select[name="type"][id="specialcat"]', targetValue: "411", targetText: "有声书 / Audiobook", eventName: "change", customHandler: "disableother('specialcat','browsecat')" } ]; function autoSelect(target) { const el = document.querySelector(target.selector); if (!el) return false; const option = Array.from(el.options).find(opt => (target.targetValue && opt.value === target.targetValue) || opt.text.includes(target.targetText) ); if (option) { el.value = option.value; const event = new Event(target.eventName, { bubbles: true, cancelable: true }); el.dispatchEvent(event); if (target.customHandler) { new Function(target.customHandler)(); } return true; } return false; } function executeSelections() { TARGETS.forEach(target => { const success = autoSelect(target); console.log(`${target.targetText}: ${success ? '成功' : '失败'}`); }); } // 增强型初始化 const observer = new MutationObserver(mutations => { if (TARGETS.some(t => document.querySelector(t.selector))) { executeSelections(); } }); function init() { // Initialize both features createCopyButton(); observer.observe(document.body, { childList: true, subtree: true }); if (document.readyState === 'complete') { setTimeout(executeSelections, 800); } } // Initialize window.addEventListener('DOMContentLoaded', init); window.addEventListener('load', init); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址