- // ==UserScript==
- // @name 番茄小说阅读辅助器
- // @namespace http://tampermonkey.net/
- // @version 2.16
- // @description 可以下载番茄小说内容,记录阅读位置(滚动位置),可以自动滚动,快捷书签,好用!
- // @author twjx
- // @match *://fanqienovel.com/*
- // @require https://cdn.jsdelivr.net/npm/lil-gui@0.16
- // @require https://update.greasyfork.org/scripts/522780/1518758/dialog-gui.js
- // @require https://update.greasyfork.org/scripts/521360/1514728/unicode1.js
- // @license GNU AGPLv3
- // @resource swalStyle https://unpkg.com/sweetalert2@10.16.6/dist/sweetalert2.min.css
- // @icon data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE4Ljg3MjcgMEg1LjEyNzI3QzIuMjkwOTEgMCAwIDIuMjkwOTEgMCA1LjEyNzI3VjE4Ljg3MjdDMCAyMS43MDkxIDIuMjkwOTEgMjQgNS4xMjcyNyAyNEgxOC44NzI3QzIxLjcwOTEgMjQgMjQgMjEuNzA5MSAyNCAxOC44NzI3VjUuMTI3MjdDMjQgMi4yOTA5MSAyMS43MDkxIDAgMTguODcyNyAwWiIgZmlsbD0id2hpdGUiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjEyNzI3IDBIMTguODcyN0MyMS43MDkxIDAgMjQgMi4yOTA5MSAyNCA1LjEyNzI3VjE4Ljg3MjdDMjQgMjEuNzA5MSAyMS43MDkxIDI0IDE4Ljg3MjcgMjRINS4xMjcyN0MyLjI5MDkxIDI0IDAgMjEuNzA5MSAwIDE4Ljg3MjdWNS4xMjcyN0MwIDIuMjkwOTEgMi4yOTA5MSAwIDUuMTI3MjcgMFpNMjMuNDc1NyA1LjEyNzI3QzIzLjQ3NTcgMi41OTYzNiAy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4xNDIgNi40NTkyNyAxNS42ODc0IDcuMTEzODIgMTYuMzIwMUM3Ljc2ODM2IDE2Ljk1MjkgOS4wNTU2NCAxNy4xNDkyIDkuMDU1NjQgMTcuMTQ5MloiIGZpbGw9IndoaXRlIi8+CjxkZWZzPgo8cmFkaWFsR3JhZGllbnQgaWQ9InBhaW50MF9yYWRpYWxfNjA3XzEyNTA1IiBjeD0iMCIgY3k9IjAiIHI9IjEiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBncmFkaWVudFRyYW5zZm9ybT0idHJhbnNsYXRlKDEyLjA5ODkgMjQuMjEyKSBzY2FsZSgxNC41OTg0IDkuMzgyNzcpIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0NDMDUwMCIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNGRjVGMDAiLz4KPC9yYWRpYWxHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K
- // @grant none
- // ==/UserScript==
-
- (function() {
- 'use strict';
- window.data=''
- window.num=0
- window.alldata=[]
- window.onstop=false
- window.movep=[]
- window.img=[]
- window.thedata
- window.unicode_data()
- window.sleep=async function(ms){
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- window.downloader={
- xml:function(type, src,idata,num,num1,aa) {
- const xhr = new XMLHttpRequest();
- xhr.open(type, src);
- xhr.overrideMimeType('text/plain; charset=utf-8');
- xhr.onload = function () {
- if (xhr.status === 200) {
- const responseText = xhr.responseText;
- let content = responseText.split('content noselect"><div>')[1]
- .split('</div><p></p>')[0]
- .replaceAll('<p>', '')
- .replaceAll('</p>', '\n');
- var decoded = downloader.decode(content);
- var text=downloader.find_img(decoded)
- if(text!==false){
- var f=decoded.split('<div data-fanqie-type="image" ')
- var textd=''
- for(let x of f){
- if(x.startsWith('source')){
- textd+='\n此处有一张图片已去除,请于下载配套中查看\n名称:'+x.split('1">')[2].split('\n')[0]+'\n'+x.split('</div>')[1]
- }else textd+=x
- }
- for(let x=0;x<text.length;x++){
- img.push({
- chapter:responseText.split('<title>')[1].split('在线免费阅读_番茄小说官网<')[0].split(' ')[0].split('第')[1].replace('章',''),
- chapter1:num1,
- chapter2:num,
- name:responseText.split('<title>')[1].split('在线免费阅读_番茄小说官网<')[0].split(' ')[1],
- src:text[x][1],
- title:text[x][0],
- })
- }
- decoded=textd
- }
- idata.data.push({
- chapter:responseText.split('<title>')[1].split('在线免费阅读_番茄小说官网<')[0].split(' ')[0].split('第')[1].replace('章',''),
- chapter1:num1,
- chapter2:num,
- name:responseText.split('<title>')[1].split('在线免费阅读_番茄小说官网<')[0].split(' ')[1],
- data:decoded,
- })
- if(decoded==undefined){onstop=true;window.d={a:responseText,b:decoded,c:text,d:textd}}
- console.log(aa+' 机改1:'+num1+' 机改2:'+num+'下载完成')
- }
- };
- xhr.send();
- },
- decode:function(content) {
- var newdata = '';
- for (let x of content) {
- if (String(x).charCodeAt(0) in unicode_data == true) {
- newdata += unicode_data[String(x).charCodeAt(0)];
- } else {
- newdata += String(x);
- }
- }
- return newdata;
- },
- dispose:async function(children,type){
- if(onstop==true)return;
- var jdata=children.children[0].innerHTML.split('<span class="volume-dot"></span>')
- var num=1
- alldata.push({
- name:jdata[0],
- volume:jdata[0],
- allchapter:jdata[1],
- data:[]})
- console.log('卷创建完毕')
- for(let x of children.children[1].children){
- if(onstop==true)return;
- this.xml('GET',x.children[0].href,alldata[alldata.length-1],num,num1,x.innerText.split(' ')[0])
- num+=1
- num1+=1
- await sleep(Number(document.querySelectorAll('.widget')[2].children[0].value))//50毫秒一下最好不要,卡爆
- }
- },
- find_img:function(text){
- if(text.includes('<div data-fanqie-type="image" ')){
- var returntext=[]
- var texta=text.split('<div data-fanqie-type="image" ')
- for(let x of texta){
- if(x.startsWith('source="')){
- var textb=x.split('Desc" group')
- returntext[texta.indexOf(x)-1]=[textb[1].split('\n')[0].split('>')[1],textb[0].split('<img src="')[1].split('" width="')[0]]
- }
- }
- return returntext
- }else return false
- },
- download:function(name, text,type) {
- var dld = document.createElement('a');
- dld.setAttribute('href', 'data:text/plain;charset=utf-8,'+encodeURIComponent(text));
-
- dld.setAttribute('download', name);
- dld.click();
- },
- downloadd:async function(type){
- data=''
- console.log('正在排序...')
- window.d=0
- for(let x=0;x<alldata.length;x++){
- data+=alldata[x].name+' '+alldata[x].allchapter+'\n'
- for(let x1=0;x1<alldata[x].data.length;x1++){
- d+=1
- for(let x2 of alldata[x].data){
- if(x2.chapter1==d){
- data+='第'+[x2.chapter,x2.chapter1,x2.chapter2][type]+'章 '+x2.name+'\n'+x2.data
- }
- }
- }
- }
- this.download(window.__INITIAL_STATE__.page.bookName,window.__INITIAL_STATE__.page.bookName+"\n此文件由番茄小说阅读辅助器下载https://greasyfork.org/zh-CN/scripts/521377-番茄小说阅读辅助器\n请支持正版番茄小说\n作者:"+window.__INITIAL_STATE__.page.author+'\n'+data,'text')
- alert('下载完成')
- /*var imgtext=''
- for(let x of img){
- imgtext+='图片名称'+x.title+' 来自章节 第'+[x.chapter,x.chapter1,x.chapter2][type]+'章 '+x.name+'\n'
- this.download(x.title,x.src,'img')
- }*/
- await sleep(100)
- //this.download(window.__INITIAL_STATE__.page.bookName,window.__INITIAL_STATE__.page.bookName+' 图片来源',imgtext,'text')
- gui.domElement.children[1].children[0].children[1].children[2].remove()
- await sleep(1000)
- data=''
- alldata=[]
- },
- loadrecord:function(){
- document.querySelectorAll('.chapter-item').forEach((x)=>{
- var recorddata=thedata.read.read_record.filter(e=>e.chapterid==x.children[0].href.split('/')[4])
- if(recorddata.length==1){
- x.innerHTML+='<span class="tooltip">已看'+Math.round(((recorddata[0].scrolltop+window.innerHeight)/recorddata[0].scrollHeight)*100)+'%</span>'
- }else{
- x.innerHTML+='<span class="tooltip">未看</span>'
- }
- })
- console.log('tips is loaded')
- },
- addstyle:function(){
- document.querySelector('.page').innerHTML+=`<style>
- .tooltip {
- visibility: hidden; /* 初始状态下隐藏工具提示 */
- background-color: #555;
- color: #fff;
- text-align: center;
- border-radius: 5px;
- padding: 5px 10px;
- position: absolute; /* 使用绝对定位 */
- z-index: 1; /* 确保工具提示显示在其他元素之上 */
- bottom: 125%; /* 工具提示显示在按钮上方 */
- left: 25%;
- transform: translateX(-50%);
- opacity: 0; /* 初始状态下透明度为0 */
- transition: opacity 0.3s; /* 添加过渡效果 */
- }
- .chapter-item:hover .tooltip {
- visibility: visible; /* 鼠标悬停时显示工具提示 */
- opacity: 1; /* 鼠标悬停时设置透明度为1 */
- }
- </style>`
-
- },
- }
- function move(){//移动模块
- var guid=gui.domElement
- gui.domElement.children[0].onmousedown=function(e) {
- if(guid.style.left==''){
- movep=[e.clientX-(window.innerWidth-275),e.clientY-0]//首次移动
- }else{
- movep=[e.clientX-Number(guid.style.left.replace('px','')),e.clientY-Number(guid.style.top.replace('px',''))]
- }
- window.onmove=true
- }
- document.onmouseup=function(e) {
- movep=[]
- window.onmove=false
- if(Number(guid.style.left.replace('px',''))<0)guid.style.left='0px';
- if(Number(guid.style.top.replace('px',''))<0)guid.style.top='0px';
- if(Number(gui.domElement.style.left.replace('px',''))+260>=windowWidth){
- gui.domElement.style.left=(windowWidth-260)+'px'
- }
- }
- document.onmousemove=function(e){
- if(window.onmove==true){
- guid.style.top=e.clientY-movep[1]+'px';
- guid.style.left=e.clientX-movep[0]+'px'
- }
- }
- guid.onmouseover=function(){
- if(!guid.children[0].innerText.includes('右'))guid.children[0].innerText+=' (右键可移动)';
- }
- guid.onmouseout=function(){
- guid.children[0].innerText='番茄阅读辅助器'
- }
- }
- window.reader={
- record:async function(){//记录阅读位置
- window.time=String(new Date).split(' ')
- var datax=thedata.read.read_record.filter(e=>e.chapterid==location.pathname.split('/')[2])
- if(datax.length==1){
- //回忆了以前的知识
- if(thescroll.scrollTop==0){await sleep(500)}
- Object.assign(thedata.read.read_record.filter(e=>e.chapterid==location.pathname.split('/')[2])[0],{
- date:{
- year:time[3],
- month:time[2],
- time:time[4],
- area:time[6],
- },
- chapterName:document.querySelector('.muye-reader-title').innerText,
- chapterid:location.pathname.split('/')[2],
- scrolltop:thescroll.scrollTop,
- scrollHeight:thescroll.scrollHeight,
- })
- }else if(datax.length==0){
- thedata.read.read_record.push({
- date:{
- year:time[3],
- month:time[2],
- time:time[4],
- area:time[6],
- },
- bookName:document.querySelector('.muye-reader-nav-title').innerText,
- chapterName:document.querySelector('.muye-reader-title').innerText,
- chapterid:location.pathname.split('/')[2],
- scrolltop:thescroll.scrollTop,
- scrollHeight:thescroll.scrollHeight,
- })
- }
- },
- onload:function(){//加载阅读位置
- if(thedata.read.read_record.filter(e=>e.chapterid==location.pathname.split('/')[2]).length==1){
- thescroll.scrollTop=thedata.read.read_record.filter(e=>e.chapterid==location.pathname.split('/')[2])[0].scrolltop
- console.log('记录加载')
- }
- },
- loadrecord:function(){//加载目录记录
- for(let x of document.querySelector('.reader-catalog-chapters').children){
- for(let xx of x.children){
- if(xx.className!=='volume-header'){
- var xxx=thedata.read.read_record.filter(e=>e.chapterid==xx.children[0].attributes[0].value)
- if(xxx.length==1){
- xx.children[0].innerHTML+='<p> 已看'+Math.round(((xxx[0].scrolltop+thescroll.clientHeight)/xxx[0].scrollHeight)*100)+'%</p>'
- }}
- }
- }
- console.log('目录记录加载')
- },
- scroll:{
- load:function(theparent){
- this.scrollInterval;
- this.scrollStatus = theparent.add({ status: '已停止' }, 'status').name('滚动状态');
- this.scrollStatus.domElement.style.color = 'red';
- this.scrollSpeed = theparent.add({ speed: 1 }, 'speed').name('滚动速度');
- this.scrollSpeed.setValue(thedata.read.scroll_speed)
- this.scrollSpeedsave = theparent.add({ speedsave: false }, 'speedsave').name('保存速度').onChange(function(value) {
- if (value==true) {
- thedata.read.scroll_speed=reader.scroll.scrollSpeed.getValue()
- console.log('保存速度:'+thedata.read.scroll_speed)
- fqxsydqdata.savedata()
- }
- });
- this.stopButton = theparent.add(this, 'start').name('开始自动滚动');
- },
- autoScroll:function() {
- if (thescroll.scrollTop >= thescroll.scrollHeight - thescroll.clientHeight) {
- console.log('滚动以至底部')
- window.reader.scroll.stopAutoScroll();
- }else{
- thescroll.scrollTop += Math.round(reader.scroll.scrollSpeed.getValue())
- }
- },
- startAutoScroll:function() {
- this.scrollInterval = setInterval(this.autoScroll, 200);
- this.scrollStatus.setValue('进行中');
- this.stopButton.name('停止自动滚动');
- this.scrollStatus.domElement.style.color = 'green';
- },
- stopAutoScroll:function() {
- clearInterval(this.scrollInterval);
- this.scrollStatus.setValue('已停止');
- this.stopButton.name('开始自动滚动');
- this.scrollStatus.domElement.style.color = 'red';
- },
- "start":()=>{
- var x=reader.scroll
- if(x.scrollStatus.getValue()=='已停止'){
- if(String(Number(x.scrollSpeed.getValue()))=='NaN'){
- alert('滚动速度输入非数字')
- return
- }
- if(x.scrollSpeed.getValue()>=1000){
- alert('滚动速度输入过大\n如有需要请在脚本后台修改上限\n如有错误作者概不负责')
- return
- }
- console.log('滚动速度:'+Math.round(x.scrollSpeed.getValue()))
- x.startAutoScroll();
- }else{
- x.stopAutoScroll();
- }
- }
- },
- keyboard:function(value){
- value.addEventListener("keydown", async function (e) {
- if(reader.mark.onchoose==true){
- await sleep(200)
- page1_2_2.children[1].domElement.children[1].children[0].value=e.key+'键'
- }
- });
- document.addEventListener("keyup", function (e) {
- delete reader.mark.keydown[e.key]
- if(reader.mark.onaddmark[2]==e.key){
- message('停止添加')
- reader.mark.onaddmark=[0,false,''];
- }
- })
- document.addEventListener("keydown", function (e) {
- if(reader.mark.ontransmission[0]==true && e.key!==reader.mark.ontransmission[1]){
- message('停止传送','',true)
- reader.mark.ontransmission=[false,'']
- }
- reader.mark.keydown[e.key]=true
- if('d' in reader.mark.keydown && Object.keys(reader.mark.keydown).filter(e=>String(Number(e))!=='NaN').length==1 && reader.mark.ondelmark[1]==false){
- message('请你持续按住'+e.key+'键 3秒 删除书签'+Object.keys(reader.mark.keydown).filter(e=>String(Number(e))!=='NaN')[0],'1')
- if(reader.mark.onaddmark[1]==true){
- message('你已经在进行删除书签的操作,为防止出错已暂停所有进程','1',true)
- reader.mark.onaddmark=[0,false,''];
- return
- }
- reader.mark.ondelmark=[0,true,Object.keys(reader.mark.keydown).filter(e=>String(Number(e))!=='NaN')[0]]
- var timer1=setInterval(()=>{
- if(reader.mark.ondelmark[1]==false){
- clearInterval(timer)
- }
- reader.mark.ondelmark[0]+=0.1
- if(reader.mark.ondelmark[0]>=3){
- clearInterval(timer1)
- Object.assign(thedata.read.bookmark['data'+reader.mark.ondelmark[2]],{
- bookName:'',
- bookid:'',
- chapterName:'',
- chapterid:'',
- scrolltop:0,
- time:{
- date:'',
- },
- })
- fqxsydqdata.savedata()
- message('书签'+reader.mark.ondelmark[2]+'删除成功','1',true)
- setTimeout(()=>{reader.mark.ondelmark=[0,false,'']},2000)
- }
- },100)
- }else if(String(Number(e.key))!=='NaN' && Object.values(thedata.read.bookmark['data'+e.key]).filter(e=>e=='').length==5 && reader.mark.onaddmark[2]!==e.key && reader.mark.ondelmark[1]==false){
- if(reader.mark.onaddmark[1]==true){
- message('你已经在进行添加书签的操作,为防止出错已暂停所有进程','1',true)
- reader.mark.onaddmark=[0,false,''];
- return
- }
- message('请你持续按住'+e.key+'键 3秒 添加书签'+e.key,'1')
- reader.mark.onaddmark=[0,true,e.key]
- var timer=setInterval(()=>{
- if(reader.mark.onaddmark[1]==false){
- clearInterval(timer)
- }
- reader.mark.onaddmark[0]+=0.1
- if(reader.mark.onaddmark[0]>=3){
- clearInterval(timer)
- thedata.read.bookmark['data'+reader.mark.onaddmark[2]]={
- bookName:window.__INITIAL_STATE__.reader.chapterData.bookName,
- bookid:window.__INITIAL_STATE__.reader.chapterData.bookId,
- chapterName:window.__INITIAL_STATE__.reader.chapterData.title,
- chapterid:location.pathname.split('/')[2],
- scrolltop:thescroll.scrollTop,
- time:{
- date:String(new Date),
- },
- }
- fqxsydqdata.savedata()
- message('书签'+reader.mark.onaddmark[2]+'添加成功','1',true)
- setTimeout(()=>{reader.mark.onaddmark=[0,false,'']},2000)
- }
- },100)
- }else if(String(Number(e.key))!=='NaN' && Object.values(thedata.read.bookmark['data'+e.key]).filter(e=>e==='').length==0 && Object.values(reader.mark.keydown).length==1 && reader.mark.onaddmark[1]==false && reader.mark.ondelmark[1]==false){
- message('开始传送至书签'+e.key+' 3秒内按其他键取消传送')
- reader.mark.ontransmission=[true,e.key]
- setTimeout(()=>{
- if(reader.mark.ontransmission[0]==true){
- reader.record()
- window.location.pathname='/reader/'+thedata.read.bookmark['data'+reader.mark.ontransmission[1]].chapterid
- }
- },3000)
- }
- });
- },
- mark:{
- onaddmark:[0,false,''],
- ondelmark:[0,false,''],
- onchoose:false,
- ontransmission:[false,''],
- keydown:{},
- },
- bookmark:function(theparent){
- var page1_2_1 = theparent.addFolder('书签').close()
- page1_2_1.add({ del:()=>{
- message('已清除本书所有书签','',true)
- fqxsydqdata.update('bookmark')
- fqxsydqdata.savedata()
- }}, 'del').name('删除书签')
- window. page1_2_2 = theparent.addFolder('快捷键').close()
- page1_2_2.add({ addbookmark: '数字键1-9(暂不支持更改)' }, 'addbookmark').name('增加书签').onFinishChange((value)=>{
- page1_2_2.children[0].$input.value='数字键1-9(暂不支持更改)'
- })
- page1_2_2.add({ delbookmark: '键'+thedata.read.shortcut_key.changemark+'+对应的数字键1-9' }, 'delbookmark').name('删除书签');
- var input=page1_2_2.children[1].$input
- this.keyboard(input)
- input.onfocus=function(x){
- input.value=''
- reader.mark.onchoose=true;
- }
- input.onblur=function(x){
- if(input.value!==''){
- thedata.read.shortcut_key.changemark=input.value.replace('键','')
- fqxsydqdata.savedata()
- }
- reader.mark.onchoose=false;
- }
- },
- }
- window.fqxsydqdata={
- getdata:function(){
- if(!localStorage.fqxsydq){
- window.thedata={
- name:'番茄阅读辅助器',
- version:'1.540',
- read:{
- read_record:[],
- last_read:{},
- scroll_speed:1,
- shortcut_key:{
- changemark:'d',
- },
- bookmark:{
-
- },
- },
- download:{
- },
- }
- this.update('bookmark')
- localStorage.fqxsydq=JSON.stringify(thedata)
- }else{
- window.thedata=JSON.parse(localStorage.fqxsydq)
- if(!thedata.read.bookmark){
- window.thedata={
- name:'番茄阅读辅助器',
- version:'2.00',
- read:{
- read_record:thedata.read.read_record,
- last_read:{},
- scroll_speed:thedata.read.scroll_speed,
- shortcut_key:{
- changemark:'d',
- },
- bookmark:{
-
- },
- },
- download:{
- },
- }
- this.update('bookmark')
- alert('原版本数据格式低,已更新,原数据未删改')
- }
- }
- },
- savedata:function(){
- localStorage.fqxsydq=JSON.stringify(thedata)
- },
- update:function(type){
- if(type=='bookmark'){//更新书签格式 1.531及版本之前的格式
- console.log('bookmark已更新/重置')
- thedata.read.bookmark={
- data1:{
- bookName:'',
- bookid:'',
- chapterName:'',
- chapterid:'',
- scrolltop:0,
- time:{
- date:'',
- },
- },
- data2:{},data3:{},data4:{},data5:{},data6:{},data7:{},data8:{},data9:{},
- }
- var bookmark1=new Map()//建obj
- for(let x=2;x<10;x++){
- bookmark1.set('data'+x,thedata.read.bookmark.data1)
- }
- Object.assign(thedata.read.bookmark,Object.fromEntries(bookmark1))
- }
- }
- }
- window.q=function(){
- alert('原版:下载原版章节\n机翻1:下载机翻1章节\n机翻2:下载机翻2章节\n机翻1效果如下\n第一卷\n第1章\n第2章\n......\n第二卷\n第100章...\n机翻2\n第一卷\n第1章\n第2章\n......\n第二卷\n第1章')
- }
- window.message=function(text,str,onclose,parent){
- if(document.querySelector('.dialog'))document.querySelector('.dialog').remove();
- var ele= dialog.create({
- type: "single",
- title: "",
- dark_screen: false,
- enMove: false,
- attribute: {
- position:'relative',
- height:'0px',
- top:'',
- },
- content: [
- {
- type: "text",
- returnElement: str,
- content: {
- type: 'h2',
- content: text,
- },
- style:{
-
- },
- },
- ]
- },document.querySelector('.muye-reader') ? document.querySelector('.muye-reader'):document.querySelector('.page'));
- if(location.href.includes('/reader/')){
- dialog.dialog.style.top=(-thescroll.clientWidth/2+thescroll.scrollTop)+'px'
- }else{
- dialog.dialog.style.top=(-(document.querySelector('.page').scrollHeight-document.querySelector('.page').scrollTop)+innerHeight/2+30)+'px'
- }
- if(onclose==true){
- setTimeout(()=>{document.querySelector('.dialog').remove()},3000)
- }
- return ele
- }
- window.main = {
- "copybook" : async()=>{
- data=''
- img=[]
- if(Number(document.querySelectorAll('.widget')[2].children[0].value)<60){
- var b=confirm('小于60毫秒作者建议请一下后台\n开的时候玩手机就行了\n作者亲测50毫秒间隔下载也不会出错')
- if(!b==true)return;
- }
- console.log('下载模式:'+document.querySelectorAll('.widget')[1].children[0].value)
- var type=['原版','机改1','机改2'].indexOf(document.querySelectorAll('.widget')[1].children[0].value)
- page1.add(main,'stop').name('暂停下载')
- document.querySelectorAll('.tooltip').forEach(x=>x.remove())
- message('请等待提示,现开始复制\n可通过控制台查看进度\n会暂时去除显示进度功能','',true)
- globalThis.a=document.querySelector('.page-directory-content')
- globalThis.num1=1
- for(let x of a.children){
- if(onstop==true)return;
- await downloader.dispose(x,'computer')
- await sleep(150)
- }
- await downloader.downloadd(type)
- downloader.loadrecord()
- },
- "stop":async()=>{
- onstop=true
- alert('已暂停')
- gui.domElement.children[1].children[0].children[1].children[2].innerText='已暂停'
- await sleep(5000)
- gui.domElement.children[1].children[0].children[1].children[2].remove()
- },
- };
- window.gui = new lil.GUI({ title: '番茄阅读辅助器' });
- window.gui.domElement.style.userSelect = 'none';
- move()
- fqxsydqdata.getdata()
- if(location.href.includes('force_mobile=1')){
- alert('暂不支持手机排版的下载\n如使用电脑请保证长宽比例不低于1\n防止排版进入手机格式')
- return
- }
- var page1
- if(location.href.includes('/page/')){
- page1 = gui.addFolder('复制')
- page1.add(main,'copybook').name('复制本书全文 (仅支持电脑)')
- page1.add({setting:1},'setting',{'原版':1,'机改1':2,'机改2':3}).name('下载设置')
- page1.add({a:100},"a").min(1).name('下载速度')
- document.querySelectorAll('.controller')[1].innerHTML+='<div class="question">?</div>'
- document.querySelector('.question').addEventListener('click',()=>{window.q()})
- downloader.loadrecord()
- downloader.addstyle()
- }
- else if(location.href.includes('/reader/')){
- window.thescroll=document.querySelector('.muye-reader')
- reader.onload()
- window.scrollhref=location.pathname
- thescroll.onscroll=function(e){
- if(scrollhref!==location.pathname){
- reader.onload()
- window.scrollhref=location.pathname
- return
- }
- reader.record()
- fqxsydqdata.savedata()
- }
- document.querySelectorAll('.reader-toolbar-item')[1].addEventListener('click',async()=>{
- await sleep(1500)
- reader.loadrecord()
- })
- page1 = gui.addFolder('阅读')
- var page1_1 = page1.addFolder('滚动').close()
- var page1_2 = page1.addFolder('书签').close()
- reader.scroll.load(page1_1)
- reader.bookmark(page1_2)
- }
- })();