东方永页机

自动翻页

当前为 2022-02-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Pagetual
  3. // @name:zh-CN 东方永页机
  4. // @name:zh-TW 東方永頁機
  5. // @name:ja 東方永頁機
  6. // @name:ru Пейджетуал
  7. // @name:de Pagetual
  8. // @name:es Pagetual
  9. // @name:fr Pagetual
  10. // @name:it Pagetual
  11. // @name:ko 東方永頁機
  12. // @namespace hoothin
  13. // @version 1.0.26
  14. // @description Simply auto loading paginated web pages
  15. // @description:zh-CN 自动翻页
  16. // @description:zh-TW 自動翻頁
  17. // @description:ja Webページを自動で読み込み継ぎ足し表示を行うブラウザ拡張です
  18. // @description:ru Просто автоматически загрузите следующую страницу
  19. // @description:de Laden Sie einfach automatisch die nächste Seite
  20. // @description:es Carga automática de páginas web paginadas
  21. // @description:fr Chargement automatique des pages Web paginées
  22. // @description:it Caricamento automatico di pagine Web impaginate
  23. // @description:ko 다음 페이지를 자동으로 로드하세요
  24. // @author hoothin
  25. // @include http://*
  26. // @include https://*
  27. // @license MIT
  28. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAdVBMVEUAAADZHQbYHQXaHQbYHgbZHATYHgbYHgbZHQXYHgXZHgbZHgfYHQXYHQbXHQDYHgbYHgbYHQXZHgbYHgbYHgbYHgXaHQbYHQbYHQbZHgbZHgbZHQbZHgbYHgbYHQbYHQXYHgfaHwDZHQXZHQbYHwTVHQrYHgbCqWmRAAAAJnRSTlMAUL8oyD/el2cy1CCPcg/35euggPG6FajOr4Z617OdXkkIi1g4GcTbfAwAAAJDSURBVFjD7dbXtqpADADQ0NsA0hHQY83/f+K9rqNOCzPwfvaTugimjEH4s86739yX0+3n8dwd7dQh/seiaWbHscUqCnZEP24LvrXjXLyyaVJMp2RbeFajZInhJWCHcurB7idEVfS+89SGsS28qJFwyN59ZcgsnXeRVrwvSNLFNJEA1/jfDqW4Po8Z1+XwsX6HGA1Cft1Y0ndw0OjCrwxDj4hPDqgYXbGlZ35pj0fQ1dr0C4DM5++lZHMt/qLNXq2rAG5qtWPdoaL5/ZwXloHAP1onUKs3SOSOO5YEsFNLkJN2T/IRRt0gj6ZUUpZTyMmzUx/Vw8wVhwgEI9pog2PiHRO0OhTq2hLnytBK3yRdsKeCGjRnoagKLRbQNfwsXdGiAkLMu5ihWUSvr5S/tPWPlIV8kxvn58CKatMu7Ly1+Kzcsgwj0wqXlgnNMT7CrFPwwaTp+OsSKS4Y1UJ5Phl/BSM3F7JBQmKO78UGJWT/zWJpTae7E4CTtJcnVJ2E7dV4RAWlY36uM96gFnHQT0HFe0zOIZYbnGsVRJZHc/DZFS15pu54URfUSgYJvVJ8BgpPWWu3TwfJUxkvPahylAzy573ybXfQHVEUFt/2uC67KgWcybPp602gndMMKF647bfIUg9oQYmCH6B1PF7jHFDQk2n6PJ7gDcil1FekowdGuVBGqw7rGZXNFSweLnJRJo4pD4cENphb/CoH57O6o8q/wzbJtCBXuXVz7sqQBbBDMJ9a6e+SA/tlzjx0Q3TLL0/4Y/QPSYfEIomUUSEAAAAASUVORK5CYII=
  29. // @grant GM_xmlhttpRequest
  30. // @grant GM_registerMenuCommand
  31. // @grant GM_notification
  32. // @grant GM_getValue
  33. // @grant GM_setValue
  34. // @grant GM_addStyle
  35. // @grant GM_openInTab
  36. // @grant GM_deleteValue
  37. // @grant GM.xmlHttpRequest
  38. // @grant GM.registerMenuCommand
  39. // @grant GM.notification
  40. // @grant GM.getValue
  41. // @grant GM.setValue
  42. // @grant GM.addStyle
  43. // @grant GM.openInTab
  44. // @grant GM.deleteValue
  45. // @supportURL https://github.com/hoothin/UserScripts/issues
  46. // @connect wedata.net
  47. // @connect githubusercontent.com
  48. // @run-at document-idle
  49. // @exclude http://www.toodledo.com/tasks/*
  50. // @exclude http*://maps.google.com*/*
  51. // @exclude *://www.google.*/_/chrome/newtab*
  52. // @exclude *://mega.*/*
  53. // @exclude *://*.mega.*/*
  54. // @exclude *://*.youku.com/v_*
  55. // @exclude *://*pan.baidu.com
  56. // @exclude *://*.iqiyi.com/v_*
  57. // @exclude *://*.iqiyi.com/w_*
  58. // @exclude *://*.iqiyi.com/a_*
  59. // @exclude *://*.le.com/ptv/vplay/*
  60. // @exclude *://v.qq.com/x/cover/*
  61. // @exclude *://v.qq.com/x/page/*
  62. // @exclude *://v.qq.com/tv/*
  63. // @exclude *://*.tudou.com/listplay/*
  64. // @exclude *://*.tudou.com/albumplay/*
  65. // @exclude *://*.tudou.com/programs/view/*
  66. // @exclude *://*.mgtv.com/b/*
  67. // @exclude *://film.sohu.com/album/*
  68. // @exclude *://tv.sohu.com/v/*
  69. // @exclude *://*.bilibili.com/video/*
  70. // @exclude *://*.bilibili.com/bangumi/play/*
  71. // @exclude *://*.baofeng.com/play/*
  72. // @exclude *://vip.pptv.com/show/*
  73. // @exclude *://v.pptv.com/show/*
  74. // @exclude *://www.le.com/ptv/vplay/*
  75. // @exclude *://www.wasu.cn/Play/show/*
  76. // @exclude *://m.v.qq.com/*
  77. // @exclude *://m.iqiyi.com/*
  78. // @exclude *://m.youku.com/alipay_video/*
  79. // @exclude *://m.mgtv.com/b/*
  80. // @exclude *://m.tv.sohu.com/v/*
  81. // @exclude *://m.film.sohu.com/album/*
  82. // @exclude *://m.le.com/ptv/vplay/*
  83. // @exclude *://m.pptv.com/show/*
  84. // @exclude *://m.acfun.cn/v/*
  85. // @exclude *://m.bilibili.com/video/*
  86. // @exclude *://m.bilibili.com/anime/*
  87. // @exclude *://m.bilibili.com/bangumi/play/*
  88. // @exclude *://m.wasu.cn/Play/show/*
  89. // @exclude *://www.youtube.com
  90. // @exclude *://www.youtube.com/
  91. // @exclude *://www.youtube.com/watch*
  92. // @exclude *://baike.baidu.com/*
  93. // @exclude *://*.instagram.com/*
  94. // @exclude *://pagetual.hoothin.com/*
  95. // @exclude *://hoothin.github.io/PagetualGuide/*
  96. // ==/UserScript==
  97.  
  98. (function() {
  99. 'use strict';
  100.  
  101. if (window.name === 'pagetual-iframe') {
  102. var domloaded = function (){
  103. window.scroll(window.scrollX, 999999);
  104. //window.parent.postMessage('pagetual-iframe:DOMLoaded', '*');
  105. };
  106. if(window.opera){
  107. document.addEventListener('DOMContentLoaded', domloaded, false);
  108. } else {
  109. domloaded();
  110. }
  111. return;
  112. }
  113.  
  114. if(window.top != window.self){
  115. return;
  116. }
  117.  
  118. const lang = navigator.appName=="Netscape"?navigator.language:navigator.userLanguage;
  119. var i18n=(name, param)=>{
  120. let config={};
  121. switch (lang){
  122. case "zh-CN":
  123. case "zh-SG":
  124. config={
  125. disable:"暂时禁用",
  126. disableSite:"在此站禁用",
  127. enable:"启用翻页",
  128. toTop:"回到顶部",
  129. toBottom:"前往页尾",
  130. current:"当前页",
  131. forceIframe:"强制拼接",
  132. cancelForceIframe:"取消强制拼接",
  133. configure:"打开配置页",
  134. update:"立即更新规则",
  135. passSec:"更新于 #t# 秒前",
  136. passMin:"更新于 #t# 分钟前",
  137. passHour:"更新于 #t# 小时前",
  138. passDay:"更新于 #t# 天前",
  139. cantDel:"无法删除内置规则",
  140. confirmDel:"是否确认要删除此规则?",
  141. updateSucc:"更新成功",
  142. beginUpdate:"正在更新,请稍候",
  143. customUrls:"导入规则url,一行一条,AutoPagerize 格式规则需要以\"0|\"开头",
  144. customRules:"输入【东方永页机】格式的自定义规则",
  145. save:"保存设置",
  146. loadingText:"少女祈祷中...",
  147. opacity:"分页隔条不透明值",
  148. hideBar:"空白处双击隐藏分页隔条",
  149. dbClick2Stop:"空白处双击暂停翻页",
  150. sortTitle:"排序在下次更新规则后生效",
  151. showPageUpDown:"显示翻屏按钮",
  152. pageUp:"上翻一屏",
  153. pageDown:"下翻一屏",
  154. showRealPage:"显示真实页数",
  155. modifyImage:"修改按钮图标,一行一条,依次为[页首][页尾][上翻][下翻]",
  156. btnCss:"添加按钮CSS"
  157. };
  158. break;
  159. case "zh-TW":
  160. case "zh-HK":
  161. config={
  162. disable:"暫時禁用",
  163. disableSite:"在此站禁用",
  164. enable:"啟用翻頁",
  165. toTop:"回到頂部",
  166. toBottom:"前往頁尾",
  167. current:"當前頁",
  168. forceIframe:"強制拼接",
  169. cancelForceIframe:"取消强制拼接",
  170. configure:"打開配置頁",
  171. update:"立即更新規則",
  172. passSec:"更新于 #t# 秒前",
  173. passMin:"更新于 #t# 分鐘前",
  174. passHour:"更新于 #t# 小時前",
  175. passDay:"更新于 #t# 天前",
  176. cantDel:"無法刪除内置規則",
  177. confirmDel:"是否確認要刪除此規則?",
  178. updateSucc:"更新成功",
  179. beginUpdate:"正在更新,請稍候",
  180. customUrls:"導入規則url,一行一條,AutoPagerize 格式規則需要以\"0|\"開頭",
  181. customRules:"輸入【東方永頁機】格式的自定義規則",
  182. save:"存儲設置",
  183. loadingText:"少女祈禱中...",
  184. opacity:"分頁隔條不透明值",
  185. hideBar:"空白處雙擊隱藏分頁隔條",
  186. dbClick2Stop:"空白處雙擊暫停翻頁",
  187. sortTitle:"排序在下次更新規則後生效",
  188. showPageUpDown:"顯示翻屏按鈕",
  189. pageUp:"上翻一屏",
  190. pageDown:"下翻一屏",
  191. showRealPage:"顯示真實頁數",
  192. modifyImage:"修改按鈕圖標,一行一條,依次為[頁首][頁尾][上翻][下翻]",
  193. btnCss:"添加按鈕CSS"
  194. };
  195. break;
  196. case "ja":
  197. config = {
  198. disable: "一時的に無効にする",
  199. disableSite:"このサイト無効",
  200. enable: "ページめくりを有効にする",
  201. toTop: "トップに戻る",
  202. toBottom: "ページの下部に移動",
  203. current: "現在のページ",
  204. forceIframe: "強制ステッチ",
  205. cancelForceIframe: "強制ステッチをキャンセル",
  206. configure: "設定ページを開く",
  207. update: "今すぐルールを更新してください",
  208. passSec: "#t#秒前に更新",
  209. passMin: "#t#分前に更新",
  210. passHour: "#t#時間前に更新",
  211. passDay: "#t#日前に更新",
  212. cantDel: "組み込みルールを削除できません",
  213. confirmDel: "このルールを削除してもよろしいですか?",
  214. updateSucc: "更新に成功しました",
  215. beginUpdate: "更新中、お待ちください",
  216. customUrls: "インポートルールのURL、1行に1つ、AutoPagerizeフォーマットルールは\"0|\"で始まる必要があります",
  217. customRules: "【東方永頁機】の形式でカスタムルールを入力してください",
  218. save: "設定を保存",
  219. loadingText: "少女祈祷中...",
  220. opacity:"ページネーションバーの不透明値",
  221. hideBar:"空白部分をダブルクリックして、ページ区切り文字を非表示にします",
  222. dbClick2Stop:"空白部分をダブルクリックしてページめくりを一時停止します",
  223. sortTitle:"並べ替えは、次のルールの更新後に有効になります",
  224. showPageUpDown:"ページめくりボタンを表示",
  225. pageUp:"ページアップ",
  226. pageDown:"ページダウン",
  227. showRealPage:"実際のページ数を表示する",
  228. modifyImage:"ボタンアイコンを変更し、[toTop][toBottom][pageUp][pageDown]の順に1行に1つのアイコンを書き込みます",
  229. btnCss:"ボタンCSSを追加"
  230. };
  231. break;
  232. default:
  233. config={
  234. disable:"Disable",
  235. disableSite:"Disable on the site",
  236. enable:"Enable",
  237. toTop:"To Top",
  238. toBottom:"To Bottom",
  239. current:"Current Page",
  240. forceIframe:"Force to join",
  241. cancelForceIframe:"Cancel Force join",
  242. configure:"Configure",
  243. update:"Update rules from url now",
  244. passSec:"Updated #t# seconds ago",
  245. passMin:"Updated #t# minutes ago",
  246. passHour:"Updated #t# hours ago",
  247. passDay:"Updated #t# days ago",
  248. cantDel:"Can't delete buildin rules",
  249. confirmDel:"Are you sure you want to delete this rule?",
  250. updateSucc:"Update succeeded",
  251. beginUpdate:"Begin update, wait a minute please",
  252. customUrls:"Import rule url, One url per line, rules on AutoPagerize format need to start with \"0|\"",
  253. customRules:"Input custom rules with [Pagetual] format",
  254. save:"Save",
  255. loadingText:"Shojo Now Loading...",
  256. opacity:"Pagination spacer opacity",
  257. hideBar:"Double-click on the blank space to hide the paging spacer",
  258. dbClick2Stop:"Double-click on the blank space to stop",
  259. sortTitle:"Sorting takes effect after the next rule update",
  260. showPageUpDown:"Show pageUp/pageDown button",
  261. pageUp: "Page up",
  262. pageDown: "Page down",
  263. showRealPage:"Show real page count",
  264. modifyImage: "Modify button icons, one per line, in order of [toTop][toBottom][pageUp][pageDown]",
  265. btnCss:"Add button CSS"
  266. };
  267. break;
  268. }
  269. return config[name]?config[name].replace("#t#",param):name;
  270. };
  271.  
  272. var enableDebug=true;
  273. var debug=str=>{
  274. if(enableDebug){
  275. console.debug(str);
  276. }
  277. };
  278.  
  279. var _GM_xmlhttpRequest,_GM_registerMenuCommand,_GM_notification,_GM_addStyle,_GM_openInTab;
  280. if(typeof GM_xmlhttpRequest!='undefined'){
  281. _GM_xmlhttpRequest=GM_xmlhttpRequest;
  282. }else if(typeof GM!='undefined' && typeof GM.xmlHttpRequest!='undefined'){
  283. _GM_xmlhttpRequest=GM.xmlHttpRequest;
  284. }
  285. if(typeof GM_registerMenuCommand!='undefined'){
  286. _GM_registerMenuCommand=GM_registerMenuCommand;
  287. }else if(typeof GM!='undefined' && typeof GM.registerMenuCommand!='undefined'){
  288. _GM_registerMenuCommand=GM.registerMenuCommand;
  289. }
  290. if(typeof GM_notification!='undefined'){
  291. _GM_notification=GM_notification;
  292. }else if(typeof GM!='undefined' && typeof GM.notification!='undefined'){
  293. _GM_notification=GM.notification;
  294. }
  295. if(typeof GM_openInTab!='undefined'){
  296. _GM_openInTab=GM_openInTab;
  297. }else if(typeof GM!='undefined' && typeof GM.openInTab!='undefined'){
  298. _GM_openInTab=GM.openInTab;
  299. }
  300. if(typeof GM_addStyle!='undefined'){
  301. _GM_addStyle=GM_addStyle;
  302. }else if(typeof GM!='undefined' && typeof GM.addStyle!='undefined'){
  303. _GM_addStyle=GM.addStyle;
  304. }else{
  305. _GM_addStyle=cssStr=>{
  306. let styleEle=document.createElement("style");
  307. styleEle.innerHTML=cssStr;
  308. document.head.appendChild(styleEle);
  309. };
  310. }
  311.  
  312. if(typeof _GM_xmlhttpRequest=='undefined')_GM_xmlhttpRequest=(f)=>{};
  313. if(typeof _GM_registerMenuCommand=='undefined')_GM_registerMenuCommand=(s,f)=>{};
  314. if(typeof _GM_notification=='undefined')_GM_notification=(s)=>{};
  315. if(typeof _GM_openInTab=='undefined')_GM_openInTab=(s)=>{window.open(s)};
  316. var _unsafeWindow=(typeof unsafeWindow=='undefined')?window:unsafeWindow;
  317. var storage={
  318. supportGM: typeof GM_getValue=='function' && typeof GM_getValue('a','b')!='undefined',
  319. supportGMPromise: typeof GM!='undefined' && typeof GM.getValue=='function' && typeof GM.getValue('a','b')!='undefined',
  320. mxAppStorage:(function(){
  321. try{
  322. return window.external.mxGetRuntime().storage;
  323. }catch(e){
  324. }
  325. })(),
  326. operaUJSStorage:(function(){
  327. try{
  328. return window.opera.scriptStorage;
  329. }catch(e){
  330. }
  331. })(),
  332. setItem:function(key,value){
  333. if(this.operaUJSStorage){
  334. this.operaUJSStorage.setItem(key,value);
  335. }else if(this.mxAppStorage){
  336. this.mxAppStorage.setConfig(key,value);
  337. }else if(this.supportGM){
  338. GM_setValue(key,value);
  339. if(value=="" && typeof GM_deleteValue!='undefined'){
  340. GM_deleteValue(key);
  341. }
  342. }else if(this.supportGMPromise){
  343. GM.setValue(key,value);
  344. if(value=="" && typeof GM!='undefined' && typeof GM.deleteValue!='undefined'){
  345. GM.deleteValue(key);
  346. }
  347. }else if(window.localStorage){
  348. window.localStorage.setItem(key,value);
  349. }
  350. },
  351. getItem:function(key,cb){
  352. var value;
  353. if(this.operaUJSStorage){
  354. value=this.operaUJSStorage.getItem(key);
  355. }else if(this.mxAppStorage){
  356. value=this.mxAppStorage.getConfig(key);
  357. }else if(this.supportGM){
  358. value=GM_getValue(key);
  359. }else if(this.supportGMPromise){
  360. value=GM.getValue(key).then(v=>{cb(v)});
  361. return;
  362. }else if(window.localStorage){
  363. value=window.localStorage.getItem(key);
  364. };
  365. cb(value);
  366. }
  367. };
  368. _GM_registerMenuCommand(i18n("configure"), ()=>{
  369. _GM_openInTab("https://github.com/hoothin/UserScripts/tree/master/Pagetual");
  370. });
  371.  
  372. function getElementByXpath(xpath, contextNode, doc){
  373. doc = doc || document;
  374. contextNode = contextNode || doc;
  375. try {
  376. var result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
  377. return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue;
  378. } catch (err) {
  379. throw new Error(`Invalid xpath: ${xpath}`);
  380. }
  381. }
  382.  
  383. function getAllElementsByXpath(xpath, contextNode, doc){
  384. doc = doc || document;
  385. contextNode = contextNode || doc;
  386. var result = [];
  387. try {
  388. var query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  389. for (var i = 0; i < query.snapshotLength; i++) {
  390. var node = query.snapshotItem(i);
  391. if (node.nodeType === 1) result.push(node);
  392. }
  393. } catch (err) {
  394. throw new Error(`Invalid xpath: ${xpath}`);
  395. }
  396. return result;
  397. }
  398.  
  399. class RuleParser {
  400. constructor() {
  401. this.hpRules=[];
  402. this.customRules=[];
  403. this.rules=[];
  404. this.pageDoc=document;
  405. this.nextLinkHref=null;
  406. this.curUrl=location.href;
  407. this.curSiteRule={};
  408. }
  409.  
  410. initSavedRules(callback){
  411. var self=this;
  412. storage.getItem("hpRules", hpRules=>{
  413. if(hpRules)self.hpRules=hpRules;
  414. storage.getItem("customRules", customRules=>{
  415. if(customRules)self.customRules=customRules;
  416. storage.getItem("rules", rules=>{
  417. if(rules)this.rules=rules;
  418. callback();
  419. });
  420. });
  421. });
  422. }
  423.  
  424. saveCurSiteRule(){
  425. if(!this.curSiteRule || !this.curSiteRule.url || this.curSiteRule.singleUrl)return;
  426. this.hpRules=this.hpRules.filter(item=>{return item&&item.url!=this.curSiteRule.url});
  427. this.hpRules.unshift(this.curSiteRule);
  428. if(this.hpRules.length>30){
  429. this.hpRules.pop();
  430. }
  431. storage.setItem("hpRules", this.hpRules);
  432. }
  433.  
  434. requestJSON(url, callback){
  435. _GM_xmlhttpRequest({
  436. url: url,
  437. method: 'GET',
  438. timeout: 10000,
  439. onload: function(res) {
  440. let json=null;
  441. try{
  442. json=JSON.parse(res.response);
  443. }catch(e){
  444. debug(e);
  445. }
  446. callback(json);
  447. },
  448. onerror: function() {
  449. callback(null);
  450. }
  451. });
  452. }
  453.  
  454. formatRule(item, type, from){
  455. switch(type){
  456. case 0:
  457. return {
  458. from:from,
  459. type:type,
  460. name:item.name,
  461. action:item.data.forceIframe=="true"?1:0,
  462. url:item.data.url,
  463. pageElement:item.data.pageElement,
  464. nextLink:item.data.nextLink,
  465. insert:item.data.insertBefore,
  466. insertPos:1,
  467. updatedAt:item.data.updated_at,
  468. css:item.data.Stylus+item.data.CSS,
  469. pageAction:item.data.bookmarklet
  470. };
  471. break;
  472. case 1:
  473. default:
  474. item.from=from;
  475. if(typeof(item.type) == "undefined")item.type=type;
  476. return item;
  477. break;
  478. }
  479. return null;
  480. }
  481.  
  482. addRuleByUrl(url, type, from, callback) {
  483. this.requestJSON(url, json=>{
  484. this.addRules(json, type, from);
  485. storage.setItem("rules", this.rules);
  486. callback();
  487. });
  488. }
  489.  
  490. addRules(rules, type, from) {
  491. if(rules && rules.length>0){
  492. this.rules=this.rules.filter(item=>{return item.from!=from});
  493. rules.forEach(item=>{
  494. let rule=this.formatRule(item, type, from);
  495. if(rule){
  496. this.rules.push(rule);
  497. }
  498. });
  499. }
  500. }
  501.  
  502. getRule(callback) {
  503. if(this.curSiteRule && this.curSiteRule.url){
  504. return this.curSiteRule;
  505. }
  506. var self=this;
  507.  
  508. function setRule(r){
  509. self.curSiteRule=r;
  510. debug(r);
  511. callback();
  512. }
  513.  
  514. function ruleMatch(r){
  515. let pageElement,nextLink,insert;
  516. if(r.pageElement)pageElement=r.type==0?getElementByXpath(r.pageElement):document.querySelector(r.pageElement);
  517. if(r.nextLink)nextLink=r.type==0?getElementByXpath(r.nextLink):document.querySelector(r.nextLink);
  518. if(r.insert)insert=r.type==0?getElementByXpath(r.insert):document.querySelector(r.insert);
  519. return !((r.pageElement && !pageElement) ||
  520. (r.nextLink && !nextLink) ||
  521. (r.insert && !insert));
  522. }
  523.  
  524. function checkRule(r){
  525. let urlReg=new RegExp(r.url, "i");
  526. if(urlReg.test(location.href)){
  527. if(r.wait){
  528. let waitTime=500,checkEval;
  529. if(isNaN(r.wait)){
  530. checkEval=Function("doc",'"use strict";' + r.wait);
  531. }else{
  532. waitTime=r.wait;
  533. }
  534. let waitTimes=10;
  535. let checkReady=()=>{
  536. if(waitTimes--<=0)return true;
  537. setTimeout(()=>{
  538. if(!ruleMatch(r) || (checkEval && !checkEval(document))){
  539. checkReady();
  540. }else{
  541. setRule(r);
  542. }
  543. },parseInt(waitTime));
  544. };
  545. checkReady();
  546. return true;
  547. }
  548. if(r.pinUrl){
  549. setRule(r);
  550. return true;
  551. }
  552. if(!ruleMatch(r)){
  553. return false;
  554. }
  555. setRule(r);
  556. return true;
  557. }
  558. return false;
  559. }
  560.  
  561. for(let i in this.hpRules){
  562. let rule=this.hpRules[i];
  563. if(!rule || !rule.url)continue;
  564. if(rule.singleUrl){
  565. if(location.origin+location.pathname==rule.url){
  566. setRule(rule);
  567. return;
  568. }
  569. continue;
  570. }
  571. if(checkRule(rule))return;
  572. }
  573. for(let i in this.customRules){
  574. let rule=this.customRules[i];
  575. if(!rule || !rule.url)continue;
  576. if(checkRule(rule))return;
  577. }
  578. let r=0;
  579. function searchByTime(){
  580. setTimeout(()=>{
  581. let end=r+80;
  582. end=end>self.rules.length?self.rules.length:end;
  583. for(;r<end;r++){
  584. let rule=self.rules[r];
  585. if(checkRule(rule))return;
  586. }
  587. if(end>=self.rules.length){
  588. self.curSiteRule={};
  589. self.curSiteRule.url=location.origin+location.pathname;
  590. self.curSiteRule.singleUrl=true;
  591. callback();
  592. return;
  593. }else{
  594. searchByTime();
  595. }
  596. },20);
  597. }
  598. searchByTime();
  599. }
  600.  
  601. geneSelector(ele){
  602. let selector=ele.tagName;
  603. //Google id class都是隨機。百度更過分,style script順序都是隨機的
  604. //if(ele.id) selector += '#' + ele.id;
  605. //if(ele.classList) selector += [].map.call(ele.classList,d=>'.'+d).join('');
  606. let parent = ele.parentElement;
  607. if(parent){
  608. let i,j=0;
  609. for(i=0;i<parent.children.length;i++){
  610. if(parent.children[i].tagName==selector){
  611. j++;
  612. if(parent.children[i]==ele){
  613. break;
  614. }
  615. }
  616. }
  617. selector = this.geneSelector(parent) + ' > ' + selector + (parent.tagName=="HTML"?"":`:nth-of-type(${j})`);
  618. }
  619. return selector;
  620. }
  621.  
  622. getPageElement(doc, curWin, dontFind) {
  623. let pageElement=null;
  624. let self=this;
  625. if(this.curSiteRule.pageElement){
  626. pageElement=this.curSiteRule.type==0?getAllElementsByXpath(this.curSiteRule.pageElement,doc,doc):doc.querySelectorAll(this.curSiteRule.pageElement);
  627. }
  628. if((!pageElement || pageElement.length==0) && curWin && !dontFind){
  629. let body=doc.body;
  630. if(!body)return null;
  631. let bodyHeight=parseInt(body.scrollHeight);
  632. let curHeight=bodyHeight;
  633. function checkElement(ele){
  634. if(curHeight/bodyHeight<=0.30)return null;
  635. if(ele.children.length==0 && !self.curSiteRule.pageElement){
  636. if(ele.parentNode.tagName=="P")ele=ele.parentNode;
  637. self.curSiteRule.pageElement=self.geneSelector(ele.parentNode)+">"+ele.tagName;
  638. self.curSiteRule.type=1;
  639. debug(self.curSiteRule.pageElement);
  640. return [ele];
  641. }
  642. let i,maxHeight=curHeight*0.6,curMaxEle=null,curMaxArea=0,maxWidth=0;
  643. let isHori=true;
  644. let offsetTop=ele.children[0].offsetTop;
  645. for(i=0;i<ele.children.length;i++){
  646. if(ele.children[i].offsetTop!=offsetTop){
  647. isHori=false;
  648. break;
  649. }
  650. }
  651. for(i=0;i<ele.children.length;i++){
  652. let curNode=ele.children[i];
  653. let comStyle=curWin.getComputedStyle(curNode);
  654. let h=parseInt(curNode.scrollHeight);
  655. let w=parseInt(curNode.scrollWidth);
  656. if(isNaN(h) || isNaN(w))continue;
  657. if(isHori && h==0)continue;
  658. let a=h*w+h,moreChild=curNode.children[0];
  659. while(moreChild){
  660. comStyle=curWin.getComputedStyle(moreChild);
  661. let ch=parseInt(moreChild.scrollHeight);
  662. let cw=parseInt(moreChild.scrollWidth);
  663. if(h<ch)h=ch;
  664. if(moreChild.innerText!="" && !isNaN(ch) && !isNaN(cw)){
  665. a+=ch*cw;
  666. }
  667. moreChild=moreChild.nextElementSibling;
  668. }
  669. if(curMaxEle==null || (isHori?maxWidth<w:curMaxArea<a)){
  670. if(h>0)curHeight=h;
  671. curMaxArea=a;
  672. maxWidth=w;
  673. curMaxEle=curNode;
  674. }
  675. }
  676. if(curMaxEle && (isHori || curHeight>maxHeight)){
  677. return checkElement(curMaxEle);
  678. }
  679. if(!self.curSiteRule.pageElement){
  680. if(ele.tagName=="P")ele=ele.parentNode;
  681. self.curSiteRule.pageElement=self.geneSelector(ele);
  682. if(ele.tagName!="UL")self.curSiteRule.pageElement+=">*";
  683. self.curSiteRule.type=1;
  684. debug(self.curSiteRule.pageElement);
  685. }
  686. return ele.tagName=="UL"?ele:ele.children;
  687. }
  688. pageElement=checkElement(body);
  689. if(pageElement)this.saveCurSiteRule();
  690. }
  691. return pageElement;
  692. }
  693.  
  694. getPage(doc){
  695. if(_unsafeWindow.Discourse)return {};
  696. let canSave=false;//發現頁碼選擇器在其他頁對不上,還是別保存了
  697. let url=this.curUrl.replace("#!","");
  698. let pageNum=1,preStr="",afterStr="";
  699. let pageMatch1=url.match(/(.*[a-z\/\-_](?:p|page)?\/?)(\d+)(\.s?html?$|\/?$)/i);
  700. let pageMatch2=url.match(/(.*[\?&]p(?:age)?=)(\d+)($|[#&].*)/i);
  701. if(pageMatch1){
  702. preStr=pageMatch1[1];
  703. pageNum=pageMatch1[2];
  704. afterStr=pageMatch1[3];
  705. }else if(pageMatch2){
  706. preStr=pageMatch2[1];
  707. pageNum=pageMatch2[2];
  708. afterStr=pageMatch2[3];
  709. }
  710. let curPage=doc,i,cur,jsNext;
  711. let next=curPage.querySelector("a.next");
  712. if(!next)next=curPage.querySelector("a#next");
  713. if(!next)next=curPage.querySelector("a#rightFix");
  714. if(!next)next=curPage.querySelector("a.next_page");
  715. if(!next)next=curPage.querySelector(".next>a");
  716. if(!next)next=curPage.querySelector("#next_page");
  717. if(!next)next=curPage.querySelector(".next>button");
  718. if(!next)next=curPage.querySelector("a[alt=next]");
  719. if(!next)next=curPage.querySelector("[title=next]");
  720. if(!next){
  721. next=curPage.querySelectorAll("[aria-label='Next']");
  722. if(next && next.length==1){
  723. next=next[0];
  724. }else{
  725. next=null;
  726. }
  727. }
  728. if(!next){
  729. next=curPage.querySelectorAll("[aria-label='Next page']");
  730. if(next && next.length==1){
  731. next=next[0];
  732. }else{
  733. next=null;
  734. }
  735. }
  736. if(!next)next=curPage.querySelector(".nextPage");
  737. if(next && (!next.href || /^javascript:/.test(next.href))){
  738. jsNext=next;
  739. next=null;
  740. }
  741. if(!next){
  742. let pageDiv=curPage.querySelector("div.wp-pagenavi");
  743. if(pageDiv){
  744. cur=pageDiv.querySelector("span.current");
  745. next=cur.nextSibling;
  746. }else{
  747. cur=curPage.querySelector("div.article-paging>span");
  748. if(cur){
  749. next=cur.nextElementSibling;
  750. }
  751. }
  752. }
  753. if(!next){
  754. let pageDiv=curPage.querySelector("div.pages>ul");
  755. if(pageDiv){
  756. cur=pageDiv.querySelector("li>b");
  757. if(cur)next=cur.parentNode.nextElementSibling.querySelector("a");
  758. }
  759. }
  760. if(!next){
  761. let aTags=curPage.querySelectorAll("a");
  762. let next1,next2,next3,next4,nextJs1,nextJs2,nextJs3;
  763. for(i=aTags.length-1;i>=0;i--){
  764. let aTag=aTags[i];
  765. if(aTag.style.display=="none")continue;
  766. if(next1 && next2 && next3 && next4)break;
  767. if(!next1){
  768. if(/^\s*下[一1]?[页頁张張]|^next( page)?\s*$|次のページ/i.test(aTag.innerText)){
  769. if(!aTag.href || /^javascript:/.test(aTag.href)){
  770. if(!nextJs1)nextJs1=aTag;
  771. }else{
  772. next1=aTag;
  773. }
  774. }
  775. }
  776. if(!next2){
  777. if(/^\s*下[一1]?[章话話]/i.test(aTag.innerText)){
  778. if(!aTag.href || /^javascript:/.test(aTag.href)){
  779. if(!nextJs2)nextJs2=aTag;
  780. }else{
  781. next2=aTag;
  782. }
  783. }
  784. }
  785. if(!next3){
  786. if(aTag.innerText=="&gt;" || aTag.innerText=="▶" || aTag.innerText=="»"){
  787. if(!aTag.href || /^javascript:/.test(aTag.href)){
  788. if(!nextJs3)nextJs3=aTag;
  789. }else{
  790. next3=aTag;
  791. }
  792. }
  793. }
  794. if(!aTag.href || /^javascript:/.test(aTag.href))continue;
  795. if(!next4){
  796. if(aTag.href.replace("?&","?").replace("#!","").replace(preStr,"").replace(afterStr,"")==parseInt(pageNum)+1){
  797. next4=aTag;
  798. }else if(aTag.href.replace("?&","?").indexOf(url)!=-1 && /^[\/\?&]?[_-]?(p|page)?=?\/?2(\/|\?|&|$)/i.test(aTag.href.replace(url,"").replace(/\.s?html?$/i,""))){
  799. next4=aTag;
  800. }
  801. }
  802. }
  803. next=next1||next2||next3||next4||nextJs1||nextJs2||nextJs3;
  804. }
  805. if(!next)next=jsNext;
  806. return {next:next,canSave:canSave};
  807. }
  808.  
  809. getNextLink(doc) {
  810. let nextLink=null,page;
  811. if(this.curSiteRule.pageElementByJs){
  812. this.nextLinkHref="#";
  813. return true;
  814. }else if(this.curSiteRule.nextLinkByJs){
  815. try{
  816. let targetUrl=Function("doc",'"use strict";' + this.curSiteRule.nextLinkByJs)(doc);
  817. if(targetUrl)nextLink={href:targetUrl};
  818. }catch(e){}
  819. }else if(this.curSiteRule.nextLinkByUrl){
  820. let targetUrl=this.curUrl.replace(new RegExp(this.curSiteRule.nextLinkByUrl[0]), this.curSiteRule.nextLinkByUrl[1]);
  821. if(targetUrl != this.curUrl){
  822. let reps=targetUrl.match(/{.*?}/g);
  823. if(reps){
  824. reps.forEach(rep=>{
  825. let code=rep.replace("{","").replace("}","");
  826. let result=code.match(/^(\d+)\+1$/);
  827. if(result){
  828. result=parseInt(result[1])+1;
  829. }else{
  830. try{
  831. result=Function('"use strict";return ' + code)();;
  832. }catch(e){}
  833. }
  834. targetUrl=targetUrl.replace(rep, result);
  835. });
  836. }
  837. }
  838. nextLink={href:targetUrl};
  839. }else if(this.curSiteRule.nextLink){
  840. nextLink=this.curSiteRule.type==0?getElementByXpath(this.curSiteRule.nextLink,doc,doc):doc.querySelector(this.curSiteRule.nextLink);
  841. }else{
  842. page=this.getPage(doc);
  843. nextLink=page.next;
  844. if(nextLink && nextLink.classList.contains("noClick")){
  845. self.nextLinkHref=false;
  846. return null;
  847. }else if(nextLink && doc==document){
  848. if(!isVisible(nextLink, _unsafeWindow)){
  849. self.nextLinkHref=false;
  850. return null;
  851. }else{
  852. let nextLinkCs=_unsafeWindow.getComputedStyle(nextLink);
  853. if(nextLinkCs.cursor=="not-allowed"){
  854. self.nextLinkHref=false;
  855. return null;
  856. }
  857. }
  858. }
  859. }
  860. if(nextLink){
  861. if(nextLink.href=="javascript:;" && (this.curSiteRule.action==0 || this.curSiteRule.action==1)){
  862. nextLink=null;
  863. }
  864. /*if(!this.curSiteRule.nextLink && page && page.canSave){
  865. this.curSiteRule.nextLink=this.geneSelector(nextLink);
  866. this.curSiteRule.type=1;
  867. this.saveCurSiteRule();
  868. }*/
  869. }
  870. if(nextLink){
  871. this.nextLinkHref=nextLink.href?nextLink.href:"#";
  872. debug(nextLink);
  873. }else{
  874. this.nextLinkHref=false;
  875. }
  876. return nextLink;
  877. }
  878.  
  879. getInsert(refresh) {
  880. if(this.insert && !refresh){
  881. let parent=this.insert;
  882. while(parent && parent.nodeName!="BODY"){
  883. parent=parent.parentNode;
  884. }
  885. if(parent && parent.nodeName=="BODY"){
  886. return this.insert;
  887. }
  888. }
  889. if(this.curSiteRule.insert){
  890. this.insert=this.curSiteRule.type==0?getElementByXpath(this.curSiteRule.insert,document):document.querySelector(this.curSiteRule.insert);
  891. }else{
  892. let pageElement=this.getPageElement(document, _unsafeWindow);
  893. if(pageElement && pageElement.length>0){
  894. var pELast = pageElement[pageElement.length - 1];
  895. this.insert = pELast.nextSibling ? pELast.nextSibling : pELast.parentNode.appendChild(document.createTextNode(' '));
  896. }
  897. }
  898. return this.insert;
  899. }
  900.  
  901. pageAction(doc,eles){
  902. let code=this.curSiteRule.pageAction;
  903. if(code){
  904. try{
  905. Function("doc","eles",'"use strict";' + code)(doc,eles);
  906. }catch(e){}
  907. }
  908. [].forEach.call(eles, ele=>{
  909. [].forEach.call(ele.querySelectorAll("img"), img=>{
  910. let realSrc;
  911. if(img.dataset && img.dataset.original){
  912. realSrc=img.dataset.original;
  913. }else if(img.dataset && img.dataset.src){
  914. realSrc=img.dataset.src;
  915. }else if(img._lazyrias && img._lazyrias.srcset){
  916. realSrc=img._lazyrias.srcset[img._lazyrias.srcset.length-1];
  917. }else if(img.dataset && img.dataset.origFile){
  918. realSrc=img.dataset.origFile;
  919. }else if(img.srcset){
  920. var srcs=img.srcset.split(","),largeSize=0;
  921. srcs.forEach(srci=>{
  922. let srcInfo=srci.trim().split(" "),curSize=parseInt(srcInfo[1]);
  923. if(srcInfo[1] && curSize>largeSize){
  924. largeSize=curSize;
  925. realSrc=srcInfo[0];
  926. }
  927. });
  928. }
  929. if(realSrc)img.src=realSrc;
  930. });
  931. [].forEach.call(ele.querySelectorAll("a.lazyload"), a=>{
  932. if(a.dataset.original){
  933. a.style.backgroundImage='url("'+a.dataset.original+'")';
  934. }
  935. });
  936. });
  937. let lazyImgSrc=this.curSiteRule.lazyImgSrc;
  938. if(lazyImgSrc){
  939. [].forEach.call(eles, ele=>{
  940. [].forEach.call(ele.querySelectorAll("img"), img=>{
  941. if(img[lazyImgSrc]){
  942. img.src=img[lazyImgSrc];
  943. }
  944. });
  945. });
  946. }
  947. }
  948.  
  949. initPage(callback){
  950. let self=this;
  951. curPage=1;
  952. //if(this.curSiteRule.url && !this.curSiteRule.singleUrl)return;
  953. this.curSiteRule={};
  954. this.pageDoc=document;
  955. this.nextLinkHref=null;
  956. this.curUrl=location.href;
  957. this.getRule(()=>{
  958. if(self.curSiteRule.enable==0){
  959. debug("Stop as rule disable");
  960. isPause=true;
  961. return;
  962. }
  963. if(self.curSiteRule && !self.curSiteRule.singleUrl){
  964. self.hpRules=self.hpRules.filter(item=>{return item&&item.url!=self.curSiteRule.url});
  965. self.hpRules.unshift(self.curSiteRule);
  966. if(self.hpRules.length>30){
  967. self.hpRules.pop();
  968. }
  969. storage.setItem("hpRules", self.hpRules);
  970. }
  971. let css=self.curSiteRule.css;
  972. if(css){
  973. _GM_addStyle(css);
  974. }
  975. let code=self.curSiteRule.init;
  976. if(code){
  977. try{
  978. Function('"use strict";' + code)();
  979. }catch(e){}
  980. }
  981. self.getNextLink(document);
  982. callback();
  983. });
  984. }
  985.  
  986. insertPage(doc, eles, url, callback, tried){
  987. this.pageDoc=doc;
  988. this.curUrl=url;
  989. this.pageAction(doc, eles);
  990. let nextLink=this.getNextLink(doc);
  991. if(curPage==1 && !tried && !this.nextLinkHref && this.curSiteRule.singleUrl && this.curSiteRule.pageElement){
  992. this.curSiteRule.action=1;
  993. return false;
  994. }
  995. if(callback)callback(eles);
  996. this.getInsert();
  997. var self=this;
  998. if(!eles || eles.length==0 || !self.insert || !self.insert.parentNode){
  999. }else{
  1000. [].forEach.call(eles, ele=>{
  1001. let newEle=ele.cloneNode(true);
  1002. let oldCanvass=ele.querySelectorAll("canvas");
  1003. let newCanvass=newEle.querySelectorAll("canvas");
  1004. for(let i=0;i<oldCanvass.length;i++){
  1005. let oldCanvas=oldCanvass[i];
  1006. let newCanvas=newCanvass[i];
  1007. newCanvas.getContext('2d').drawImage(oldCanvas, 0, 0);
  1008. }
  1009. if(self.curSiteRule.insertPos==2){
  1010. self.insert.appendChild(newEle);
  1011. }else{
  1012. self.insert.parentNode.insertBefore(newEle, self.insert);
  1013. }
  1014. });
  1015. }
  1016. if(nextLink.tagName){
  1017. let nextLinkCs=_unsafeWindow.getComputedStyle(nextLink);
  1018. if(nextLinkCs.cursor=="not-allowed" || !isVisible(nextLink, _unsafeWindow)){
  1019. self.nextLinkHref=false;
  1020. }
  1021. }
  1022. return true;
  1023. }
  1024. }
  1025. var ruleParser = new RuleParser();
  1026.  
  1027. var rulesData={},ruleUrls,updateDate,configPage="https://github.com/hoothin/UserScripts/tree/master/Pagetual";
  1028. function initConfig(){
  1029. _GM_registerMenuCommand(i18n(forceState==1?"enable":"disableSite"), ()=>{
  1030. storage.setItem("forceState_"+location.host, (forceState==1?"":1));
  1031. location.reload();
  1032. });
  1033.  
  1034. _GM_registerMenuCommand(i18n(forceState==2?"cancelForceIframe":"forceIframe"), ()=>{
  1035. storage.setItem("forceState_"+location.host, (forceState==2?"":2));
  1036. location.reload();
  1037. });
  1038. var configCon,insertPos;
  1039. if(location.href=="https://github.com/hoothin/UserScripts/tree/master/Pagetual"){
  1040. _GM_addStyle(`
  1041. p>span:nth-child(1),p>span:nth-child(2),p>span:nth-child(3){
  1042. cursor: pointer;
  1043. user-select: none;
  1044. }
  1045. p>span:nth-child(1):hover,p>span:nth-child(2):hover,p>span:nth-child(3):hover{
  1046. color:red;
  1047. }
  1048. .updateDate{
  1049. cursor: pointer;
  1050. user-select: none;
  1051. }
  1052. .updateDate:hover{
  1053. color:red;
  1054. }
  1055. `);
  1056. configCon=document.querySelector(".markdown-body");
  1057. insertPos=configCon.querySelector("hr");
  1058. }else if(location.href==configPage){
  1059. }else return;
  1060. class Rulebar {
  1061. init(ruleUrl){
  1062. this.ruleUrl=ruleUrl;
  1063. this.item=document.createElement("p");
  1064. this.item.title=ruleUrl.type==0?"AutoPagerize Rules":"Pagetual Rules";
  1065. this.item.dataset.id=this.ruleUrl.id;
  1066. let url=document.createElement("span");
  1067. url.innerHTML=ruleUrl.url;
  1068. let up=document.createElement("span");
  1069. up.innerHTML="↑ ";
  1070. up.title=i18n("sortTitle");
  1071. let down=document.createElement("span");
  1072. down.innerHTML="↓ ";
  1073. down.title=i18n("sortTitle");
  1074. let del=document.createElement("span");
  1075. del.innerHTML="× ";
  1076. up.onclick=e=>{
  1077. this.moveUp();
  1078. };
  1079. down.onclick=e=>{
  1080. this.moveDown();
  1081. };
  1082. del.onclick=e=>{
  1083. this.del();
  1084. };
  1085. this.item.appendChild(up);
  1086. this.item.appendChild(down);
  1087. this.item.appendChild(del);
  1088. this.item.appendChild(url);
  1089. configCon.insertBefore(this.item, insertPos);
  1090. }
  1091. saveSort(){
  1092. let sort=[];
  1093. [].forEach.call(this.item.parentNode.querySelectorAll("p[data-id]"), i=>{
  1094. sort.push(i.dataset.id);
  1095. });
  1096. rulesData.sort=sort;
  1097. storage.setItem("rulesData", rulesData);
  1098. }
  1099. moveUp(){
  1100. let preE=this.item.previousElementSibling;
  1101. if(preE.tagName=="P" && preE.children.length>1){
  1102. this.item.parentNode.insertBefore(this.item,preE);
  1103. this.saveSort();
  1104. }
  1105. }
  1106. moveDown(){
  1107. let nextE=this.item.nextElementSibling;
  1108. if(nextE.tagName=="P" && nextE.children.length>1){
  1109. this.item.parentNode.insertBefore(nextE,this.item);
  1110. this.saveSort();
  1111. }
  1112. }
  1113. del(){
  1114. if(this.ruleUrl.id<2){
  1115. alert(i18n("cantDel"));
  1116. }else if(window.confirm(i18n("confirmDel"))){
  1117. for(let u=0;u<rulesData.urls.length;u++){
  1118. if(this.ruleUrl.id==rulesData.urls[u].id){
  1119. rulesData.urls.splice(u,1);
  1120. break;
  1121. }
  1122. }
  1123. for(let u=0;u<rulesData.sort.length;u++){
  1124. if(this.ruleUrl.id==rulesData.sort[u]){
  1125. rulesData.sort.splice(u,1);
  1126. break;
  1127. }
  1128. }
  1129. storage.setItem("rulesData", rulesData);
  1130. ruleParser.rules=ruleParser.rules.filter(item=>{return item.from!=this.ruleUrl.id});
  1131. storage.setItem("rules", ruleParser.rules);
  1132. this.item.parentNode.removeChild(this.item);
  1133. //location.reload();
  1134. }
  1135. }
  1136. }
  1137. let updateP=document.createElement("p"),i=0;
  1138. let now=new Date().getTime(),inUpdate=false;
  1139.  
  1140.  
  1141. let pastDate=(new Date(updateDate)).toString(),passStr;
  1142. let passTime=(now-updateDate)/1000;
  1143. if(passTime<60){
  1144. passStr=i18n("passSec", passTime);
  1145. }else if(passTime<60*60){
  1146. passStr=i18n("passMin", parseInt(passTime/60));
  1147. }else if(passTime<60*60*24){
  1148. passStr=i18n("passHour", parseInt(passTime/3600));
  1149. }else{
  1150. passStr=i18n("passDay", parseInt(passTime/86400));
  1151. }
  1152.  
  1153.  
  1154. updateP.className="updateDate";
  1155. updateP.innerHTML=passStr;
  1156. updateP.title=i18n("update")+" - "+pastDate;
  1157. updateP.onclick=e=>{
  1158. if(inUpdate)return;
  1159. inUpdate=true;
  1160. let ruleIndex=0;
  1161. storage.setItem("hpRules", []);
  1162. function addNextRule(){
  1163. if(ruleIndex>=ruleUrls.length){
  1164. storage.setItem("ruleLastUpdate", now);
  1165. alert(i18n("updateSucc"));
  1166. inUpdate=false;
  1167. updateP.innerHTML=i18n("passSec", 0);
  1168. updateP.title=i18n("update");
  1169. }else{
  1170. let rule=ruleUrls[ruleIndex++];
  1171. ruleParser.addRuleByUrl(rule.url, rule.type, rule.id, ()=>{
  1172. addNextRule();
  1173. })
  1174. }
  1175. }
  1176. addNextRule();
  1177. alert(i18n("beginUpdate"));
  1178. };
  1179. configCon.insertBefore(updateP, insertPos);
  1180. if(ruleUrls){
  1181. ruleUrls.forEach(ruleUrl=>{
  1182. var rulebar=new Rulebar();
  1183. rulebar.init(ruleUrl);
  1184. });
  1185. }
  1186. let customUrlsTitle=document.createElement("h2");
  1187. customUrlsTitle.innerHTML=i18n("customUrls");
  1188. configCon.insertBefore(customUrlsTitle, insertPos);
  1189. let customUrlsInput=document.createElement("textarea");
  1190. customUrlsInput.style.width="100%";
  1191. customUrlsInput.placeholder="0|http://wedata.net/databases/AutoPagerize/items_all.json";
  1192. configCon.insertBefore(customUrlsInput, insertPos);
  1193.  
  1194. let opacityTitle=document.createElement("h2");
  1195. opacityTitle.innerHTML=i18n("opacity");
  1196. let opacityInput=document.createElement("input");
  1197. opacityInput.value=rulesData.opacity*100;
  1198. opacityInput.type="number";
  1199. opacityInput.style.width="50px";
  1200. opacityInput.style.margin="0 0 0 10px";
  1201. opacityTitle.appendChild(opacityInput);
  1202. configCon.insertBefore(opacityTitle, insertPos);
  1203.  
  1204.  
  1205. let hideBarTitle=document.createElement("h2");
  1206. hideBarTitle.innerHTML=i18n("hideBar");
  1207. let hideBarInput=document.createElement("input");
  1208. hideBarInput.type="checkbox";
  1209. hideBarInput.style.width="50px";
  1210. hideBarInput.style.height="20px";
  1211. hideBarInput.checked=rulesData.hideBar;
  1212. hideBarTitle.appendChild(hideBarInput);
  1213. configCon.insertBefore(hideBarTitle, insertPos);
  1214.  
  1215. let dbClick2StopTitle=document.createElement("h2");
  1216. dbClick2StopTitle.innerHTML=i18n("dbClick2Stop");
  1217. let dbClick2StopInput=document.createElement("input");
  1218. dbClick2StopInput.type="checkbox";
  1219. dbClick2StopInput.style.width="50px";
  1220. dbClick2StopInput.style.height="20px";
  1221. dbClick2StopInput.checked=rulesData.dbClick2Stop;
  1222. dbClick2StopTitle.appendChild(dbClick2StopInput);
  1223. configCon.insertBefore(dbClick2StopTitle, insertPos);
  1224.  
  1225. let customRulesTitle=document.createElement("h2");
  1226. customRulesTitle.innerHTML=i18n("customRules")
  1227. configCon.insertBefore(customRulesTitle, insertPos);
  1228. let customRulesInput=document.createElement("textarea");
  1229. customRulesInput.style.width="100%";
  1230. customRulesInput.style.height="500px";
  1231. customRulesInput.placeholder=`[\n {\n "name":"yande",\n "action":"0",\n "url":"^https:\/\/yande\\.re\/",\n "pageElement":"ul#post-list-posts>li",\n "nextLink":"a.next_page",\n "css":".javascript-hide {display: inline-block !important;}"\n },\n {\n "name":"tieba",\n "action":"1",\n "url":"^https:\/\/tieba\\.baidu.com\/f\\?kw=",\n "pageElement":"ul#thread_list>li",\n "nextLink":".next.pagination-item "\n }\n]`;
  1232. customRulesInput.value=getFormatJSON(ruleParser.customRules);
  1233. configCon.insertBefore(customRulesInput, insertPos);
  1234. let saveBtn=document.createElement("button");
  1235. saveBtn.innerHTML=i18n("save");
  1236. saveBtn.style.width="100%";
  1237. configCon.insertBefore(saveBtn, insertPos);
  1238. saveBtn.onclick=e=>{
  1239. try{
  1240. storage.setItem("hpRules", []);
  1241. if(customRulesInput.value==""){
  1242. storage.setItem("customRules", "");
  1243. }else{
  1244. let customRules=JSON.parse(customRulesInput.value);
  1245. if(Array && Array.isArray && !Array.isArray(customRules)){
  1246. alert("Rules must be a Array!");
  1247. return;
  1248. }
  1249. debug(customRules);
  1250. storage.setItem("customRules", customRules);
  1251. }
  1252. }catch(e){
  1253. debug(e);
  1254. alert("JSON error, check again!");
  1255. return;
  1256. }
  1257. rulesData.opacity=opacityInput.value/100;
  1258. rulesData.hideBar=hideBarInput.checked;
  1259. rulesData.dbClick2Stop=dbClick2StopInput.checked;
  1260. storage.setItem("rulesData", rulesData);
  1261. let customUrls=customUrlsInput.value.trim();
  1262. if(customUrls){
  1263. customUrls=customUrls.split(/\n/);
  1264. for(let c=0;c<customUrls.length;c++){
  1265. let urlArr=customUrls[c].split("|"),url,type=1;
  1266. if(urlArr.length==1){
  1267. url=urlArr[0].trim();
  1268. if(!/^http/.test(url)){
  1269. alert("Wrong url, check again!");
  1270. return;
  1271. }
  1272. }else if(urlArr.length==2){
  1273. type=urlArr[0].trim();
  1274. url=urlArr[1].trim();
  1275. if(!/^http/.test(url)){
  1276. alert("Wrong url, check again!");
  1277. return;
  1278. }
  1279. }else{
  1280. break;
  1281. }
  1282. let maxId=0,hasUrl=false;;
  1283. if(!rulesData.urls){
  1284. rulesData.urls=[];
  1285. maxId=1;
  1286. }else{
  1287. rulesData.urls.forEach(u=>{
  1288. if(maxId<u.id){
  1289. maxId=u.id;
  1290. }
  1291. if(u.url==url){
  1292. hasUrl=true;
  1293. }
  1294. });
  1295. if(hasUrl)break;
  1296. }
  1297. rulesData.urls.push({id:maxId+1,url:url,type:type});
  1298. rulesData.sort.push(maxId+1);
  1299. storage.setItem("rulesData", rulesData);
  1300. }
  1301. }
  1302. alert("Modified successfully");
  1303. location.reload();
  1304. };
  1305. }
  1306.  
  1307. function objIsArr(obj) {
  1308. return obj &&
  1309. typeof obj === 'object' &&
  1310. typeof obj.length === 'number' &&
  1311. !(obj.propertyIsEnumerable('length'));
  1312. }
  1313.  
  1314. function isVisible(el, win) {
  1315. var loopable = true,
  1316. visible = win.getComputedStyle(el).display != 'none' && win.getComputedStyle(el).visibility != 'hidden';
  1317. while(loopable && visible) {
  1318. el = el.parentNode;
  1319.  
  1320. if(el && el.tagName!="BODY") {
  1321. visible = win.getComputedStyle(el).display != 'none' && win.getComputedStyle(el).visibility != 'hidden';
  1322. }else {
  1323. loopable = false;
  1324. }
  1325. }
  1326. return visible;
  1327. }
  1328.  
  1329. function getFormatJSON(obj){
  1330. if(!objIsArr(obj))return "";
  1331. let ret="[\n";
  1332. let len=obj.length,i=0,isLast;
  1333. obj.forEach(item=>{
  1334. ret+=" {\n";
  1335. let iLen=Object.keys(item).length,j=0;
  1336. for(let key in item){
  1337. isLast=(++j)==iLen;
  1338. let value=item[key];
  1339. if(objIsArr(value)){
  1340. let vstr="[",v=0,vIsLast=false;
  1341. value.forEach(vi=>{
  1342. vIsLast=(++v)==value.length;
  1343. vstr+="\""+vi.replace(/\\/g,"\\\\")+"\""+(vIsLast?"":",");
  1344. });
  1345. vstr+="]";
  1346. ret+=" \""+key+"\":"+vstr+""+(isLast?"":",")+"\n";
  1347. }else{
  1348. if(typeof value=="string"){
  1349. value=value.replace(/\\/g,"\\\\").replace(/"/g,"\\\"");
  1350. value="\""+value+"\"";
  1351. }
  1352. ret+=" \""+key+"\":"+value+""+(isLast?"":",")+"\n";
  1353. }
  1354. }
  1355. isLast=(++i)==len;
  1356. ret+=" }"+(isLast?"":",")+"\n";
  1357. });
  1358. ret+="]";
  1359. return ret;
  1360. }
  1361.  
  1362. function initRules(callback) {
  1363. /*0 wedata格式,1 pagetual格式*/
  1364. ruleUrls=[
  1365. {
  1366. id:0,
  1367. url:'https://raw.githubusercontent.com/hoothin/UserScripts/master/Pagetual/pagetualRules.json',
  1368. type:1
  1369. },
  1370. {
  1371. id:1,
  1372. url:'http://wedata.net/databases/AutoPagerize/items_all.json',
  1373. type:0,
  1374. }
  1375. ];var i=0,j=0;
  1376.  
  1377. ruleParser.initSavedRules(()=>{
  1378. storage.getItem("rulesData", data=>{
  1379. if(data){
  1380. rulesData=data;
  1381. if(data.urls)ruleUrls=ruleUrls.concat(data.urls);
  1382. if(data.sort){
  1383. let urls=[];
  1384. data.sort.forEach(id=>{
  1385. for(let s=0;s<ruleUrls.length;s++){
  1386. if(id==ruleUrls[s].id){
  1387. urls.push(ruleUrls[s]);
  1388. break;
  1389. }
  1390. }
  1391. });
  1392. ruleUrls=urls;
  1393. }
  1394. }
  1395. if(typeof(rulesData.opacity)=="undefined"){
  1396. rulesData.opacity=0.3;
  1397. }
  1398. if(typeof(rulesData.hideBar)=="undefined"){
  1399. rulesData.hideBar=true;
  1400. }
  1401. if(typeof(rulesData.dbClick2Stop)=="undefined"){
  1402. rulesData.dbClick2Stop=true;
  1403. }
  1404. storage.getItem("forceState_"+location.host, v=>{
  1405. storage.getItem("ruleLastUpdate", date=>{
  1406. forceState=v||0;
  1407. updateDate=date;
  1408. initConfig();
  1409. if(forceState==1)return;
  1410. let now=new Date().getTime();
  1411. if(!date || now-date>2*24*60*60*1000){
  1412. storage.setItem("ruleLastUpdate", now);
  1413. storage.setItem("hpRules", []);
  1414. let ruleIndex=0;
  1415. function addNextRule(){
  1416. if(ruleIndex>=ruleUrls.length){
  1417. callback();
  1418. }else{
  1419. let rule=ruleUrls[ruleIndex++];
  1420. ruleParser.addRuleByUrl(rule.url, rule.type, rule.id, ()=>{
  1421. addNextRule();
  1422. })
  1423. }
  1424. }
  1425. addNextRule();
  1426. }else{
  1427. callback();
  1428. }
  1429. });
  1430. });
  1431. });
  1432. });
  1433. }
  1434.  
  1435. function requestDoc(url, callback){
  1436. _GM_xmlhttpRequest({
  1437. url: url,
  1438. method: 'GET',
  1439. overrideMimeType: 'text/html;charset='+document.charset,
  1440. headers: {
  1441. 'Referer': location.href
  1442. },
  1443. timeout: 5000,
  1444. onload: function(res) {
  1445. var doc=null;
  1446. try {
  1447. doc=document.implementation.createHTMLDocument('');
  1448. doc.documentElement.innerHTML=res.response;
  1449. }
  1450. catch (e) {
  1451. debug('parse error'+e.toString());
  1452. }
  1453. let pageElement=ruleParser.getPageElement(doc);
  1454. //只有1的話怕不是圖片哦
  1455. if(pageElement && (pageElement.length>1 || (pageElement.length==1 && pageElement[0].tagName!="IMG") )){
  1456. let result=ruleParser.insertPage(doc, pageElement, url, callback, false);
  1457. if(!result){
  1458. requestFromIframe(url, (doc, eles)=>{
  1459. if(eles){
  1460. ruleParser.insertPage(doc, eles, url, callback, true);
  1461. }
  1462. });
  1463. }
  1464. }else if(ruleParser.curSiteRule.singleUrl){
  1465. requestFromIframe(url, (doc, eles)=>{
  1466. if(eles){
  1467. ruleParser.insertPage(doc, eles, url, callback, true);
  1468. }
  1469. });
  1470. }
  1471. },
  1472. onerror: function(e){
  1473. debug(e);
  1474. callback(false);
  1475. }
  1476. });
  1477. }
  1478.  
  1479. var failFromIframe=0;
  1480. function requestFromIframe(url, callback){
  1481. let orgPage,curPage;
  1482. let iframe = document.createElement('iframe');
  1483. iframe.name = 'pagetual-iframe';
  1484. iframe.width = '100%';
  1485. iframe.height = '0';
  1486. iframe.frameBorder = '0';
  1487. iframe.sandbox="allow-same-origin allow-scripts allow-popups allow-forms";
  1488. iframe.style.cssText = 'margin:0!important;padding:0!important;visibility:hidden!important;';
  1489. iframe.addEventListener("load", e=>{
  1490. let waitTime=500,checkEval;
  1491. if(ruleParser.curSiteRule.wait){
  1492. if(isNaN(ruleParser.curSiteRule.wait)){
  1493. checkEval=Function("doc",'"use strict";' + ruleParser.curSiteRule.wait);
  1494. }else{
  1495. waitTime=ruleParser.curSiteRule.wait;
  1496. }
  1497. }
  1498. setTimeout(()=>{
  1499. let tryTimes=0;
  1500. function checkIframe(){
  1501. try{
  1502. let doc=iframe.contentDocument || iframe.contentWindow.document;
  1503. let eles=ruleParser.getPageElement(doc, iframe.contentWindow);
  1504. if(eles && eles.length>0 && (!checkEval || checkEval(doc))){
  1505. callback(doc, eles);
  1506. }else if(tryTimes++ < 10){
  1507. setTimeout(()=>{
  1508. checkIframe();
  1509. },waitTime);
  1510. return;
  1511. }else{
  1512. if(failFromIframe++ > 2){
  1513. failFromIframe=0;
  1514. debug("Stop as failFromIframe");
  1515. isPause=true;
  1516. callback(false, false);
  1517. }else{
  1518. callback(false, false);
  1519. }
  1520. }
  1521. }catch(e){
  1522. debug("Stop as cors");
  1523. isPause=true;
  1524. callback(false, false);
  1525. }
  1526. document.body.removeChild(iframe);
  1527. }
  1528. checkIframe();
  1529. },waitTime);
  1530. });
  1531. iframe.src=url;
  1532. document.body.appendChild(iframe);
  1533. }
  1534.  
  1535. function initPage(){
  1536. ruleParser.initPage(()=>{
  1537. initListener();
  1538. nextPage();
  1539. });
  1540. }
  1541.  
  1542. function initView(){
  1543. _GM_addStyle(`
  1544. .pagetual_pageBar.stop {
  1545. -webkit-filter: invert(100%);
  1546. filter: invert(100%);
  1547. opacity: 1!important;
  1548. }
  1549. .pagetual_pageBar.hide {
  1550. display: none!important;
  1551. }
  1552. .pagetual_pageBar:hover {
  1553. opacity: 1!important;
  1554. }
  1555. .pagetual_pageBar span {
  1556. vertical-align: super;
  1557. }
  1558.  
  1559. .pagetual_pageBar span>svg:hover {
  1560. animation: touhouAni 1s infinite;
  1561. }
  1562.  
  1563. @keyframes touhouAni{
  1564. from {transform: rotate(0deg) scale3d(1.2, 1.2, 1.2);}
  1565. to {transform: rotate(360deg);}
  1566. }
  1567. @-webkit-keyframes touhouAni{
  1568. from {transform: rotate(0deg) scale3d(1.2, 1.2, 1.2);}
  1569. to {transform: rotate(360deg);}
  1570. }
  1571. `);
  1572. pageBarStyle=`opacity:${rulesData.opacity};display:${rulesData.opacity==0?"none":"block"};padding:0;box-shadow: 0px 0px 10px 0px #000000aa;border-radius: 20px;background-color: rgb(240 240 240 / 80%);visibility: visible; position: initial; width: auto; height: 30px; float: none; clear: both; margin: 5px auto; text-align: center;`;
  1573. }
  1574. var loading=document.createElement("div");
  1575. loading.className="pagetual_loading";
  1576. loading.style.cssText="display:none;cy: initial;d: initial;dominant-baseline: initial;empty-cells: initial;fill: initial;fill-opacity: initial;fill-rule: initial;filter: initial;flex: initial;flex-flow: initial;float: initial;flood-color: initial;flood-opacity: initial;grid: initial;grid-area: initial;height: initial;hyphens: initial;image-orientation: initial;image-rendering: initial;inline-size: initial;inset-block: initial;inset-inline: initial;isolation: initial;letter-spacing: initial;lighting-color: initial;line-break: initial;list-style: initial;margin-block: initial;margin: 0px auto;margin-inline: initial;marker: initial;mask: initial;mask-type: initial;max-block-size: initial;max-height: initial;max-inline-size: initial;max-width: initial;min-block-size: initial;min-height: initial;min-inline-size: initial;min-width: initial;mix-blend-mode: initial;object-fit: initial;object-position: initial;offset: initial;opacity: initial;order: initial;origin-trial-test-property: initial;orphans: initial;outline: initial;outline-offset: initial;overflow-anchor: initial;overflow-clip-margin: initial;overflow-wrap: initial;overflow: initial;overscroll-behavior-block: initial;overscroll-behavior-inline: initial;overscroll-behavior: initial;padding-block: initial;padding: initial;padding-inline: initial;page: initial;page-orientation: initial;paint-order: initial;perspective: initial;perspective-origin: initial;pointer-events: initial;position: initial;quotes: initial;r: initial;resize: initial;ruby-position: initial;rx: initial;ry: initial;scroll-behavior: initial;scroll-margin-block: initial;scroll-margin: initial;scroll-margin-inline: initial;scroll-padding-block: initial;scroll-padding: initial;scroll-padding-inline: initial;scroll-snap-align: initial;scroll-snap-stop: initial;scroll-snap-type: initial;scrollbar-gutter: initial;shape-image-threshold: initial;shape-margin: initial;shape-outside: initial;shape-rendering: initial;size: initial;speak: initial;stop-color: initial;stop-opacity: initial;stroke: initial;stroke-dasharray: initial;stroke-dashoffset: initial;stroke-linecap: initial;stroke-linejoin: initial;stroke-miterlimit: initial;stroke-opacity: initial;stroke-width: initial;tab-size: initial;table-layout: initial;text-align: initial;text-align-last: initial;text-anchor: initial;text-combine-upright: initial;text-decoration: initial;text-decoration-skip-ink: initial;text-indent: initial;text-overflow: initial;text-shadow: initial;text-size-adjust: initial;text-transform: initial;text-underline-offset: initial;text-underline-position: initial;touch-action: initial;transform: initial;transform-box: initial;transform-origin: initial;transform-style: initial;transition: initial;user-select: initial;vector-effect: initial;vertical-align: initial;visibility: initial;border-spacing: initial;-webkit-border-image: initial;-webkit-box-align: initial;-webkit-box-decoration-break: initial;-webkit-box-direction: initial;-webkit-box-flex: initial;-webkit-box-ordinal-group: initial;-webkit-box-orient: initial;-webkit-box-pack: initial;-webkit-box-reflect: initial;-webkit-highlight: initial;-webkit-hyphenate-character: initial;-webkit-line-break: initial;-webkit-line-clamp: initial;-webkit-mask-box-image: initial;-webkit-mask: initial;-webkit-mask-composite: initial;-webkit-perspective-origin-x: initial;-webkit-perspective-origin-y: initial;-webkit-print-color-adjust: initial;-webkit-rtl-ordering: initial;-webkit-ruby-position: initial;-webkit-tap-highlight-color: initial;-webkit-text-combine: initial;-webkit-text-decorations-in-effect: initial;-webkit-text-emphasis: initial;-webkit-text-emphasis-position: initial;-webkit-text-fill-color: initial;-webkit-text-security: initial;-webkit-text-stroke: initial;-webkit-transform-origin-x: initial;-webkit-transform-origin-y: initial;-webkit-transform-origin-z: initial;-webkit-user-drag: initial;-webkit-user-modify: initial;white-space: initial;widows: initial;width: initial;will-change: initial;word-break: initial;word-spacing: initial;x: initial;y: initial;z-index: 2147483647;";
  1577. loading.innerHTML=`<p style=" display: block; position: initial; margin: auto auto 5px auto; shape-rendering: auto; vertical-align: middle; visibility: visible; width: initial; height: initial; text-align: center; color: #6e6e6e; ">${i18n("loadingText")}</p><svg width="120" height="30" viewBox="0 0 120 30" fill="#000000A0" style="display: block;position: initial;margin: auto;shape-rendering: auto;vertical-align: middle;visibility: visible;width: initial;height: initial;"><circle cx="15" cy="15" r="15"><animate attributeName="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcMode="linear" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcMode="linear" repeatCount="indefinite"></animate></circle><circle cx="60" cy="15" r="9" fill-opacity="0.3"><animate attributeName="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcMode="linear" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcMode="linear" repeatCount="indefinite"></animate></circle><circle cx="105" cy="15" r="15"><animate attributeName="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcMode="linear" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcMode="linear" repeatCount="indefinite"></animate></circle></svg>`;
  1578. document.body.appendChild(loading);
  1579.  
  1580. var upSvg=`<svg style="position:absolute;cursor: pointer;margin: 0 -45px;width: 30px;height: 30px;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6364"><path d="M296 440c-44.1 0-80 35.9-80 80s35.9 80 80 80 80-35.9 80-80-35.9-80-80-80z" fill="#604b4a" p-id="6365"></path><path d="M960 512c0-247-201-448-448-448S64 265 64 512c0 1.8 0.1 3.5 0.1 5.3 0 0.9-0.1 1.8-0.1 2.7h0.2C68.5 763.3 267.7 960 512 960c236.2 0 430.1-183.7 446.7-415.7 0.1-0.8 0.1-1.6 0.2-2.3 0.4-4.6 0.5-9.3 0.7-13.9 0.1-2.7 0.4-5.3 0.4-8h-0.2c0-2.8 0.2-5.4 0.2-8.1z m-152 8c0 44.1-35.9 80-80 80s-80-35.9-80-80 35.9-80 80-80 80 35.9 80 80zM512 928C284.4 928 99 744.3 96.1 517.3 97.6 408.3 186.6 320 296 320c110.3 0 200 89.7 200 200 0 127.9 104.1 232 232 232 62.9 0 119.9-25.2 161.7-66-66 142.7-210.4 242-377.7 242z" fill="#604b4a" p-id="6366"></path></svg>`;
  1581. var downSvg=`<svg style="position:absolute;cursor: pointer;margin: 0 15px;width: 30px;height: 30px;vertical-align: middle;fill: currentColor;overflow: hidden;transform: rotate(180deg);" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6364"><path d="M296 440c-44.1 0-80 35.9-80 80s35.9 80 80 80 80-35.9 80-80-35.9-80-80-80z" fill="#604b4a" p-id="6365"></path><path d="M960 512c0-247-201-448-448-448S64 265 64 512c0 1.8 0.1 3.5 0.1 5.3 0 0.9-0.1 1.8-0.1 2.7h0.2C68.5 763.3 267.7 960 512 960c236.2 0 430.1-183.7 446.7-415.7 0.1-0.8 0.1-1.6 0.2-2.3 0.4-4.6 0.5-9.3 0.7-13.9 0.1-2.7 0.4-5.3 0.4-8h-0.2c0-2.8 0.2-5.4 0.2-8.1z m-152 8c0 44.1-35.9 80-80 80s-80-35.9-80-80 35.9-80 80-80 80 35.9 80 80zM512 928C284.4 928 99 744.3 96.1 517.3 97.6 408.3 186.6 320 296 320c110.3 0 200 89.7 200 200 0 127.9 104.1 232 232 232 62.9 0 119.9-25.2 161.7-66-66 142.7-210.4 242-377.7 242z" fill="#604b4a" p-id="6366"></path></svg>`;
  1582. var pageBarStyle;
  1583. var initStyle=`right: unset;left: unset;top: unset;bottom: unset;inset: unset;clear: both;cy: initial;d: initial;dominant-baseline: initial;empty-cells: initial;fill: initial;fill-opacity: initial;fill-rule: initial;filter: initial;flex: initial;flex-flow: initial;float: initial;flood-color: initial;flood-opacity: initial;grid: initial;grid-area: initial;height: initial;hyphens: initial;image-orientation: initial;image-rendering: initial;inline-size: initial;inset-block: initial;inset-inline: initial;isolation: initial;letter-spacing: initial;lighting-color: initial;line-break: initial;list-style: initial;margin-block: initial;margin: 0px auto;margin-inline: initial;marker: initial;mask: initial;mask-type: initial;max-block-size: initial;max-height: initial;max-inline-size: initial;max-width: initial;min-block-size: initial;min-height: initial;min-inline-size: initial;min-width: initial;mix-blend-mode: initial;object-fit: initial;object-position: initial;offset: initial;opacity: initial;order: initial;orphans: initial;outline: initial;outline-offset: initial;overflow-anchor: initial;overflow-clip-margin: initial;overflow-wrap: initial;overflow: initial;overscroll-behavior-block: initial;overscroll-behavior-inline: initial;overscroll-behavior: initial;padding-block: initial;padding: initial;padding-inline: initial;page: initial;page-orientation: initial;paint-order: initial;perspective: initial;perspective-origin: initial;pointer-events: initial;position: initial;quotes: initial;r: initial;resize: initial;ruby-position: initial;rx: initial;ry: initial;scroll-behavior: initial;scroll-margin-block: initial;scroll-margin: initial;scroll-margin-inline: initial;scroll-padding-block: initial;scroll-padding: initial;scroll-padding-inline: initial;scroll-snap-align: initial;scroll-snap-stop: initial;scroll-snap-type: initial;scrollbar-gutter: initial;shape-image-threshold: initial;shape-margin: initial;shape-outside: initial;shape-rendering: initial;size: initial;speak: initial;stop-color: initial;stop-opacity: initial;stroke: initial;stroke-dasharray: initial;stroke-dashoffset: initial;stroke-linecap: initial;stroke-linejoin: initial;stroke-miterlimit: initial;stroke-opacity: initial;stroke-width: initial;tab-size: initial;table-layout: initial;text-align: initial;text-align-last: initial;text-anchor: initial;text-combine-upright: initial;text-decoration: initial;text-decoration-skip-ink: initial;text-indent: initial;text-overflow: initial;text-shadow: initial;text-size-adjust: initial;text-transform: initial;text-underline-offset: initial;text-underline-position: initial;touch-action: initial;transform: initial;transform-box: initial;transform-origin: initial;transform-style: initial;transition: initial;user-select: initial;vector-effect: initial;vertical-align: initial;visibility: initial;border-spacing: initial;-webkit-border-image: initial;-webkit-box-align: initial;-webkit-box-decoration-break: initial;-webkit-box-direction: initial;-webkit-box-flex: initial;-webkit-box-ordinal-group: initial;-webkit-box-orient: initial;-webkit-box-pack: initial;-webkit-box-reflect: initial;-webkit-highlight: initial;-webkit-hyphenate-character: initial;-webkit-line-break: initial;-webkit-line-clamp: initial;-webkit-mask-box-image: initial;-webkit-mask: initial;-webkit-mask-composite: initial;-webkit-perspective-origin-x: initial;-webkit-perspective-origin-y: initial;-webkit-print-color-adjust: initial;-webkit-rtl-ordering: initial;-webkit-ruby-position: initial;-webkit-tap-highlight-color: initial;-webkit-text-combine: initial;-webkit-text-decorations-in-effect: initial;-webkit-text-emphasis: initial;-webkit-text-emphasis-position: initial;-webkit-text-fill-color: initial;-webkit-text-security: initial;-webkit-text-stroke: initial;-webkit-transform-origin-x: initial;-webkit-transform-origin-y: initial;-webkit-transform-origin-z: initial;-webkit-user-drag: initial;-webkit-user-modify: initial;white-space: initial;widows: initial;width: initial;will-change: initial;word-break: initial;word-spacing: initial;x: initial;y: initial;`;
  1584. var pageTextStyle=`line-height: 30px;text-decoration: none;user-select: none;visibility: visible;position: initial;width: auto;height: auto;float: none;clear: both;margin: 0px auto;text-align: center;display: inline;font-weight: bold;font-style: normal;font-size: 16px;letter-spacing: initial;vertical-align: super;color: rgb(85, 85, 95);`;
  1585.  
  1586. var isPause=false,isLoading=false,curPage=1,forceState=0,bottomGap=1000;
  1587.  
  1588. function changeStop(stop, hide){
  1589. isPause=stop;
  1590. [].forEach.call(document.querySelectorAll(".pagetual_pageBar"), bar=>{
  1591. if(isPause){
  1592. bar.classList.add("stop");
  1593. if(hide)bar.classList.add("hide");
  1594. }else{
  1595. bar.classList.remove("stop");
  1596. if(hide)bar.classList.remove("hide");
  1597. }
  1598. });
  1599. }
  1600.  
  1601. function isInViewPort(element) {
  1602. if(!element.parentNode)return false;
  1603. if(_unsafeWindow.getComputedStyle(element).display=="none")return false;
  1604. const viewWidth = window.innerWidth || document.documentElement.clientWidth;
  1605. const viewHeight = window.innerHeight || document.documentElement.clientHeight;
  1606. const {
  1607. top,
  1608. right,
  1609. bottom,
  1610. left,
  1611. } = element.getBoundingClientRect();
  1612.  
  1613. return (
  1614. top >= 0 &&
  1615. left >= 0 &&
  1616. right <= viewWidth &&
  1617. bottom <= viewHeight
  1618. );
  1619. }
  1620.  
  1621. function initListener(){
  1622. var urlChanged=false;
  1623. var _wr = function(type) {
  1624. var orig = history[type];
  1625. return function() {
  1626. var rv = orig.apply(this, arguments);
  1627. var e = new Event(type);
  1628. e.arguments = arguments;
  1629. window.dispatchEvent(e);
  1630. return rv;
  1631. };
  1632. };
  1633. history.pushState = _wr('pushState');
  1634. window.addEventListener('pushState', function(e) {
  1635. urlChanged=true;
  1636. setTimeout(()=>{
  1637. if(location.href==configPage){
  1638. location.reload();
  1639. }
  1640. },1);
  1641. });
  1642. let loadmoreBtn=getLoadMore(document),loading=true;
  1643. if(loadmoreBtn){
  1644. //emuClick(loadmoreBtn);
  1645. setTimeout(()=>{loading=false},500);
  1646. }
  1647. document.addEventListener('scroll', e=>{
  1648. if(urlChanged){
  1649. ruleParser.initPage(()=>{});
  1650. initView();
  1651. urlChanged=false;
  1652. isPause=false;
  1653. }
  1654. if(!loading){
  1655. loading=true;
  1656. if(!loadmoreBtn || !loadmoreBtn.parentNode){
  1657. loadmoreBtn=getLoadMore(document);
  1658. }
  1659. if(loadmoreBtn){
  1660. loading=false;
  1661. if(isInViewPort(loadmoreBtn)){
  1662. emuClick(loadmoreBtn);
  1663. }
  1664. }else{
  1665. setTimeout(()=>{loading=false},500);
  1666. }
  1667. }
  1668. setTimeout(()=>{
  1669. if(!isPause && !isLoading){
  1670. let scrolly=window.scrollY;
  1671. let windowHeight=window.innerHeight;
  1672. let scrollH=Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
  1673. if(scrollH-scrolly-windowHeight<bottomGap){
  1674. nextPage();
  1675. }
  1676. }
  1677. },100);
  1678. }, true);
  1679. document.addEventListener('dblclick', e=>{
  1680. if(rulesData.dbClick2Stop){
  1681. setTimeout(()=>{
  1682. changeStop(!isPause, rulesData.hideBar);
  1683. if(!isPause){
  1684. let scrolly=window.scrollY;
  1685. let windowHeight=window.innerHeight;
  1686. let scrollH=Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
  1687. if(scrollH-scrolly-windowHeight<bottomGap){
  1688. nextPage();
  1689. }
  1690. }
  1691. },200);
  1692. }
  1693. });
  1694. }
  1695.  
  1696. function getLoadMore(doc){
  1697. let btnSel=ruleParser.curSiteRule.loadMore||".LoadMore";
  1698. let loadmoreBtn=doc.querySelector(btnSel);
  1699. if(!loadmoreBtn){
  1700. let buttons=doc.querySelectorAll("input,button,a"),loadmoreReg=/^\s*(加载更多|加載更多|load\s*more|もっと読み込む)\s*$/i;
  1701. for(let i=0;i<buttons.length;i++){
  1702. let button=buttons[i];
  1703. if(button && loadmoreReg.test(button.innerText)){
  1704. loadmoreBtn=button;
  1705. break;
  1706. }
  1707. }
  1708. }
  1709. return loadmoreBtn;
  1710. }
  1711.  
  1712. function createPageBar(url){
  1713. let insert=ruleParser.getInsert();
  1714. if(!insert || !insert.parentNode)return;
  1715. curPage++;
  1716. let inTable=insert.tagName=="TR" ||
  1717. (insert.previousElementSibling && insert.previousElementSibling.tagName=="TR") ||
  1718. insert.tagName=="TBODY" || (insert.previousElementSibling && insert.previousElementSibling.tagName=="TBODY");
  1719. let inLi=insert.tagName=="LI" || (insert.previousElementSibling && insert.previousElementSibling.tagName=="LI");
  1720. let pageBar=document.createElement(inTable?"tr":"div");
  1721. let upSpan=document.createElement("span");
  1722. let downSpan=document.createElement("span");
  1723. let pageText=document.createElement("a");
  1724. pageBar.className="pagetual_pageBar";
  1725. pageBar.id="pagetual_pageBar";
  1726. if(isPause){
  1727. pageBar.classList.add("stop");
  1728. }
  1729. pageBar.style.cssText=pageBarStyle;
  1730. pageBar.title=i18n(isPause?"enable":"disable");
  1731. upSpan.innerHTML=upSvg;
  1732. upSpan.title=i18n("toTop");
  1733. downSpan.innerHTML=downSvg;
  1734. downSpan.title=i18n("toBottom");
  1735. upSpan.style.cssText=initStyle;
  1736. downSpan.style.cssText=initStyle;
  1737. pageText.href=url;
  1738. pageText.style=pageTextStyle;
  1739. pageText.innerHTML="Page "+curPage;
  1740. pageText.title=i18n("current");
  1741. pageBar.appendChild(upSpan);
  1742. pageBar.appendChild(pageText);
  1743. pageBar.appendChild(downSpan);
  1744. if(inTable){
  1745. let example=(insert.tagName=="TR" || insert.tagName=="TBODY")?insert:insert.previousElementSibling;
  1746. let tdNum=0;
  1747. [].forEach.call(example.querySelectorAll("td,th"), td=>{
  1748. tdNum+=td.colSpan||1;
  1749. });
  1750. pageBar.style.display="table-row";
  1751. pageBar.style.backgroundColor="unset";
  1752. let td=document.createElement("td");
  1753. td.style.backgroundColor="rgb(240 240 240 / 80%)";
  1754. td.style.borderRadius="20px";
  1755. td.colSpan=tdNum||1;
  1756. td.style.padding="0 0";
  1757. td.style.textAlign="center";
  1758. td.appendChild(upSpan);
  1759. td.appendChild(pageText);
  1760. td.appendChild(downSpan);
  1761. pageBar.appendChild(td);
  1762. }
  1763.  
  1764. upSpan.addEventListener("click", e=>{
  1765. //changeStop(true);
  1766. //pageBar.title=i18n(isPause?"enable":"disable");
  1767. document.body.scrollTop=0;
  1768. document.documentElement.scrollTop=0;
  1769. e.preventDefault();
  1770. e.stopPropagation();
  1771. });
  1772. downSpan.addEventListener("click", e=>{
  1773. changeStop(true);
  1774. pageBar.title=i18n(isPause?"enable":"disable");
  1775. document.body.scrollTop=9999999;
  1776. document.documentElement.scrollTop=9999999;
  1777. e.preventDefault();
  1778. e.stopPropagation();
  1779. });
  1780. pageBar.addEventListener("click", e=>{
  1781. changeStop(!isPause);
  1782. pageBar.title=i18n(isPause?"enable":"disable");
  1783. });
  1784. pageText.addEventListener("click", e=>{
  1785. e.stopPropagation();
  1786. });
  1787. let parentStyle=_unsafeWindow.getComputedStyle(insert.parentNode);
  1788. pageBar.style.width=parseInt(parentStyle.width)*.99-parseInt(parentStyle.paddingLeft)-parseInt(parentStyle.paddingRight)+"px";
  1789. if(inLi){
  1790. pageBar.style.width="90%";
  1791. pageBar.style.minWidth="150px";
  1792. pageBar.style.display="inline-block";
  1793. let line=document.createElement("li");
  1794. line.style.textAlign="center";
  1795. line.appendChild(pageBar);
  1796. if(ruleParser.curSiteRule.insertPos==2){
  1797. insert.appendChild(line);
  1798. }else{
  1799. insert.parentNode.insertBefore(line, insert);
  1800. }
  1801. }else{
  1802. if(ruleParser.curSiteRule.insertPos==2){
  1803. insert.appendChild(pageBar);
  1804. }else{
  1805. insert.parentNode.insertBefore(pageBar, insert);
  1806. }
  1807. }
  1808.  
  1809. let scrollH=Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
  1810. let actualTop = pageBar.offsetTop;
  1811. let current = pageBar.parentNode.offsetParent;
  1812. while (current !== null){
  1813. actualTop += current.offsetTop;
  1814. current = current.offsetParent;
  1815. }
  1816. bottomGap=scrollH-actualTop+800;
  1817. return pageBar;
  1818. }
  1819.  
  1820. function emuClick(btn){
  1821. if(!PointerEvent)return btn.click();
  1822. let eventParam={
  1823. isTrusted: true,
  1824. altKey: false,
  1825. azimuthAngle: 0,
  1826. bubbles: true,
  1827. button: 0,
  1828. buttons: 0,
  1829. clientX: 1,
  1830. clientY: 1,
  1831. cancelBubble: false,
  1832. cancelable: true,
  1833. composed: true,
  1834. ctrlKey: false,
  1835. defaultPrevented: false,
  1836. detail: 1,
  1837. eventPhase: 2,
  1838. fromElement: null,
  1839. height: 1,
  1840. isPrimary: false,
  1841. metaKey: false,
  1842. pointerId: 1,
  1843. pointerType: "mouse",
  1844. pressure: 0,
  1845. relatedTarget: null,
  1846. returnValue: true,
  1847. shiftKey: false,
  1848. toElement: null,
  1849. twist: 0,
  1850. type: "click",
  1851. which: 1
  1852. };
  1853. var mouseclick = new PointerEvent("click",eventParam);
  1854. btn.dispatchEvent(mouseclick);
  1855. }
  1856.  
  1857. var emuIframe;
  1858. function emuPage(callback){
  1859. let orgPage,curPage,iframeDoc,times=0,loadmoreBtn,loadmoreEnd=false,waitTimes=10;
  1860. function checkPage(){
  1861. if(isPause)return;
  1862. try{
  1863. iframeDoc=emuIframe.contentDocument || emuIframe.contentWindow.document;
  1864. }catch(e){
  1865. debug("Stop as cors");
  1866. isPause=true;
  1867. callback(false, false);
  1868. return;
  1869. }
  1870.  
  1871. let nextLink=ruleParser.getNextLink(iframeDoc);
  1872. let waitTime=500,checkEval;
  1873. if(ruleParser.curSiteRule.wait){
  1874. if(isNaN(ruleParser.curSiteRule.wait)){
  1875. checkEval=Function("doc",'"use strict";' + ruleParser.curSiteRule.wait);
  1876. }else{
  1877. waitTime=ruleParser.curSiteRule.wait;
  1878. }
  1879. }
  1880.  
  1881. if(!orgPage){
  1882. if(!loadmoreEnd){
  1883. loadmoreBtn=getLoadMore(iframeDoc);
  1884. if(loadmoreBtn){
  1885. emuClick(loadmoreBtn);
  1886. let intv=setInterval(()=>{
  1887. loadmoreBtn=getLoadMore(iframeDoc);
  1888. if(!loadmoreBtn || !loadmoreBtn.parentNode || !isVisible(loadmoreBtn, iframeDoc.defaultView)){
  1889. clearInterval(intv);
  1890. loadmoreEnd=true;
  1891. setTimeout(()=>{
  1892. checkPage();
  1893. },500);
  1894. }else{
  1895. emuClick(loadmoreBtn);
  1896. }
  1897. },200);
  1898. return;
  1899. }else{
  1900. loadmoreEnd=true;
  1901. }
  1902. }
  1903. let pageEle=ruleParser.getPageElement(iframeDoc, iframeDoc.defaultView, true);
  1904. if(!nextLink || !pageEle || (checkEval && !checkEval(iframeDoc))){
  1905. if(ruleParser.curSiteRule.wait && waitTimes-->0){
  1906. setTimeout(()=>{
  1907. checkPage();
  1908. },waitTime);
  1909. return;
  1910. }
  1911. }
  1912. orgPage=pageEle;
  1913. if(!orgPage || orgPage.length==0){
  1914. debug("Stop as no page when emu");
  1915. isPause=true;
  1916. callback(false, false);
  1917. return;
  1918. }
  1919. orgPage=orgPage[parseInt(orgPage.length/2)];
  1920. if(orgPage && orgPage.tagName=="UL")orgPage=orgPage.children[0];
  1921. if(orgPage && nextLink){
  1922. if(!isVisible(nextLink, iframeDoc.defaultView)){
  1923. debug("Stop as next hide when emu");
  1924. isPause=true;
  1925. callback(false, false);
  1926. }else{
  1927. emuClick(nextLink);
  1928. setTimeout(()=>{
  1929. checkPage();
  1930. },500);
  1931. }
  1932. }else{
  1933. debug("Stop as no next when emu");
  1934. isPause=true;
  1935. callback(false, false);
  1936. }
  1937. return;
  1938. }
  1939. if(times++ > 20){
  1940. //emuClick(nextLink);
  1941. debug("Stop as timeout when emu");
  1942. isPause=true;
  1943. callback(false, false);
  1944. return;
  1945. }
  1946. iframeDoc.body.scrollTop=9999999;
  1947. iframeDoc.documentElement.scrollTop=9999999;
  1948. let eles=ruleParser.getPageElement(iframeDoc, iframeDoc.defaultView, true);
  1949. if(!eles || eles.length==0 || orgPage == eles[parseInt(eles.length/2)] || (checkEval && !checkEval(iframeDoc))){
  1950. setTimeout(()=>{
  1951. checkPage();
  1952. },waitTime);
  1953. }else{
  1954. callback(iframeDoc, eles);
  1955. }
  1956. }
  1957. if(!emuIframe){
  1958. emuIframe = document.createElement('iframe');
  1959. emuIframe.name = 'pagetual-iframe';
  1960. //emuIframe.sandbox="allow-same-origin allow-scripts allow-popups allow-forms";
  1961. emuIframe.width = '100%';
  1962. emuIframe.height = '0';
  1963. emuIframe.frameBorder = '0';
  1964. emuIframe.style.cssText = 'margin:0!important;padding:0!important;visibility:hidden!important;';
  1965. emuIframe.addEventListener("load", e=>{
  1966. setTimeout(()=>{
  1967. checkPage();
  1968. },300);
  1969. });
  1970. emuIframe.src=location.href;
  1971. document.body.appendChild(emuIframe);
  1972. }else{
  1973. checkPage();
  1974. }
  1975. }
  1976.  
  1977. function forceIframe(url, callback){
  1978. let curIframe = document.createElement('iframe');
  1979. curIframe.name = 'pagetual-iframe';
  1980. curIframe.sandbox="allow-same-origin allow-scripts allow-popups allow-forms";
  1981. curIframe.frameBorder = '0';
  1982. curIframe.scrolling="no";
  1983. curIframe.style.cssText = 'display: block; visibility: visible; float: none; clear: both; width: 100%;height:0;background: initial; border: 0px; border-radius: 0px; margin: 0px 0px 2rem; padding: 0px; z-index: 2147483647;';
  1984. curIframe.addEventListener("load", e=>{
  1985. let iframeDoc;
  1986. try{
  1987. iframeDoc=curIframe.contentDocument || curIframe.contentWindow.document;
  1988. }catch(e){
  1989. debug("Stop as cors");
  1990. isPause=true;
  1991. callback(false, false);
  1992. return;
  1993. }
  1994. ruleParser.insertPage(iframeDoc, [], url, null, true);
  1995. callback(curIframe, true);
  1996. curIframe.style.height=iframeDoc.body.scrollHeight+"px";
  1997. curIframe.style.width=iframeDoc.body.scrollWidth+"px";
  1998. setTimeout(()=>{
  1999. curIframe.style.height=iframeDoc.body.scrollHeight+"px";
  2000. curIframe.style.width=iframeDoc.body.scrollWidth+"px";
  2001. },300);
  2002. });
  2003. curIframe.src=url;
  2004. let insert=ruleParser.getInsert();
  2005. document.body.insertBefore(curIframe, loading);
  2006. return curIframe;
  2007. }
  2008.  
  2009. function nextPage(){
  2010. if(isPause || isLoading)return;
  2011. let nextLink=ruleParser.nextLinkHref;
  2012. if(!nextLink)return;
  2013. let insert=ruleParser.getInsert();
  2014. if(insert){
  2015. let isJs=/^(javascript|#)/.test(nextLink.replace(location.href,""));
  2016. if(location.protocol=="https:" && /^http:/.test(nextLink)){
  2017. nextLink=nextLink.replace(/^http/,"https");
  2018. }
  2019. isLoading=true;
  2020. loading.style.display="";
  2021. if(ruleParser.curSiteRule.pageElementByJs){
  2022. var over=ele=>{
  2023. isLoading=false;
  2024. loading.style.display="none";
  2025. if(ele){
  2026. createPageBar(nextLink);
  2027. ruleParser.insertPage(null, ele, nextLink, null, true);
  2028. }else{
  2029. debug("Stop as no page when get by js");
  2030. isPause=true;
  2031. }
  2032. };
  2033. try{
  2034. Function("over",'"use strict";' + ruleParser.curSiteRule.pageElementByJs)(over);
  2035. }catch(e){}
  2036. }else if(ruleParser.curSiteRule.action==1 && !isJs){
  2037. requestFromIframe(nextLink, (doc, eles)=>{
  2038. isLoading=false;
  2039. loading.style.display="none";
  2040. if(eles){
  2041. createPageBar(nextLink);
  2042. ruleParser.insertPage(doc, eles, nextLink, null, true);
  2043. }
  2044. });
  2045. }else if(forceState==2 && !isJs){
  2046. forceIframe(nextLink, (iframe, eles)=>{
  2047. isLoading=false;
  2048. loading.style.display="none";
  2049. let pageBar=createPageBar(nextLink);
  2050. iframe.parentNode.insertBefore(pageBar, iframe);
  2051. });
  2052. }else{
  2053. if(!isJs){
  2054. requestDoc(nextLink, (eles)=>{
  2055. isLoading=false;
  2056. loading.style.display="none";
  2057. if(eles){
  2058. createPageBar(nextLink);
  2059. }
  2060. });
  2061. }else{
  2062. emuPage((doc, eles)=>{
  2063. isLoading=false;
  2064. loading.style.display="none";
  2065. if(eles){
  2066. createPageBar(nextLink);
  2067. ruleParser.insertPage(doc, eles, "", null, true);
  2068. }
  2069. });
  2070. }
  2071. }
  2072. }
  2073. }
  2074.  
  2075. function init(){
  2076. initRules(()=>{
  2077. initView();
  2078. initPage();
  2079. });
  2080. }
  2081. setTimeout(()=>{
  2082. init();
  2083. },300);
  2084. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址