东方永页机

自动翻页

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

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