您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to take over the world!
当前为
// ==UserScript== // @name pixivnovel // @namespace http://tampermonkey.net/ // @version 1.50 // @description try to take over the world! // @author You // @match https://www.pixiv.net/novel/show.php?id=* // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js // @require https://cdn.jsdelivr.net/npm/[email protected]/FileSaver.min.js // @grant GM_xmlhttpRequest // ==/UserScript== (function() { "use strict"; let textlist = []; let pagecount = 1; let lurl = location.href; let title; const s = location.href.indexOf("#"); if (s > 0) { lurl = location.href.substring(0, s); } function pageone(doc) { title = doc.find(".sc-LzMjg").text(); const title0 = doc.find(".sc-LzMjG.iwvplz").text(); if (!title) title = title0; const wordcount = doc.find(".sc-LzMkp.jDjWlD").text(); const Introduction = doc.find(".sc-LzMjI.jkOmgw").text(); const updatetime = doc.find(".sc-LzMjf.diKqPA").text(); textlist.push(title); textlist.push(title0); textlist.push(wordcount); textlist.push(Introduction); textlist.push(updatetime); console.log(textlist); } async function Analysis() { const url = lurl + "#" + pagecount; console.log("url", url); let str = await gethtml(url); str = str.document.body.innerHTML; const str2 = str.replace(/<br>/g, "\r\n"); let doc = $("<html></html>"); doc.html(str2); //let doc = $(str); if (!title) { pageone(doc); } // const text = doc.find(".sc-LzMYn").text(); doc .find(".sc-LzMYn") .find(".csHEBi") .each((i, v) => { textlist.push($(v).text()); }); doc.find(".sc-LzMXa.laextB").each((i, v) => { textlist.push($(v).text()); }); pagecount++; const button = doc.find(":button.gtm-novel-work-footer-pager-next"); if (button.length > 0) { console.log(button); Analysis(); } else { console.log("END"); if (textlist.length > 0) { console.log(textlist); var blob = new Blob([textlist.join("\r\n\r\n")], { type: "text/plain;charset=utf-8" }); saveAs(blob, `${title}.txt`); $("#CWDownSave").css("background-color", "red"); } else { alert(" NO DOWNLOAD"); } } } async function gethtml(url) { return new Promise((resolve, reject) => { const iframeId = "iframeId" + pagecount; var ele1 = document.createElement("iframe"); ele1.src = url; ele1.name = iframeId; ele1.id = iframeId; ele1.width = "195px"; ele1.height = "126px"; ele1.style.display = "none"; ele1.onload = function() { var frame = this; resolve( new Promise((resolve2, reject2) => { function loopcheck() { if (frame) { console.log("loop1"); const e1 = frame.contentWindow.document.querySelector( ".sc-LzMYn.csHEBi" ); const e2 = frame.contentWindow.document.querySelector( ".sc-LzMXa.laextB" ); console.log(e1) console.log(e2) if (e1 || e2) { clearInterval(akoop); resolve2(frame.contentWindow); } } } const akoop = setInterval(function() { loopcheck(); }, 1000); }) ); }; document.body.appendChild(ele1); }); } function inits() { var content = document.createElement("div"); document.body.appendChild(content); content.outerHTML = ` <div id="CWDownContent"> <div style="width:40px;height:25px;position:fixed;left:3PX;top:3PX;z-index:100000;/*! background-color:#ffffff; *//*! border:1px solid #afb3b6; *//*! opacity:0.95; */filter:alpha(opacity=95);"> <div id="CWDownSave" style="/*! width:43px; *//*! height:26px; */cursor: pointer;background-color:#3169da;/*! margin: 2px 5px 3px 10px; */"> <span style="/*! line-height:25px; */display:block;color:#FFF;text-align:center;font-size: 14px;">pixiv novel</span> </div> </div> </div> `; var WCSave = document.querySelector("#CWDownSave"); WCSave.onclick = Analysis; Analysis(); } inits(); // Your code here... })();