您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
下载魔蝎小说资源
// ==UserScript== // @name 获取魔蝎小说资源 // @namespace http://tampermonkey.net/ // @version 2024-03-28 // @description 下载魔蝎小说资源 // @author mw // @match http://www.moxiexs.com/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js // @grant GM_addStyle // @license MIT // ==/UserScript== (function () { $(document).ready(function () { GM_addStyle(` ::selection { background: #ff9900; /* 选中背景色 */ color: white; /* 选中文字颜色 */ text-shadow: none; /* 移除默认的文本阴影 */ } .start-fetch { position: fixed; bottom: 28%; right: 0; padding: 10px 20px; background-color: #fff; color: #000; border-radius: 10px; cursor: pointer; z-index: 1000; font-size: 28px; } .hqxscontbox{ position: fixed; top: 0; left: 0; bottom: 0; right: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, .7); z-index: 10000; pointer-events: all; display: none; -webkit-user-select: all; } .hqxscont { position: absolute; top: 50%; left: 50%; width: 75%; height: 80%; overflow: auto; transform: translate(-50%,-50%); background-color: #fff; color: #000; border-radius: 5px; padding: 10px; font-size: 12px; } .copyButton123{ position: absolute; bottom: 8%; left: 50%; width: 75%; background-color: #000; color: #fff; transform: translate(-50%, 0); border-radius: 0; cursor: pointer; font-size: 28px; text-align: center; z-index: 10001; display: none; } `); init(); }); function init() { $('body').append('<div class="start-fetch">下载文本</div><div class="copyButton123">下载文本</div><div class="hqxscontbox"><div class="hqxscont"><div> </div>'); console.log('初始化完成执行 init'); $('.start-fetch').click(function () { $(this).hide() $('html,body').css({ 'overflow':'hidden;' }) content() }); function copyButton() { // 获取HTML内容的innerHTML var htmlString = $('.hqxscont').html(); // 将HTML转换为纯文本 var plainText = htmlToText(htmlString); var blob = new Blob([plainText], { type: "text/plain;charset=utf-8" }); var url = URL.createObjectURL(blob); var a = document.createElement("a"); a.href = url; let tit = extractTitle() a.download = tit + ".txt"; a.click(); window.URL.revokeObjectURL(url); $('.bottem2 a').eq(3)[0].click(); } $('.copyButton123').click(function () { copyButton() }); function extractTitle() { let tit = $('.bookname>h1').text() // 如果没有匹配,返回null return tit; } function htmlToText(html) { // 使用正则表达式替换 <br> 标签为换行符 let text = html.replace(/<br\s*\/?>/gi, '\n'); // 使用正则表达式替换 实体为空格 text = text.replace(/ /gi, ' '); // 去除其他 HTML 标签(可选,如果需要) text = text.replace(/<[^>]*>/g, ''); return text; } function content() { $('.hqxscontbox').show(); let cont = ' '+ extractTitle()+ '<br/><br/><br/>' + $('#content').html() $('.hqxscont').html(cont); $('.copyButton123').show() copyButton() } } // Your code here... })();