您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to take over the world!
当前为
// ==UserScript== // @name 轻小说文库下载 // @namespace http://tampermonkey.net/ // @version 0.2 // @description try to take over the world! // @author You // @match https://www.wenku8.net/* // @match http://www.wenku8.net/* // @connect dl.wenku8.com // @require http://code.jquery.com/jquery-3.5.1.min.js // @grant GM_xmlhttpRequest // ==/UserScript== (function() { 'use strict'; //替换所有 String.prototype.replaceAll= function(exp,newStr){ return this.replace(new RegExp(exp,"gm"),newStr); }; //标记含有html代码的行 var htmlLine = function(txt){ return 'c1ef6520'+ txt +'1a5219e9b2b0'; }; //格式化内容 var contentFormat = function(txt){ //设置章节名样式 txt = txt.replaceAll(/^ {2}\S+.*$/,function(match){ return htmlLine('<br/><div style="background:#e4e1d8" id="title">'+ match.trim() +'</div>'); }); txt = $('<div></div>').text(txt).html(); txt = txt.replaceAll(/ /,' '); txt = txt.replaceAll(/(c1ef6520).*(1a5219e9b2b0)/,function(match){ return $('<div></div>').html(match.replaceAll(/( )/,' ').replace('c1ef6520','').replace('1a5219e9b2b0','')).text(); }); txt = txt.replaceAll(/[\r\n]+/,'<br/>'); return txt; }; //目录页面或内容会声明章节变量。 if('undefined' == typeof chapter_id || undefined===chapter_id) return; //本书编号 article_id //目录页面章节id定义为 '0' if('0' == chapter_id)//在章节名之后添加下载链接 { //书名 var aname = $('#title').text(); //添加全本下载链接 var allDLink = 'http://dl.wenku8.com/down.php?type=utf8&id='+article_id+'&fname='+aname; var allaEle = '<a href="'+allDLink+'"> 全本下载(utf-8)</a>'; $('#title').append(allaEle); $('.vcss').each( function(){ var jqthis = $(this); var vname = jqthis.text(); var nextChapter = jqthis.parent().next().children().first(); var vid = $('a',nextChapter).attr('href').split('.')[0]; //vid = (Number(vid)-1).toString();//部分文章无法使用章节减1来下载,直接使用章节可以下载(下载内容使用-1时章节名包含小说名,不-1不包含小说名) var dlink = 'http://dl.wenku8.com/packtxt.php?aid='+article_id+ '&vid='+vid+'&aname='+aname+'&vname='+vname+'&charset=utf-8'; var aEle = '<a href="'+dlink+'"> 下载(utf-8)</a>' jqthis.append(aEle); } ); return; } if('0' != chapter_id) //内容页面 { if($('#contentmain span').first().text().trim() == 'null')//如果包含一个内容为 'null'的span则判定为版权限制 { //设置下一页和上一页快捷键到目录页 preview_page = next_page = index_page; $('#content').text('正在下载,请稍候...'); var dlink = 'http://dl.wenku8.com/packtxt.php?aid='+article_id+ '&vid='+chapter_id; GM_xmlhttpRequest({ method :'GET', url :dlink, onload :function(response){ if(response.statusText == "OK"){ var formatTxt = contentFormat(response.responseText); $('#content').html(formatTxt); //$('#content').text(response.responseText); }else{ $('#content').text('下载失败'); } }, }); } } // Your code here... })();