东方永页机

终极自动翻页 - 加载并拼接下一分页内容至当前页尾,智能适配任意网页

当前为 2024-07-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Pagetual
  3. // @name:zh-CN 东方永页机
  4. // @name:zh-TW 東方永頁機
  5. // @name:ja 東方永頁機
  6. // @name:ko 東方永頁機
  7. // @name:ru Pagetual
  8. // @name:de Pagetual
  9. // @name:es Pagetual
  10. // @name:fr Pagetual
  11. // @name:it Pagetual
  12. // @namespace hoothin
  13. // @version 1.9.37.82
  14. // @description Perpetual pages - powerful auto-pager script. Auto fetching next paginated web pages and inserting into current page for infinite scroll. Support thousands of web sites without any rule.
  15. // @description:zh-CN 终极自动翻页 - 加载并拼接下一分页内容至当前页尾,智能适配任意网页
  16. // @description:zh-TW 終極自動翻頁 - 加載並拼接下一分頁內容至當前頁尾,智能適配任意網頁
  17. // @description:ja Webページを自動で読み込み継ぎ足し表示を行うブラウザ拡張です、次のページ付けされた Web ページの自動読み込みと現在のページへの挿入 ルールなしで何千もの Web サイトをサポートします。
  18. // @description:ko 페이지가 매겨진 다음 웹 페이지를 자동으로 로드하고 현재 페이지에 삽입합니다. 규칙 없이 수천 개의 웹 사이트를 지원합니다.
  19. // @description:ru Автоматическая подгрузка следующих страниц и вставка их содержимого в текущую страницу. Поддерживает тысячи сайтов даже с настройками по умолчанию.
  20. // @description:de Automatisches Laden der nächsten paginierten Webseiten und Einfügen in die aktuelle Seite. Unterstützen Sie Tausende von Websites ohne Regeln.
  21. // @description:es Carga automática de las siguientes páginas web paginadas e inserción en la página actual. Admite miles de sitios web sin ninguna regla.
  22. // @description:fr Chargement automatique des pages Web paginées suivantes et insertion dans la page en cours. Prend en charge des milliers de sites Web sans aucune règle.
  23. // @description:it Caricamento automatico delle pagine Web impaginate successive e inserimento nella pagina corrente. Supporta migliaia di siti web senza alcuna regola.
  24. // @author hoothin
  25. // @license MPL-2.0
  26. // @match *://*/*
  27. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAdVBMVEUAAAD3VU33VU32VEz8U073VU32VU33VU32VUz0Uk/3VE32VU32VUz2VU32VU32VU32VU33VU33U0z2VU34Wkv3VE32VUz/mpj/nJj2VUz2VU32VE33VEz2VU32VU32VUz3VE32VEz3VE3/mZf2Vkz2VU3/mpilFFolAAAAJXRSTlMA3Lp/GvTBT5YQLuawZ/DOyZwlPQeKc21N04+FX1bqpm9DNoB4T68ePwAAAitJREFUWMPt1tuasiAUBuCFCG5Rs3QybTPV1/1f4v/3PDkyIojn8x5qBrI+ltAfh32/yysmBKvyXb+njb6bDL9kzTd5SzjDAsYT8nFoGSxYe6BVqoNDp2jFDit25BRgVUAODB4YWcETWVTwVNGiGN5iWtBgg4YMCpsoI38dNunmmWyxUTvbPwwbsYR0fIzZLQ0pTG8eieRmBLMmpdH9uimQEf6TNRnXXKLZHixpJtywLzOgMHtFCqdM64DahHRnOE1dsrekm9wr2WtLcAlpdHwcp1pAJySXYnERclzp4+v19jXdmcTvQUJtz+ZaI4i05/V/UGYrCxbaAsOYoNfIKEQxpqQuzCgJJJ/3f42O8ywEZuMVWi/8hODxGj3GW2b0udkbGULLDOjimAG0S3fLGlBnXQM9irG1CiQdVQi0dqQsOSDlyEEz7Vy9OxxfR71VCXsSB23jMrKJYZXSjw57sqgLn5Z0wolsOCz0RyJkyeYjgz7pwwVq20eboZwtVUl2EnN5gJ50dQZFdryATvABRTr/tJXkUMdaAK5pwtCapwtFLskguwuyMh/Sd9WChQ4sIvIUYSk3PYqQvCQlOC04IfN7PkdjOyRKWhdKXMmiAFt9i3sJ5jxoRuR0vqAghxxwHuqfQE5OHGDKOrwEnqs1DgAZ2e4Eev1d45TN7JfhrQLKgfwMFYAsvp33dXII073aVQLI2gN5S58lfmGnKKFtah7nkgnBZB7zlP7Y/QNiTM6sYNzawwAAAABJRU5ErkJggg==
  28. // @grant GM_xmlhttpRequest
  29. // @grant GM_registerMenuCommand
  30. // @grant GM_notification
  31. // @grant GM_getValue
  32. // @grant GM_setValue
  33. // @grant GM_addStyle
  34. // @grant GM_openInTab
  35. // @grant GM_deleteValue
  36. // @grant GM_info
  37. // @grant GM_setClipboard
  38. // @grant GM.xmlHttpRequest
  39. // @grant GM.registerMenuCommand
  40. // @grant GM.notification
  41. // @grant GM.getValue
  42. // @grant GM.setValue
  43. // @grant GM.addStyle
  44. // @grant GM.openInTab
  45. // @grant GM.deleteValue
  46. // @grant GM.info
  47. // @grant GM.setClipboard
  48. // @homepage https://github.com/hoothin/UserScripts/tree/master/Pagetual
  49. // @supportURL https://github.com/hoothin/UserScripts/issues
  50. // @connect wedata.net
  51. // @connect githubusercontent.com
  52. // @connect ghproxy.com
  53. // @connect hoothin.github.io
  54. // @run-at document-idle
  55. // @connect *
  56. // @contributionURL https://ko-fi.com/hoothin
  57. // @contributionAmount 1
  58. // ==/UserScript==
  59.  
  60. (function() {
  61. 'use strict';
  62. const pauseVideo = () => {
  63. setTimeout(() => {
  64. [].forEach.call(document.querySelectorAll("video"), video => {
  65. video.removeAttribute && video.removeAttribute("autoplay");
  66. video.pause && video.pause();
  67. });
  68. }, 1000);
  69. };
  70. if (window.name === 'pagetual-iframe' || (window.frameElement && window.frameElement.name === 'pagetual-iframe')) {
  71. [].forEach.call(document.querySelectorAll("iframe"), iframe => {
  72. iframe.name = 'pagetual-iframe';
  73. });
  74. var domloaded = function() {
  75. window.parent.postMessage('pagetual-iframe:DOMLoaded', '*');
  76. };
  77. if (window.opera) {
  78. document.addEventListener('DOMContentLoaded', domloaded, false);
  79. pauseVideo();
  80. } else {
  81. domloaded();
  82. if (document.readystate === 'complete') {
  83. pauseVideo();
  84. } else {
  85. window.addEventListener('load', () => {
  86. pauseVideo();
  87. }, false);
  88. }
  89. }
  90. if (getComputedStyle(document.documentElement).display === 'none') {
  91. document.documentElement.style.display = 'block';
  92. }
  93. if (document.body && getComputedStyle(document.body).display === 'none') {
  94. document.body.style.display = 'block';
  95. }
  96. return;
  97. }
  98.  
  99. if (window.top !== window.self) {
  100. try {
  101. if (window.self.innerWidth < 300 || window.self.innerHeight < 300) {
  102. return;
  103. }
  104. } catch(e) {
  105. return;
  106. }
  107. }
  108.  
  109. const noRuleTest = false;
  110. const lang = navigator.appName === "Netscape" ? navigator.language : navigator.userLanguage;
  111. const langData = [
  112. {
  113. // English translation update by github.com/https433, admin@abby0666.xyz.
  114. name: "English",
  115. match: ["en"],
  116. lang: {
  117. enableDebug: "Enable debug output to console.",
  118. updateNotification: "Notification after rules updated",
  119. disable: "Temporarily disable.",
  120. disableSite: "Toggle disabled state.",
  121. disableSiteTips: "Disabled on this site.",
  122. enableSiteTips: "Enabled on this site.",
  123. enable: "Enable automatic page turning.",
  124. toTop: "Back to Top.",
  125. toBottom: "Go to Bottom.",
  126. current: "Current Page.",
  127. forceIframe: "Force to join next page",
  128. cancelForceIframe: "Cancel Force join",
  129. configure: "Configure Pagetual",
  130. firstUpdate: "Click here to initialize the default rule list",
  131. update: "Update online rules",
  132. click2update: "Click to update rules from url now",
  133. loadNow: "Load next automatically",
  134. loadConfirm: "How many pages do you want to load? (0 means infinite)",
  135. noNext: "No next link found, please create a new rule",
  136. passSec: "Updated #t# seconds ago",
  137. passMin: "Updated #t# minutes ago",
  138. passHour: "Updated #t# hours ago",
  139. passDay: "Updated #t# days ago",
  140. cantDel: "Can't delete builtin rules",
  141. confirmDel: "Are you sure you want to delete this rule?",
  142. updateSucc: "Update succeeded",
  143. beginUpdate: "Begin update, wait a moment please",
  144. customUrls: "Import Pagetual or AutoPagerize rule url, one url per line.",
  145. customRules: "Input custom rules. <a href='#t#'>✍️Contribute rules</a>",
  146. save: "Save",
  147. loadingText: "Shojo Now Loading...",
  148. opacity: "Opacity",
  149. opacityPlaceholder: "0: hide spacer",
  150. hideBar: "Hide the pagnation spacer",
  151. hideBarButNoStop: "Hide but not stop",
  152. dbClick2Stop: "Double-click on the blank space to pause",
  153. sortTitle: "Sorting takes effect after the next rule update",
  154. autoRun: "Auto enable (blacklist mode)",
  155. autoLoadNum: "Amount for preload pages",
  156. turnRate: "Turn the next page when it's less than 【X】 times page height from the footer",
  157. inputPageNum: "Enter page number to jump",
  158. enableHistory: "Write browsing history after page turning",
  159. enableHistoryAfterInsert: "Write browsing history immediately after splicing, otherwise write after browsing",
  160. contentVisibility: "Automatically switch content-visibility to improve rendering performance",
  161. initRun: "Turn pages immediately after opening",
  162. preload: "Preload next page for speeding up",
  163. click2ImportRule: "Click to import base rules link, and then wait until the update is complete: ",
  164. forceAllBody: "Join full body of page?",
  165. openInNewTab: "Open urls of additions in new tab",
  166. importSucc: "Import complete",
  167. import: "Import",
  168. editCurrent: "Edit rule for current website.",
  169. editBlacklist: "Edit the url blacklist, one entry per line, Supports [?,*] wildcarding.",
  170. upBtnImg: "Icon of back to top",
  171. downBtnImg: "Icon of go to footer",
  172. sideControllerIcon: "Icon of sidebar",
  173. loadingTextTitle: "Loading.",
  174. dbClick2StopCtrl: "Ctrl key",
  175. dbClick2StopAlt: "Alt key",
  176. dbClick2StopShift: "Shift key",
  177. dbClick2StopMeta: "Meta key",
  178. dbClick2StopKey: "Shortcut key",
  179. pageElementCss: "Custom style for main page elements",
  180. customCss: "Custom complete css",
  181. firstAlert: "You have not imported the base rule, please select the appropriate rule to import",
  182. picker: "Pagetual page element picker",
  183. closePicker: "Close Pagetual picker",
  184. pickerPlaceholder: "Element selector, (Advanced users only, leave blank otherwise)",
  185. pickerCheck: "Check selector and copy",
  186. switchSelector: "Click to switch element",
  187. gotoEdit: "Go to edit rule with current selector",
  188. manualMode: "Disable splicing, manually advance next page using the right arrow key (or dispatch event 'pagetual.next')",
  189. clickMode: "Disable splicing, automatically click the next page when scrolling to the end of the page",
  190. pageBarMenu: "Click the center of the page bar to open the picker menu",
  191. nextSwitch: "Switch next link",
  192. arrowToScroll: "Press left arrow to scroll back and right arrow to advance page",
  193. sideController: "Display the paging control bar in the sidebar",
  194. sideControllerScroll: "Scroll toggle",
  195. sideControllerAlways: "Always show",
  196. hideLoadingIcon: "Hide loading animation",
  197. hideBarArrow: "Hide arrow for page bar",
  198. duplicate: "Duplicate Pagetual have been installed, check your script manager!",
  199. forceStateIframe: "Embed full page as iframe",
  200. forceStateDynamic: "Load dynamic content via iframe",
  201. forceStateDisable: "Disable page turning on this site",
  202. autoScrollRate: "Scroll speed (1~1000)",
  203. disableAutoScroll: "Stop Auto Scroll",
  204. enableAutoScroll: "Enable Auto Scroll",
  205. toggleAutoScroll: "Toggle Auto Scroll",
  206. ruleRequest: "Rule Request",
  207. page: "Page ",
  208. prevPage: "Prev page",
  209. nextPage: "Next page",
  210. errorRulesMustBeArray: "Rules must be an Array!",
  211. errorJson: "JSON error, Check again!",
  212. editSuccess: "Edit successfully",
  213. errorWrongUrl: "Wrong url, Check again!",
  214. errorAlreadyExists: "A rule already exists!",
  215. settingsSaved: "The settings are saved, refresh to view",
  216. iframe: "Forced split by iframe.",
  217. dynamic: "Dynamic loading.",
  218. reloadPage: "Edit completed, reload now?",
  219. copied: "Copied",
  220. noValidContent: "No valid content detected, a Captcha may be present",
  221. outOfDate: "The script is outdated, update to the latest version please.",
  222. hideBarTips: "Hide the pagination bar, toggle immersive experience",
  223. setConfigPage: "Set current page as the default configuration page",
  224. wedata2github: "Change the wedata address to the mirror address in the github repository",
  225. addOtherProp: "Add rule properties",
  226. addNextSelector: "Add selector content as nextLink",
  227. addPageSelector: "Add selector content as pageElement",
  228. propName: "Enter rule property name",
  229. propValue: "Enter rule property value",
  230. customFirst: "Ignore cache for local custom rules",
  231. rulesExample: "Rules Example",
  232. lastPage: "Reached the last page",
  233. lastPageTips: "Show tips when reaching the last page"
  234. }
  235. },
  236. {
  237. // Translated by SrKalopsia (srkalopsia@gmail.com).
  238. name: "Español",
  239. match: ["es", "es-ES"],
  240. lang: {
  241. enableDebug: "Habilitar salida de depuración",
  242. updateNotification: "Notificación después de actualizar las reglas",
  243. disable: "Desactivar",
  244. disableSite: "Alternar estado desactivado",
  245. disableSiteTips: "Desactivado en este sitio",
  246. enableSiteTips: "Activado en este sitio",
  247. enable: "Habilitar",
  248. toTop: "Ir al inicio",
  249. toBottom: "Ir al final",
  250. current: "Página actual",
  251. forceIframe: "Forzar para unirse a la siguiente página",
  252. cancelForceIframe: "Cancelar unión forzada",
  253. configure: "Configurar",
  254. firstUpdate: "Haga clic aquí para inicializar las reglas",
  255. update: "Actualizar reglas en línea",
  256. click2update: "Haga clic para actualizar las reglas desde la URL ahora",
  257. loadNow: "Cargar el siguiente automáticamente",
  258. loadConfirm: "¿Cuántas páginas desea cargar? (0 significa infinito)",
  259. noNext: "No se encontró el enlace siguiente, por favor cree una nueva regla",
  260. passSec: "Actualizado hace #t# segundos",
  261. passMin: "Actualizado hace #t# minutos",
  262. passHour: "Actualizado hace #t# horas",
  263. passDay: "Actualizado hace #t# días",
  264. cantDel: "No se pueden eliminar las reglas incorporadas",
  265. confirmDel: "¿Está seguro de que desea eliminar esta regla?",
  266. updateSucc: "Actualización exitosa",
  267. beginUpdate: "Comenzar actualización, espere un momento por favor",
  268. customUrls: "Importar URL de reglas de Pagetual o AutoPagerize, una URL por línea",
  269. customRules: "Introduzca reglas personalizadas. <a href='#t#'>✍️Contribuir reglas</a>",
  270. save: "Guardar",
  271. loadingText: "Shojo Cargando...",
  272. opacity: "Opacidad",
  273. opacityPlaceholder: "0: ocultar espaciador",
  274. hideBar: "Ocultar el espaciador de paginación",
  275. hideBarButNoStop: "Ocultar pero no detener",
  276. dbClick2Stop: "Haga doble clic en el espacio en blanco para pausar",
  277. sortTitle: "La ordenación surtirá efecto después de la próxima actualización de reglas",
  278. autoRun: "Habilitar automáticamente (modo lista negra)",
  279. autoLoadNum: "Cantidad de páginas para precargar",
  280. turnRate: "Pasar a la siguiente página cuando esté a menos de 【X】 veces la altura de la página desde el pie de página",
  281. inputPageNum: "Ingrese el número de página para saltar",
  282. enableHistory: "Escribir historial de navegación después de pasar la página",
  283. enableHistoryAfterInsert: "Escribir historial de navegación inmediatamente después de unir, de lo contrario escribir después de navegar",
  284. contentVisibility: "Cambiar automáticamente la visibilidad del contenido para mejorar el rendimiento de renderización",
  285. initRun: "Pasar páginas inmediatamente después de abrir",
  286. preload: "Precargar la siguiente página para acelerar",
  287. click2ImportRule: "Haga clic para importar el enlace de reglas base, luego espere hasta que la actualización esté completa: ",
  288. forceAllBody: "¿Unir el cuerpo completo de la página?",
  289. openInNewTab: "Abrir URLs de adiciones en una nueva pestaña",
  290. importSucc: "Importación completada",
  291. import: "Importar",
  292. editCurrent: "Editar regla para la actual",
  293. editBlacklist: "Editar URLs de la lista negra, una por línea, admite ? * para comodín",
  294. upBtnImg: "Icono de volver al inicio",
  295. downBtnImg: "Icono de ir al pie de página",
  296. sideControllerIcon: "Icono de la barra lateral",
  297. loadingTextTitle: "Texto de carga",
  298. dbClick2StopCtrl: "Tecla Ctrl",
  299. dbClick2StopAlt: "Tecla Alt",
  300. dbClick2StopShift: "Tecla Shift",
  301. dbClick2StopMeta: "Tecla Meta",
  302. dbClick2StopKey: "Tecla de acceso rápido",
  303. pageElementCss: "Estilo personalizado para los elementos principales de la página",
  304. customCss: "CSS completo personalizado",
  305. firstAlert: "No ha importado la regla base, por favor seleccione la regla adecuada para importar",
  306. picker: "Selector de elementos de página de Pagetual",
  307. closePicker: "Cerrar selector de Pagetual",
  308. pickerPlaceholder: "Selector de elementos, déjelo vacío si no tiene idea",
  309. pickerCheck: "Comprobar selector y copiar",
  310. switchSelector: "Haga clic para cambiar el elemento",
  311. gotoEdit: "Ir a editar la regla con el selector actual",
  312. manualMode: "Deshabilitar unión, pasar páginas manualmente con las teclas de flecha derecha (o despachar evento 'pagetual.next')",
  313. clickMode: "Deshabilitar unión, hacer clic automáticamente en la siguiente página al desplazarse al final de la página",
  314. pageBarMenu: "Haga clic en el centro de la barra de página para abrir el menú del selector",
  315. nextSwitch: "Cambiar al siguiente enlace",
  316. arrowToScroll: "Presione la tecla de flecha izquierda para desplazarse anterior y la tecla de flecha derecha para desplazarse siguiente",
  317. sideController: "Mostrar la barra de control de paginación en la barra lateral",
  318. sideControllerScroll: "Alternar desplazamiento",
  319. sideControllerAlways: "Mostrar siempre",
  320. hideLoadingIcon: "Ocultar animación de carga",
  321. hideBarArrow: "Ocultar flecha para la barra de página",
  322. duplicate: "Pagetual duplicado ha sido instalado, ¡revise su gestor de scripts!",
  323. forceStateIframe: "Incrustar página completa como iframe",
  324. forceStateDynamic: "Cargar contenido dinámico a través de iframe",
  325. forceStateDisable: "Deshabilitar pasar páginas en este sitio",
  326. autoScrollRate: "Velocidad de desplazamiento (1~1000)",
  327. disableAutoScroll: "Detener desplazamiento automático",
  328. enableAutoScroll: "Habilitar desplazamiento automático",
  329. toggleAutoScroll: "Alternar desplazamiento automático",
  330. ruleRequest: "Solicitud de regla",
  331. page: "Página ",
  332. prevPage: "Página anterior",
  333. nextPage: "Página siguiente",
  334. errorRulesMustBeArray: "¡Las reglas deben ser un array!",
  335. errorJson: "Error JSON, ¡verifique de nuevo!",
  336. editSuccess: "Editado exitosamente",
  337. errorWrongUrl: "URL incorrecta, ¡verifique de nuevo!",
  338. errorAlreadyExists: "¡Ya existe!",
  339. settingsSaved: "La configuración se ha guardado, actualice para ver",
  340. iframe: "Iframe",
  341. dynamic: "Dinámico",
  342. reloadPage: "Edición completada, ¿recargar página ahora?",
  343. copied: "Copiado",
  344. noValidContent: "No se detectó contenido válido, puede ser necesario realizar una acción de Captcha, haga clic para ver",
  345. outOfDate: "El script está desactualizado, ¡actualice a la última versión a tiempo!",
  346. hideBarTips: "Ocultar la barra de paginación, alternar experiencia inmersiva",
  347. setConfigPage: "Establecer la página actual como la página de configuración predeterminada",
  348. wedata2github: "Cambiar la dirección de wedata a la dirección espejo en el repositorio de GitHub",
  349. addOtherProp: "Agregar propiedad de regla",
  350. addNextSelector: "Agregar contenido del selector como nextLink",
  351. addPageSelector: "Agregar contenido del selector como pageElement",
  352. propName: "Ingrese el nombre de la propiedad de la regla",
  353. propValue: "Ingrese el valor de la propiedad de la regla",
  354. customFirst: "Ignorar caché para reglas personalizadas locales",
  355. rulesExample: "Ejemplo de reglas",
  356. lastPage: "Llegó a la última página",
  357. lastPageTips: "Mostrar consejos al llegar a la última página"
  358. }
  359. },
  360. {
  361. // Translated by Prankster 199 (vfggf95565).
  362. name: "Arabic",
  363. match: ["ar", "ar-AE", "ar-BH", "ar-DZ", "ar-EG", "ar-IQ", "ar-JO", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-OM", "ar-QA", "ar-SA", "ar-SY", "ar-TN", "ar-YE"],
  364. encode: true, // In Firefox, Arabic characters may cause issues.
  365. lang: {
  366. enableDebug: "%D8%AA%D9%85%D9%83%D9%8A%D9%86%20%D8%AA%D8%B5%D8%AD%D9%8A%D8%AD%20%D8%A7%D9%84%D8%A3%D8%AE%D8%B7%D8%A7%D8%A1",
  367. updateNotification: "%D8%A5%D8%B4%D8%B9%D8%A7%D8%B1%20%D8%A8%D8%B9%D8%AF%20%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF",
  368. disable: "%D9%85%D8%B9%D8%B7%D9%84",
  369. disableSite: "%D8%AA%D8%A8%D8%AF%D9%8A%D9%84%20%D8%AD%D8%A7%D9%84%D8%A9%20%D8%A7%D9%84%D8%AA%D8%B9%D8%B7%D9%8A%D9%84/%D8%A7%D9%84%D8%AA%D9%81%D8%B9%D9%8A%D9%84%20%D9%84%D9%84%D9%85%D9%88%D9%82%D8%B9",
  370. disableSiteTips: "%D9%85%D8%B9%D8%B7%D9%84%20%D8%B9%D9%84%D9%89%20%D9%87%D8%B0%D8%A7%20%D8%A7%D9%84%D9%85%D9%88%D9%82%D8%B9",
  371. enableSiteTips: "%D9%85%D9%81%D8%B9%D9%84%20%D8%B9%D9%84%D9%89%20%D9%87%D8%B0%D8%A7%20%D8%A7%D9%84%D9%85%D9%88%D9%82%D8%B9",
  372. enable: "%D9%85%D9%81%D8%B9%D9%84",
  373. toTop: "%D8%A5%D9%84%D9%89%20%D8%A7%D9%84%D8%A3%D8%B9%D9%84%D9%89",
  374. toBottom: "%D8%A5%D9%84%D9%89%20%D8%A7%D9%84%D8%A3%D8%B3%D9%81%D9%84",
  375. current: "%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%AD%D8%A7%D9%84%D9%8A%D8%A9",
  376. forceIframe: "%D8%A5%D8%AC%D8%A8%D8%A7%D8%B1%20%D8%B9%D9%84%D9%89%20%D8%A7%D9%84%D8%A7%D9%86%D8%B6%D9%85%D8%A7%D9%85%20%D9%84%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A%D8%A9",
  377. cancelForceIframe: "%D8%A5%D9%84%D8%BA%D8%A7%D8%A1%20%D8%A7%D9%84%D8%A7%D9%86%D8%B6%D9%85%D8%A7%D9%85%20%D8%A7%D9%84%D9%82%D8%B3%D8%B1%D9%8A",
  378. configure: "%D8%A5%D8%B9%D8%AF%D8%A7%D8%AF",
  379. firstUpdate: "%D8%A7%D9%86%D9%82%D8%B1%20%D9%87%D9%86%D8%A7%20%D9%84%D8%AA%D9%81%D8%B9%D9%8A%D9%84%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF%20%D9%84%D8%A3%D9%88%D9%84%20%D9%85%D8%B1%D8%A9",
  380. update: "%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF%20%D8%B9%D8%A8%D8%B1%20%D8%A7%D9%84%D8%A5%D9%86%D8%AA%D8%B1%D9%86%D8%AA",
  381. click2update: "%D8%A7%D9%86%D9%82%D8%B1%20%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF%20%D9%85%D9%86%20%D8%A7%D9%84%D8%B1%D8%A7%D8%A8%D8%B7%20%D8%A7%D9%84%D8%A2%D9%86",
  382. loadNow: "%D8%AA%D8%AD%D9%85%D9%8A%D9%84%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A%20%D8%AA%D9%84%D9%82%D8%A7%D8%A6%D9%8A%D9%8B%D8%A7",
  383. loadConfirm: "%D9%83%D9%85%20%D8%B9%D8%AF%D8%AF%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A7%D8%AA%20%D8%A7%D9%84%D8%AA%D9%8A%20%D8%AA%D8%B1%D8%BA%D8%A8%20%D8%AA%D8%AD%D9%85%D9%8A%D9%84%D9%87%D8%A7%D8%9F%20(0%20%D9%8A%D8%B9%D9%86%D9%8A%20%D9%84%D8%A7%D9%86%D9%87%D8%A7%D8%A6%D9%8A)",
  384. noNext: "%D9%84%D9%85%20%D9%8A%D8%AA%D9%85%20%D8%A7%D9%84%D8%B9%D8%AB%D9%88%D8%B1%20%D8%B9%D9%84%D9%89%20%D8%B1%D8%A7%D8%A8%D8%B7%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A%D8%A9%D8%8C%20%D9%8A%D8%B1%D8%AC%D9%89%20%D8%A5%D9%86%D8%B4%D8%A7%D8%A1%20%D9%82%D8%A7%D8%B9%D8%AF%D8%A9%20%D8%AC%D8%AF%D9%8A%D8%AF%D8%A9",
  385. passSec: "%D8%AA%D9%85%20%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D9%85%D9%86%D8%B0%20#t#%20%D8%AB%D8%A7%D9%86%D9%8A%D8%A9",
  386. passMin: "%D8%AA%D9%85%20%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D9%85%D9%86%D8%B0%20#t#%20%D8%AF%D9%82%D9%8A%D9%82%D8%A9",
  387. passHour: "%D8%AA%D9%85%20%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D9%85%D9%86%D8%B0%20#t#%20%D8%B3%D8%A7%D8%B9%D8%A9",
  388. passDay: "%D8%AA%D9%85%20%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D9%85%D9%86%D8%B0%20#t#%20%D9%8A%D9%88%D9%85",
  389. cantDel: "%D9%84%D8%A7%20%D9%8A%D9%85%D9%83%D9%86%20%D8%AD%D8%B0%D9%81%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF%20%D8%A7%D9%84%D9%85%D8%AF%D9%85%D8%AC%D8%A9",
  390. confirmDel: "%D9%87%D9%84%20%D8%A3%D9%86%D8%AA%20%D9%85%D8%AA%D8%A3%D9%83%D8%AF%20%D9%85%D9%86%20%D8%AD%D8%B0%D9%81%20%D9%87%D8%B0%D9%87%20%D8%A7%D9%84%D9%82%D8%A7%D8%B9%D8%AF%D8%A9%D8%9F",
  391. updateSucc: "%D8%AA%D9%85%20%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D8%A8%D9%86%D8%AC%D8%A7%D8%AD",
  392. beginUpdate: "%D8%A8%D8%AF%D8%A3%20%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%D8%8C%20%D9%8A%D8%B1%D8%AC%D9%89%20%D8%A7%D9%84%D8%A7%D9%86%D8%AA%D8%B8%D8%A7%D8%B1%20%D9%84%D8%AD%D8%B8%D8%A9",
  393. customUrls: "%D8%A7%D8%B3%D8%AA%D9%8A%D8%B1%D8%A7%D8%AF%20%D8%B1%D8%A7%D8%A8%D8%B7%20%D9%82%D8%A7%D8%B9%D8%AF%D8%A9%20Pagetual%20%D8%A3%D9%88%20AutoPagerize%D8%8C%20%D8%B1%D8%A7%D8%A8%D8%B7%20%D9%88%D8%A7%D8%AD%D8%AF%20%D9%84%D9%83%D9%84%20%D8%B3%D8%B7%D8%B1",
  394. customRules: "%D8%A5%D8%AF%D8%AE%D8%A7%D9%84%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF%20%D8%A7%D9%84%D9%85%D8%AE%D8%B5%D8%B5%D8%A9.%20%3Ca%20href='#t#'%3E%E2%9C%8D%EF%B8%8F%D8%B3%D8%A7%D9%87%D9%85%20%D8%A8%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF%3C/a%3E",
  395. save: "%D8%AD%D9%81%D8%B8",
  396. loadingText: "%D8%AC%D8%A7%D8%B1%D9%8D%20%D8%A7%D9%84%D8%AA%D8%AD%D9%85%D9%8A%D9%84...",
  397. opacity: "%D8%A7%D9%84%D8%B4%D9%81%D8%A7%D9%81%D9%8A%D8%A9",
  398. opacityPlaceholder: "0:%20%D8%A5%D8%AE%D9%81%D8%A7%D8%A1%20%D8%A7%D9%84%D9%81%D8%A7%D8%B5%D9%84",
  399. hideBar: "%D8%A5%D8%AE%D9%81%D8%A7%D8%A1%20%D8%A7%D9%84%D9%81%D8%A7%D8%B5%D9%84%20%D8%A7%D9%84%D8%AA%D8%B5%D9%81%D8%AD%D9%8A",
  400. hideBarButNoStop: "%D8%A5%D8%AE%D9%81%D8%A7%D8%A1%D8%8C%20%D9%84%D9%83%D9%86%20%D9%84%D8%A7%20%D8%AA%D8%AA%D9%88%D9%82%D9%81",
  401. dbClick2Stop: "%D8%A7%D9%86%D9%82%D8%B1%20%D9%85%D8%B2%D8%AF%D9%88%D8%AC%20%D8%B9%D9%84%D9%89%20%D8%A7%D9%84%D9%85%D8%B3%D8%A7%D8%AD%D8%A9%20%D8%A7%D9%84%D9%81%D8%A7%D8%B1%D8%BA%D8%A9%20%D9%84%D9%84%D8%A5%D9%8A%D9%82%D8%A7%D9%81",
  402. sortTitle: "%D9%8A%D8%AA%D9%85%20%D8%AA%D9%81%D8%B9%D9%8A%D9%84%20%D8%A7%D9%84%D9%81%D8%B1%D8%B2%20%D8%A8%D8%B9%D8%AF%20%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A%20%D9%84%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF",
  403. autoRun: "%D8%AA%D9%85%D9%83%D9%8A%D9%86%20%D8%AA%D9%84%D9%82%D8%A7%D8%A6%D9%8A%20(%D9%88%D8%B6%D8%B9%20%D8%A7%D9%84%D9%82%D8%A7%D8%A6%D9%85%D8%A9%20%D8%A7%D9%84%D8%B3%D9%88%D8%AF%D8%A7%D8%A1)",
  404. autoLoadNum: "%D8%B9%D8%AF%D8%AF%20%D8%B5%D9%81%D8%AD%D8%A7%D8%AA%20%D8%A7%D9%84%D8%AA%D8%AD%D9%85%D9%8A%D9%84%20%D8%A7%D9%84%D9%85%D8%B3%D8%A8%D9%82",
  405. turnRate: "%D8%A7%D9%84%D8%A7%D9%86%D8%AA%D9%82%D8%A7%D9%84%20%D9%84%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A%D8%A9%20%D8%B9%D9%86%D8%AF%D9%85%D8%A7%20%D8%AA%D9%83%D9%88%D9%86%20%D8%A7%D9%84%D9%85%D8%B3%D8%A7%D9%81%D8%A9%20%D8%A3%D9%82%D9%84%20%D9%85%D9%86%20%E3%80%90X%E3%80%91%20%D9%85%D8%B1%D8%A7%D8%AA%20%D8%A7%D8%B1%D8%AA%D9%81%D8%A7%D8%B9%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D9%85%D9%86%20%D8%A7%D9%84%D8%AA%D8%B0%D9%8A%D9%8A%D9%84",
  406. inputPageNum: "%D8%A3%D8%AF%D8%AE%D9%84%20%D8%B1%D9%82%D9%85%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D9%84%D9%84%D8%A7%D9%86%D8%AA%D9%82%D8%A7%D9%84",
  407. enableHistory: "%D9%83%D8%AA%D8%A7%D8%A8%D8%A9%20%D8%B3%D8%AC%D9%84%20%D8%A7%D9%84%D8%AA%D8%B5%D9%81%D8%AD%20%D8%A8%D8%B9%D8%AF%20%D8%AA%D8%AD%D9%88%D9%8A%D9%84%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9",
  408. enableHistoryAfterInsert: "%D9%83%D8%AA%D8%A7%D8%A8%D8%A9%20%D8%B3%D8%AC%D9%84%20%D8%A7%D9%84%D8%AA%D8%B5%D9%81%D8%AD%20%D9%81%D9%88%D8%B1%D9%8B%D8%A7%20%D8%A8%D8%B9%D8%AF%20%D8%A7%D9%84%D8%AF%D9%85%D8%AC%D8%8C%20%D8%A3%D9%88%20%D8%A8%D8%B9%D8%AF%20%D8%A7%D9%84%D8%AA%D8%B5%D9%81%D8%AD",
  409. contentVisibility: "%D8%A7%D9%84%D8%AA%D9%86%D9%82%D9%84%20%D8%A7%D9%84%D8%AA%D9%84%D9%82%D8%A7%D8%A6%D9%8A%20%D9%84%D8%B1%D8%A4%D9%8A%D8%A9%20%D8%A7%D9%84%D9%85%D8%AD%D8%AA%D9%88%D9%89,%20%D9%84%D8%AA%D8%AD%D8%B3%D9%8A%D9%86%20%D8%A3%D8%AF%D8%A7%D8%A1%20%D8%A7%D9%84%D8%B9%D8%B1%D8%B6",
  410. initRun: "%D8%A7%D9%84%D8%A7%D9%86%D8%AA%D9%82%D8%A7%D9%84%20%D8%A8%D9%8A%D9%86%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A7%D8%AA%20%D9%81%D9%88%D8%B1%20%D8%A7%D9%84%D9%81%D8%AA%D8%AD",
  411. preload: "%D8%AA%D8%AD%D9%85%D9%8A%D9%84%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A%D8%A9%20%D9%85%D8%B3%D8%A8%D9%82%D9%8B%D8%A7%20%D9%84%D8%AA%D8%B3%D8%B1%D9%8A%D8%B9%20%D8%A7%D9%84%D8%A3%D8%AF%D8%A7%D8%A1",
  412. click2ImportRule: "%D8%A7%D9%86%D9%82%D8%B1%20%D9%84%D8%A7%D8%B3%D8%AA%D9%8A%D8%B1%D8%A7%D8%AF%20%D8%B1%D8%A7%D8%A8%D8%B7%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF%20%D8%A7%D9%84%D8%A3%D8%B3%D8%A7%D8%B3%D9%8A%D8%A9%D8%8C%20%D8%AB%D9%85%20%D8%A7%D9%86%D8%AA%D8%B8%D8%B1%20%D8%AD%D8%AA%D9%89%20%D9%8A%D9%83%D8%AA%D9%85%D9%84%20%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB",
  413. forceAllBody: "%D8%AF%D9%85%D8%AC%20%D9%83%D8%A7%D9%85%D9%84%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D9%83%D8%A5%D8%B7%D8%A7%D8%B1%D8%9F",
  414. openInNewTab: "%D9%81%D8%AA%D8%AD%20%D8%A7%D9%84%D8%B1%D9%88%D8%A7%D8%A8%D8%B7%20%D8%A7%D9%84%D8%A5%D8%B6%D8%A7%D9%81%D9%8A%D8%A9%20%D9%81%D9%8A%20%D8%B9%D9%84%D8%A7%D9%85%D8%A9%20%D8%AA%D8%A8%D9%88%D9%8A%D8%A8%20%D8%AC%D8%AF%D9%8A%D8%AF%D8%A9",
  415. importSucc: "%D8%AA%D9%85%20%D8%A7%D9%84%D8%A7%D8%B3%D8%AA%D9%8A%D8%B1%D8%A7%D8%AF%20%D8%A8%D9%86%D8%AC%D8%A7%D8%AD",
  416. import: "%D8%A7%D8%B3%D8%AA%D9%8A%D8%B1%D8%A7%D8%AF",
  417. editCurrent: "%D8%AA%D8%AD%D8%B1%D9%8A%D8%B1%20%D8%A7%D9%84%D9%82%D8%A7%D8%B9%D8%AF%D8%A9%20%D9%84%D9%84%D8%AD%D8%A7%D9%84%D9%8A%D8%A9",
  418. editBlacklist: "%D8%AA%D8%AD%D8%B1%D9%8A%D8%B1%20%D8%B9%D9%86%D8%A7%D9%88%D9%8A%D9%86%20%D8%A7%D9%84%D9%82%D8%A7%D8%A6%D9%85%D8%A9%20%D8%A7%D9%84%D8%B3%D9%88%D8%AF%D8%A7%D8%A1%D8%8C%20%D8%B3%D8%B7%D8%B1%20%D8%A8%D8%B3%D8%B7%D8%B1%D8%8C%20%D8%AF%D8%B9%D9%85%D8%9F%20*%20%D9%84%D9%84%D8%B1%D9%85%D9%88%D8%B2%20%D8%A7%D9%84%D9%85%D8%AA%D8%AD%D8%B1%D9%83%D8%A9",
  419. upBtnImg: "%D8%A3%D9%8A%D9%82%D9%88%D9%86%D8%A9%20%D8%A7%D9%84%D8%B9%D9%88%D8%AF%D8%A9%20%D8%A5%D9%84%D9%89%20%D8%A7%D9%84%D8%A3%D8%B9%D9%84%D9%89",
  420. downBtnImg: "%D8%A3%D9%8A%D9%82%D9%88%D9%86%D8%A9%20%D8%A7%D9%84%D8%A7%D9%86%D8%AA%D9%82%D8%A7%D9%84%20%D8%A5%D9%84%D9%89%20%D8%A7%D9%84%D8%A3%D8%B3%D9%81%D9%84",
  421. sideControllerIcon: "%D8%A3%D9%8A%D9%82%D9%88%D9%86%D8%A9%20%D8%A7%D9%84%D8%B4%D8%B1%D9%8A%D8%B7%20%D8%A7%D9%84%D8%AC%D8%A7%D9%86%D8%A8%D9%8A",
  422. loadingTextTitle: "%D8%AA%D8%AD%D9%85%D9%8A%D9%84%20%D8%A7%D9%84%D9%86%D8%B5",
  423. dbClick2StopCtrl: "%D9%85%D9%81%D8%AA%D8%A7%D8%AD%20Ctrl",
  424. dbClick2StopAlt: "%D9%85%D9%81%D8%AA%D8%A7%D8%AD%20Alt",
  425. dbClick2StopShift: "%D9%85%D9%81%D8%AA%D8%A7%D8%AD%20Shift",
  426. dbClick2StopMeta: "%D9%85%D9%81%D8%AA%D8%A7%D8%AD%20Meta",
  427. dbClick2StopKey: "%D9%85%D9%81%D8%A7%D8%AA%D9%8A%D8%AD%20%D8%A7%D9%84%D8%A7%D8%AE%D8%AA%D8%B5%D8%A7%D8%B1",
  428. pageElementCss: "%D9%86%D9%85%D8%B7%20%D9%85%D8%AE%D8%B5%D8%B5%20%D9%84%D8%B9%D9%86%D8%A7%D8%B5%D8%B1%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%B1%D8%A6%D9%8A%D8%B3%D9%8A%D8%A9",
  429. customCss: "%D9%85%D8%AE%D8%B5%D8%B5%20%D8%A8%D8%A7%D9%84%D9%83%D8%A7%D9%85%D9%84%20CSS%20%D9%86%D9%85%D8%B7",
  430. firstAlert: "%D9%84%D9%85%20%D8%AA%D8%B3%D8%AA%D9%88%D8%B1%D8%AF%20%D8%A7%D9%84%D9%82%D8%A7%D8%B9%D8%AF%D8%A9%20%D8%A7%D9%84%D8%A3%D8%B3%D8%A7%D8%B3%D9%8A%D8%A9%20%D8%A8%D8%B9%D8%AF%D8%8C%20%D9%8A%D8%B1%D8%AC%D9%89%20%D8%A7%D8%AE%D8%AA%D9%8A%D8%A7%D8%B1%20%D8%A7%D9%84%D9%82%D8%A7%D8%B9%D8%AF%D8%A9%20%D8%A7%D9%84%D9%85%D9%86%D8%A7%D8%B3%D8%A8%D8%A9%20%D9%84%D9%84%D8%A7%D8%B3%D8%AA%D9%8A%D8%B1%D8%A7%D8%AF",
  431. picker: "%D9%85%D8%AD%D8%AF%D8%AF%20%D8%B9%D9%86%D8%A7%D8%B5%D8%B1%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20Pagetual",
  432. closePicker: "%D8%A5%D8%BA%D9%84%D8%A7%D9%82%20%D9%85%D8%AD%D8%AF%D8%AF%20Pagetual",
  433. pickerPlaceholder: "%D9%85%D8%AD%D8%AF%D8%AF%20%D8%A7%D9%84%D8%B9%D9%86%D8%A7%D8%B5%D8%B1%D8%8C%20%D8%A7%D8%AA%D8%B1%D9%83%D9%87%20%D9%81%D8%A7%D8%B1%D8%BA%D9%8B%D8%A7%20%D8%A5%D8%B0%D8%A7%20%D9%83%D9%86%D8%AA%20%D9%84%D8%A7%20%D8%AA%D8%B9%D8%B1%D9%81",
  434. pickerCheck: "%D8%AA%D8%AD%D9%82%D9%82%20%D9%85%D9%86%20%D8%A7%D9%84%D9%85%D8%AD%D8%AF%D8%AF%20%D9%88%D9%86%D8%B3%D8%AE",
  435. switchSelector: "%D8%A7%D9%86%D9%82%D8%B1%20%D9%84%D9%84%D8%AA%D8%A8%D8%AF%D9%8A%D9%84%20%D8%A8%D9%8A%D9%86%20%D8%A7%D9%84%D8%B9%D9%86%D8%A7%D8%B5%D8%B1",
  436. gotoEdit: "%D8%A7%D8%B0%D9%87%D8%A8%20%D9%84%D8%AA%D8%AD%D8%B1%D9%8A%D8%B1%20%D8%A7%D9%84%D9%82%D8%A7%D8%B9%D8%AF%D8%A9%20%D8%A8%D8%A7%D9%84%D9%85%D8%AD%D8%AF%D8%AF%20%D8%A7%D9%84%D8%AD%D8%A7%D9%84%D9%8A",
  437. manualMode: "%D8%AA%D8%B9%D8%B7%D9%8A%D9%84%20%D8%A7%D9%84%D8%AF%D9%85%D8%AC/%D8%A7%D9%84%D8%B1%D8%A8%D8%B7%D8%8C%20%D9%88%D8%A7%D8%B3%D8%AA%D8%AE%D8%AF%D8%A7%D9%85%20%D9%85%D9%81%D8%AA%D8%A7%D8%AD%20%D8%A7%D9%84%D8%A7%D8%AA%D8%AC%D8%A7%D9%87%20%D8%A7%D9%84%D8%A3%D9%8A%D9%85%D9%86%20%D9%8A%D8%AF%D9%88%D9%8A%D9%8B%D8%A7%20%D9%84%D9%84%D8%AA%D9%85%D8%B1%D9%8A%D8%B1%D8%8C%20%D9%88%D8%A7%D8%B3%D8%AA%D8%AE%D8%AF%D8%A7%D9%85%20%D9%85%D9%81%D8%AA%D8%A7%D8%AD%20%D8%A7%D9%84%D8%B3%D9%87%D9%85%20%D8%A7%D9%84%D8%A3%D9%8A%D8%B3%D8%B1%20%D9%84%D9%84%D8%B1%D8%AC%D9%88%D8%B9",
  438. clickMode: "%D8%AA%D8%B9%D8%B7%D9%8A%D9%84%20%D8%A7%D9%84%D8%AF%D9%85%D8%AC/%D8%A7%D9%84%D8%B1%D8%A8%D8%B7%D8%8C%20%D8%B9%D9%86%D8%AF%20%D8%A7%D9%84%D8%AA%D9%85%D8%B1%D9%8A%D8%B1%20%D8%A5%D9%84%D9%89%20%D9%86%D9%87%D8%A7%D9%8A%D8%A9%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%D8%8C%20%D8%B3%D9%8A%D8%AA%D9%85%20%D8%A7%D9%84%D9%86%D9%82%D8%B1%20%D8%AA%D9%84%D9%82%D8%A7%D8%A6%D9%8A%D9%8B%D8%A7%20%D8%B9%D9%84%D9%89%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A%D8%A9",
  439. pageBarMenu: "%D8%A7%D9%86%D9%82%D8%B1%20%D8%B9%D9%84%D9%89%20%D9%85%D8%B1%D9%83%D8%B2%20%D8%B4%D8%B1%D9%8A%D8%B7%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D9%84%D9%81%D8%AA%D8%AD%20%D9%82%D8%A7%D8%A6%D9%85%D8%A9%20%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AF",
  440. nextSwitch: "%D8%AA%D8%A8%D8%AF%D9%8A%D9%84%20%D8%A7%D9%84%D8%B1%D8%A7%D8%A8%D8%B7%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A",
  441. arrowToScroll: "%D8%A7%D9%86%D9%82%D8%B1%20%D8%B9%D9%84%D9%89%20%D9%85%D9%81%D8%AA%D8%A7%D8%AD%20%D8%A7%D9%84%D8%B3%D9%87%D9%85%20%D8%A7%D9%84%D8%A3%D9%8A%D9%85%D9%86%20%D9%84%D9%84%D8%AA%D9%85%D8%B1%D9%8A%D8%B1%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A%20%D9%88%D9%85%D9%81%D8%AA%D8%A7%D8%AD%20%D8%A7%D9%84%D8%B3%D9%87%D9%85%20%D8%A7%D9%84%D8%A3%D9%8A%D8%B3%D8%B1%20%D9%84%D9%84%D8%AA%D9%85%D8%B1%D9%8A%D8%B1%20%D8%A7%D9%84%D8%B3%D8%A7%D8%A8%D9%82",
  442. sideController: "%D8%B9%D8%B1%D8%B6%20%D8%B4%D8%B1%D9%8A%D8%B7%20%D8%A7%D9%84%D8%AA%D8%AD%D9%83%D9%85%20%D9%81%D9%8A%20%D8%A7%D9%84%D8%AA%D8%B5%D9%81%D8%AD%20%D8%A7%D9%84%D8%AA%D8%B1%D9%82%D9%8A%D9%85%20%D9%81%D9%8A%20%D8%A7%D9%84%D8%B4%D8%B1%D9%8A%D8%B7%20%D8%A7%D9%84%D8%AC%D8%A7%D9%86%D8%A8%D9%8A",
  443. sideControllerScroll: "%D8%AA%D8%A8%D8%AF%D9%8A%D9%84%20%D8%A7%D9%84%D8%AA%D9%85%D8%B1%D9%8A%D8%B1",
  444. sideControllerAlways: "%D8%B9%D8%B1%D8%B6%20%D8%AF%D8%A7%D8%A6%D9%85%D9%8B%D8%A7",
  445. hideLoadingIcon: "%D8%A5%D8%AE%D9%81%D8%A7%D8%A1%20%D8%B1%D9%85%D8%B2%20%D8%A7%D9%84%D8%AA%D8%AD%D9%85%D9%8A%D9%84",
  446. hideBarArrow: "%D8%A5%D8%AE%D9%81%D8%A7%D8%A1%20%D8%B3%D9%87%D9%85%20%D8%B4%D8%B1%D9%8A%D8%B7%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9",
  447. duplicate: "%D8%AA%D9%85%20%D8%AA%D8%AB%D8%A8%D9%8A%D8%AA%20Pagetual%20%D9%85%D9%83%D8%B1%D8%B1%D8%8C%20%D8%AA%D8%AD%D9%82%D9%82%20%D9%85%D9%86%20%D9%85%D8%AF%D9%8A%D8%B1%20%D8%A7%D9%84%D9%86%D8%B5%D9%88%D8%B5%20%D8%A7%D9%84%D8%A8%D8%B1%D9%85%D8%AC%D9%8A%D8%A9%20%D8%A7%D9%84%D8%AE%D8%A7%D8%B5%20%D8%A8%D9%83!",
  448. forceStateIframe: "%D8%AA%D8%B6%D9%85%D9%8A%D9%86%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A8%D8%A7%D9%84%D9%83%D8%A7%D9%85%D9%84%20%D9%83%D8%A5%D8%B7%D8%A7%D8%B1",
  449. forceStateDynamic: "%D8%AA%D8%AD%D9%85%D9%8A%D9%84%20%D8%A7%D9%84%D9%85%D8%AD%D8%AA%D9%88%D9%89%20%D8%A7%D9%84%D8%AF%D9%8A%D9%86%D8%A7%D9%85%D9%8A%D9%83%D9%8A%20%D8%B9%D8%A8%D8%B1%20%D8%A7%D9%84%D8%A5%D8%B7%D8%A7%D8%B1",
  450. forceStateDisable: "%D8%AA%D8%B9%D8%B7%D9%8A%D9%84%20%D8%AA%D8%AD%D9%88%D9%8A%D9%84%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A7%D8%AA%20%D8%B9%D9%84%D9%89%20%D9%87%D8%B0%D8%A7%20%D8%A7%D9%84%D9%85%D9%88%D9%82%D8%B9",
  451. autoScrollRate: "%D8%B3%D8%B1%D8%B9%D8%A9%20%D8%A7%D9%84%D8%AA%D9%85%D8%B1%D9%8A%D8%B1%20(1~1000)",
  452. disableAutoScroll: "%D8%A5%D9%8A%D9%82%D8%A7%D9%81%20%D8%A7%D9%84%D8%AA%D9%85%D8%B1%D9%8A%D8%B1%20%D8%A7%D9%84%D8%AA%D9%84%D9%82%D8%A7%D8%A6%D9%8A",
  453. enableAutoScroll: "%D8%AA%D9%85%D9%83%D9%8A%D9%86%20%D8%A7%D9%84%D8%AA%D9%85%D8%B1%D9%8A%D8%B1%20%D8%A7%D9%84%D8%AA%D9%84%D9%82%D8%A7%D8%A6%D9%8A",
  454. toggleAutoScroll: "%D8%AA%D8%A8%D8%AF%D9%8A%D9%84%20%D8%A7%D9%84%D8%AA%D9%85%D8%B1%D9%8A%D8%B1%20%D8%A7%D9%84%D8%AA%D9%84%D9%82%D8%A7%D8%A6%D9%8A",
  455. ruleRequest: "%D8%B7%D9%84%D8%A8%20%D9%82%D8%A7%D8%B9%D8%AF%D8%A9",
  456. page: "%D8%B5%D9%81%D8%AD%D8%A9%20",
  457. prevPage: "%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%B3%D8%A7%D8%A8%D9%82%D8%A9",
  458. nextPage: "%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%AA%D8%A7%D9%84%D9%8A%D8%A9",
  459. errorRulesMustBeArray: "%D9%8A%D8%AC%D8%A8%20%D8%A3%D9%86%20%D8%AA%D9%83%D9%88%D9%86%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF%20%D9%85%D8%B5%D9%81%D9%88%D9%81%D8%A9!",
  460. errorJson: "%D8%AE%D8%B7%D8%A3%20%D9%81%D9%8A%20JSON%D8%8C%20%D8%AA%D8%AD%D9%82%D9%82%20%D9%85%D8%B1%D8%A9%20%D8%A3%D8%AE%D8%B1%D9%89!",
  461. editSuccess: "%D8%AA%D9%85%20%D8%A7%D9%84%D8%AA%D8%AD%D8%B1%D9%8A%D8%B1%20%D8%A8%D9%86%D8%AC%D8%A7%D8%AD",
  462. errorWrongUrl: "%D8%B9%D9%86%D9%88%D8%A7%D9%86%20URL%20%D8%AE%D8%A7%D8%B7%D8%A6%D8%8C%20%D8%AA%D8%AD%D9%82%D9%82%20%D9%85%D8%B1%D8%A9%20%D8%A3%D8%AE%D8%B1%D9%89!",
  463. errorAlreadyExists: "%D9%85%D9%88%D8%AC%D9%88%D8%AF%20%D8%A8%D8%A7%D9%84%D9%81%D8%B9%D9%84!",
  464. settingsSaved: "%D8%AA%D9%85%20%D8%AD%D9%81%D8%B8%20%D8%A7%D9%84%D8%A5%D8%B9%D8%AF%D8%A7%D8%AF%D8%A7%D8%AA%D8%8C%20%D9%82%D9%85%20%D8%A8%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D9%84%D8%B9%D8%B1%D8%B6",
  465. iframe: "%D8%A5%D8%B7%D8%A7%D8%B1",
  466. dynamic: "%D8%AF%D9%8A%D9%86%D8%A7%D9%85%D9%8A%D9%83%D9%8A",
  467. reloadPage: "%D8%A7%D9%83%D8%AA%D9%85%D9%84%20%D8%A7%D9%84%D8%AA%D8%AD%D8%B1%D9%8A%D8%B1%D8%8C%20%D8%A5%D8%B9%D8%A7%D8%AF%D8%A9%20%D8%AA%D8%AD%D9%85%D9%8A%D9%84%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%A2%D9%86%D8%9F",
  468. copied: "%D8%AA%D9%85%20%D8%A7%D9%84%D9%86%D8%B3%D8%AE",
  469. noValidContent: "%D9%84%D9%85%20%D9%8A%D8%AA%D9%85%20%D8%A7%D9%84%D9%83%D8%B4%D9%81%20%D8%B9%D9%86%20%D9%85%D8%AD%D8%AA%D9%88%D9%89%20%D8%B5%D8%A7%D9%84%D8%AD%D8%8C%20%D9%82%D8%AF%20%D9%8A%D9%83%D9%88%D9%86%20%D8%A7%D9%84%D8%A5%D8%AC%D8%B1%D8%A7%D8%A1%20Captcha%20%D9%85%D8%B7%D9%84%D9%88%D8%A8%D9%8B%D8%A7%D8%8C%20%D8%A7%D9%86%D9%82%D8%B1%20%D9%84%D8%B9%D8%B1%D8%B6",
  470. outOfDate: "%D8%A7%D9%84%D9%86%D8%B5%20%D8%A7%D9%84%D8%A8%D8%B1%D9%85%D8%AC%D9%8A%20%D9%82%D8%AF%D9%8A%D9%85%D8%8C%20%D9%82%D9%85%20%D8%A8%D8%A7%D9%84%D8%AA%D8%AD%D8%AF%D9%8A%D8%AB%20%D8%A5%D9%84%D9%89%20%D8%A7%D9%84%D8%A5%D8%B5%D8%AF%D8%A7%D8%B1%20%D8%A7%D9%84%D8%A3%D8%AD%D8%AF%D8%AB%20%D9%81%D9%8A%20%D8%A7%D9%84%D9%88%D9%82%D8%AA%20%D8%A7%D9%84%D9%85%D9%86%D8%A7%D8%B3%D8%A8!",
  471. hideBarTips: "%D8%A5%D8%AE%D9%81%D8%A7%D8%A1%20%D8%B4%D8%B1%D9%8A%D8%B7%20%D8%A7%D9%84%D8%AA%D8%AD%D9%83%D9%85%20%D9%81%D9%8A%20%D8%A7%D9%84%D8%AA%D8%B5%D9%81%D8%AD%20%D8%A7%D9%84%D8%AA%D8%B1%D9%82%D9%8A%D9%85%20%D8%8C%20%D9%88%D8%A7%D9%84%D8%AA%D8%A8%D8%AF%D9%8A%D9%84%20%D9%84%D9%88%D8%B6%D8%B9%20%D9%83%D8%A7%D9%85%D9%84%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9",
  472. setConfigPage: "%D8%AA%D8%B9%D9%8A%D9%8A%D9%86%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%AD%D8%A7%D9%84%D9%8A%D8%A9%20%D9%83%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%A5%D8%B9%D8%AF%D8%A7%D8%AF%20%D8%A7%D9%84%D8%A7%D9%81%D8%AA%D8%B1%D8%A7%D8%B6%D9%8A%D8%A9",
  473. wedata2github: "%D8%AA%D8%BA%D9%8A%D9%8A%D8%B1%20%D8%B9%D9%86%D9%88%D8%A7%D9%86%20%D8%A7%D9%84%D9%88%D9%8A%D8%A8%20%D8%AF%D8%A7%D8%AA%D8%A7%20%D8%A5%D9%84%D9%89%20%D8%A7%D9%84%D8%B9%D9%86%D9%88%D8%A7%D9%86%20%D8%A7%D9%84%D8%A8%D8%AF%D9%8A%D9%84%20%D8%A7%D9%84%D9%85%D8%B1%D8%A2%D8%A9,%20%D9%81%D9%8A%20%D9%85%D8%B3%D8%AA%D9%88%D8%AF%D8%B9%20%D8%AC%D9%8A%D8%AA%20%D9%87%D8%A7%D8%A8",
  474. addOtherProp: "%D8%A5%D8%B6%D8%A7%D9%81%D8%A9%20%D8%AE%D8%A7%D8%B5%D9%8A%D8%A9%20%D9%82%D8%A7%D8%B9%D8%AF%D8%A9",
  475. addNextSelector: "%D8%A5%D8%B6%D8%A7%D9%81%D8%A9%20%D9%85%D8%AD%D8%AA%D9%88%D9%89%20%D8%A7%D9%84%D9%85%D8%AD%D8%AF%D8%AF%20%D9%83%D9%80%20nextLink",
  476. addPageSelector: "%D8%A5%D8%B6%D8%A7%D9%81%D8%A9%20%D9%85%D8%AD%D8%AA%D9%88%D9%89%20%D8%A7%D9%84%D9%85%D8%AD%D8%AF%D8%AF%20%D9%83%D9%80%20pageElement",
  477. propName: "%D8%A3%D8%AF%D8%AE%D9%84%20%D8%A7%D8%B3%D9%85%20%D8%AE%D8%A7%D8%B5%D9%8A%D8%A9%20%D8%A7%D9%84%D9%82%D8%A7%D8%B9%D8%AF%D8%A9",
  478. propValue: "%D8%A3%D8%AF%D8%AE%D9%84%20%D9%82%D9%8A%D9%85%D8%A9%20%D8%AE%D8%A7%D8%B5%D9%8A%D8%A9%20%D8%A7%D9%84%D9%82%D8%A7%D8%B9%D8%AF%D8%A9",
  479. customFirst: "%D8%AA%D8%AC%D8%A7%D9%87%D9%84%20%D8%B0%D8%A7%D9%83%D8%B1%D8%A9%20%D8%A7%D9%84%D8%AA%D8%AE%D8%B2%D9%8A%D9%86%20%D8%A7%D9%84%D9%85%D8%A4%D9%82%D8%AA%20%D9%84%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF%20%D8%A7%D9%84%D9%85%D8%AE%D8%B5%D8%B5%D8%A9%20%D8%A7%D9%84%D9%85%D8%AD%D9%84%D9%8A%D8%A9",
  480. rulesExample: "%D9%85%D8%AB%D8%A7%D9%84%20%D8%B9%D9%84%D9%89%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF",
  481. lastPage: "%D8%AA%D9%85%20%D8%A7%D9%84%D9%88%D8%B5%D9%88%D9%84%20%D8%A5%D9%84%D9%89%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%A3%D8%AE%D9%8A%D8%B1%D8%A9",
  482. lastPageTips: "%D8%B9%D8%B1%D8%B6%20%D8%AA%D9%84%D9%85%D9%8A%D8%AD%D8%A7%D8%AA%20%D8%B9%D9%86%D8%AF%20%D8%A7%D9%84%D9%88%D8%B5%D9%88%D9%84%20%D8%A5%D9%84%D9%89%20%D8%A7%D9%84%D8%B5%D9%81%D8%AD%D8%A9%20%D8%A7%D9%84%D8%A3%D8%AE%D9%8A%D8%B1%D8%A9"
  483. }
  484. },
  485. {
  486. name: "简体中文",
  487. match: ["zh-CN", "zh-SG"],
  488. lang: {
  489. enableDebug: "调试模式,输出信息至控制台",
  490. updateNotification: "规则更新后提示",
  491. disable: "暂时禁用",
  492. disableSite: "站点禁用开关",
  493. disableSiteTips: "已在此站禁用",
  494. enableSiteTips: "已在此站启用",
  495. enable: "启用自动翻页",
  496. toTop: "回到顶部",
  497. toBottom: "前往页尾",
  498. current: "当前页",
  499. forceIframe: "强制拼接",
  500. cancelForceIframe: "取消强制拼接",
  501. configure: "打开配置页面",
  502. firstUpdate: "点击此处初始化规则",
  503. update: "更新在线规则",
  504. click2update: "点击立即更新规则",
  505. loadNow: "立即翻页",
  506. loadConfirm: "要翻几页?(0为不间断)",
  507. noNext: "没有找到下一页,请新建规则",
  508. passSec: "更新于 #t# 秒前",
  509. passMin: "更新于 #t# 分钟前",
  510. passHour: "更新于 #t# 小时前",
  511. passDay: "更新于 #t# 天前",
  512. cantDel: "无法删除内置规则",
  513. confirmDel: "是否确认要删除此规则?",
  514. updateSucc: "更新成功",
  515. beginUpdate: "正在更新,请耐心等待,不要关闭页面",
  516. customUrls: "导入 Pagetual 或 AutoPagerize 规则 url,一行一条",
  517. customRules: "输入【东方永页机】格式的自定义规则 <a href='#t#'>✍️贡献规则</a>",
  518. save: "保存设置",
  519. loadingText: "少女祈祷中...",
  520. opacity: "不透明值",
  521. opacityPlaceholder: "0: 隐藏分隔条",
  522. hideBar: "隐藏分页隔条",
  523. hideBarButNoStop: "隐藏但不停止",
  524. dbClick2Stop: "空白处双击暂停翻页",
  525. sortTitle: "排序在下次更新规则后生效",
  526. autoRun: "自动启用,否则为白名单模式",
  527. autoLoadNum: "自动加载指定页数",
  528. turnRate: "距离页尾【X】倍页面高度时就开始翻页",
  529. inputPageNum: "输入页码跳转",
  530. enableHistory: "翻页后写入历史记录",
  531. enableHistoryAfterInsert: "拼接后立即写入历史记录,否则浏览完毕后再行写入",
  532. contentVisibility: "自动切换 contentVisibility,提升渲染性能",
  533. initRun: "打开页面后立即尝试翻页,否则滚动至页尾再翻页",
  534. preload: "翻页前预读下一页,加速浏览",
  535. click2ImportRule: "点击下方任意一条添加规则库,并静待更新成功,请预先打开链接确认能正常访问再行导入:",
  536. forceAllBody: "是否拼接整个页面?",
  537. openInNewTab: "使拼接页面的内容在新页面打开",
  538. importSucc: "导入成功",
  539. import: "导入",
  540. editCurrent: "编辑此站规则",
  541. editBlacklist: "编辑黑名单网址,一行一条,支持? *通配符与正则",
  542. upBtnImg: "回到页首图标",
  543. downBtnImg: "前往页尾图标",
  544. sideControllerIcon: "侧边栏图标",
  545. loadingTextTitle: "加载中文字",
  546. dbClick2StopCtrl: "Ctrl",
  547. dbClick2StopAlt: "Alt",
  548. dbClick2StopShift: "Shift",
  549. dbClick2StopMeta: "Meta",
  550. dbClick2StopKey: "快捷键",
  551. pageElementCss: "页面主体框架的样式",
  552. customCss: "自定义 css",
  553. firstAlert: "你还未导入规则库,请选择合适的规则库导入哦",
  554. picker: "东方永页机主体元素抓取器",
  555. closePicker: "关闭东方永页机抓取器",
  556. pickerPlaceholder: "元素选择器,没想法建议留空",
  557. pickerCheck: "检查你编辑的选择器并复制",
  558. switchSelector: "点击切换元素",
  559. gotoEdit: "使用当前的选择器前往编辑规则",
  560. manualMode: "禁用拼接,手动用右方向键翻页,可使用左方向键返回",
  561. clickMode: "禁用拼接,滚动至页尾时自动点击下一页",
  562. pageBarMenu: "点击分隔条中间弹出菜单",
  563. nextSwitch: "切换其他页码",
  564. arrowToScroll: "左方向键滚动至上一页,右方向键滚动至下一页",
  565. sideController: "在侧边显示翻页控制栏",
  566. sideControllerScroll: "滚动开关",
  567. sideControllerAlways: "始终显示",
  568. hideLoadingIcon: "隐藏加载动画",
  569. hideBarArrow: "隐藏分隔条定位箭头",
  570. duplicate: "检测到永页机重复安装,请删除其他脚本管理器中的永页机!",
  571. forceStateIframe: "以 iframe 嵌入整页",
  572. forceStateDynamic: "通过 iframe 加载动态内容后取出",
  573. forceStateDisable: "在此站禁用",
  574. autoScrollRate: "滚动速度(1~1000)",
  575. disableAutoScroll: "停止自动滚动",
  576. enableAutoScroll: "开启自动滚动",
  577. toggleAutoScroll: "自动滚动开关",
  578. ruleRequest: "适配请求",
  579. page: "Page ",
  580. prevPage: "上一页",
  581. nextPage: "下一页",
  582. errorRulesMustBeArray: "规则必须为数组形式!",
  583. errorJson: "JSON 格式有错,请重新检查!",
  584. editSuccess: "编辑成功",
  585. errorWrongUrl: "URL 错误, 请重新检查!",
  586. errorAlreadyExists: "已经存在!",
  587. settingsSaved: "设置已保存,刷新后生效",
  588. iframe: "强制拼接",
  589. dynamic: "动态加载",
  590. reloadPage: "编辑完成,是否立即刷新页面?",
  591. copied: "已复制",
  592. noValidContent: "没有检测到有效内容,可能需要人机校验,点击查看",
  593. outOfDate: "脚本已过时,请及时更新到最新版本!",
  594. hideBarTips: "隐藏分页隔条,沉浸式体验",
  595. setConfigPage: "将当前页面设为默认配置页",
  596. wedata2github: "将 wedata 地址更改为 github 仓库内的镜像地址",
  597. addOtherProp: "添加规则属性",
  598. addNextSelector: "添加选择器内容为 nextLink",
  599. addPageSelector: "添加选择器内容为 pageElement",
  600. propName: "输入规则属性名",
  601. propValue: "输入规则属性值",
  602. customFirst: "为本地自定义规则忽略缓存",
  603. rulesExample: "自定义规则详解",
  604. lastPage: "已到达最后一页",
  605. lastPageTips: "到达最后一页时进行提示"
  606. }
  607. },
  608. {
  609. name: "正體中文",
  610. match: ["zh", "zh-TW", "zh-HK"],
  611. lang: {
  612. enableDebug: "調試模式,輸出信息至控制台",
  613. updateNotification: "規則更新后提示",
  614. disable: "暫時禁用",
  615. disableSite: "站點禁用開關",
  616. disableSiteTips: "已在此站禁用",
  617. enableSiteTips: "已在此站啟用",
  618. enable: "啟用自動翻頁",
  619. toTop: "回到頂部",
  620. toBottom: "前往頁尾",
  621. current: "當前頁",
  622. forceIframe: "強制拼接",
  623. cancelForceIframe: "取消强制拼接",
  624. configure: "打開配置頁面",
  625. firstUpdate: "點擊此處初始化規則",
  626. update: "更新在綫規則",
  627. click2update: "點擊立即更新規則",
  628. loadNow: "立即翻頁",
  629. loadConfirm: "要翻几頁?(0為不間斷)",
  630. noNext: "沒有找到下一頁,請新建規則",
  631. passSec: "更新于 #t# 秒前",
  632. passMin: "更新于 #t# 分鐘前",
  633. passHour: "更新于 #t# 小時前",
  634. passDay: "更新于 #t# 天前",
  635. cantDel: "無法刪除内置規則",
  636. confirmDel: "是否確認要刪除此規則?",
  637. updateSucc: "更新成功",
  638. beginUpdate: "正在更新,請稍候",
  639. customUrls: "導入 Pagetual 或 AutoPagerize 規則 url,一行一條",
  640. customRules: "輸入【東方永頁機】格式的自定義規則 <a href='#t#'>✍️貢獻規則</a>",
  641. save: "存儲設置",
  642. loadingText: "少女祈禱中...",
  643. opacity: "不透明值",
  644. opacityPlaceholder: "0: 隱藏分隔條",
  645. hideBar: "隱藏分頁隔條",
  646. hideBarButNoStop: "隱藏但不停止",
  647. dbClick2Stop: "空白處雙擊暫停翻頁",
  648. sortTitle: "排序在下次更新規則後生效",
  649. autoRun: "自動啓用,否則為白名單模式",
  650. autoLoadNum: "自動加載指定頁數",
  651. turnRate: "距離頁尾【X】倍頁面高度時就開始翻頁",
  652. inputPageNum: "輸入頁碼跳轉",
  653. enableHistory: "翻頁后寫入歷史記錄",
  654. enableHistoryAfterInsert: "拼接後立即寫入歷史記錄,否則瀏覽完畢後再行寫入",
  655. contentVisibility: "自動切換 contentVisibility,提升渲染性能",
  656. initRun: "打開頁面后立即嘗試翻頁,否則滾動至頁尾再翻頁",
  657. preload: "翻頁前預讀下一頁,加速瀏覽",
  658. click2ImportRule: "點擊下方添加特殊規則庫,并靜待更新成功:",
  659. forceAllBody: "是否拼接整個頁面?",
  660. openInNewTab: "使拼接頁面的内容在新頁面打開",
  661. importSucc: "導入成功",
  662. import: "導入",
  663. editCurrent: "編輯此站規則",
  664. editBlacklist: "編輯黑名單網址,一行一條,支持? *通配符與正則",
  665. upBtnImg: "回到頁首圖標",
  666. downBtnImg: "前往頁尾圖標",
  667. sideControllerIcon: "側邊欄圖標",
  668. loadingTextTitle: "加載中文字",
  669. dbClick2StopCtrl: "Ctrl",
  670. dbClick2StopAlt: "Alt",
  671. dbClick2StopShift: "Shift",
  672. dbClick2StopMeta: "Meta",
  673. dbClick2StopKey: "快捷鍵",
  674. pageElementCss: "頁面主體框架的樣式",
  675. customCss: "自定義 css",
  676. firstAlert: "你還未導入規則庫,請選擇合適的規則庫導入哦",
  677. picker: "東方永頁機主體元素抓取器",
  678. closePicker: "關閉東方永頁機抓取器",
  679. pickerPlaceholder: "元素選擇器,沒想法建議留空",
  680. pickerCheck: "檢查你編輯的選擇器並複製",
  681. switchSelector: "點擊切換元素",
  682. gotoEdit: "使用當前的選擇器前往編輯規則",
  683. manualMode: "禁用拼接,手動用右方向鍵翻頁,左方向鍵返回",
  684. clickMode: "禁用拼接,滾動至頁尾時自動點擊下一頁",
  685. pageBarMenu: "點擊分隔條中間彈出菜單",
  686. nextSwitch: "切換其他頁碼",
  687. arrowToScroll: "左方向鍵滾動至上一頁,右方向鍵滾動至下一頁",
  688. sideController: "在側邊顯示翻頁控制欄",
  689. sideControllerScroll: "滾燈開關",
  690. sideControllerAlways: "始終顯示",
  691. hideLoadingIcon: "隱藏加載動畫",
  692. hideBarArrow: "隱藏分隔條定位箭頭",
  693. duplicate: "檢測到永頁機重複安裝,請刪除其他腳本管理器中的永頁機!",
  694. forceStateIframe: "以 iframe 嵌入整頁",
  695. forceStateDynamic: "通過 iframe 加載動態內容後取出",
  696. forceStateDisable: "在此站禁用",
  697. autoScrollRate: "滾動速度(1~1000)",
  698. disableAutoScroll: "停止自動滾動",
  699. enableAutoScroll: "開啟自動滾動",
  700. toggleAutoScroll: "自動滾動開關",
  701. ruleRequest: "適配請求",
  702. page: "Page ",
  703. prevPage: "上一頁",
  704. nextPage: "下一頁",
  705. errorRulesMustBeArray: "規則必須為陣列形式!",
  706. errorJson: "JSON 格式有錯,請重新檢查!",
  707. editSuccess: "編輯成功",
  708. errorWrongUrl: "URL 錯誤, 請重新檢查!",
  709. errorAlreadyExists: "已經存在!",
  710. settingsSaved: "設置已保存,刷新後生效",
  711. iframe: "強制拼接",
  712. dynamic: "動態加載",
  713. reloadPage: "編輯完成,是否立即刷新頁面?",
  714. copied: "已復制",
  715. noValidContent: "沒有檢測到有效内容,可能需要人機校驗,點擊查看",
  716. outOfDate: "脚本已過時,請及時更新到最新版本!",
  717. hideBarTips: "隱藏分頁隔條,沉浸式體驗",
  718. setConfigPage: "將當前頁面設為默認配置頁",
  719. wedata2github: "將 wedata 地址更改為 github 倉庫內的鏡像地址",
  720. addOtherProp: "添加規則屬性",
  721. addNextSelector: "添加選擇器內容為 nextLink",
  722. addPageSelector: "添加選擇器內容為 pageElement",
  723. propName: "輸入規則屬性名",
  724. propValue: "輸入規則屬性值",
  725. customFirst: "為本地自定義規則忽略緩存",
  726. rulesExample: "自定義規則詳解",
  727. lastPage: "已到達最後一頁",
  728. lastPageTips: "到達最後一頁時進行提示"
  729. }
  730. },
  731. {
  732. name: "日本語",
  733. match: ["ja"],
  734. lang: {
  735. enableDebug: "デバッグモード",
  736. updateNotification: "ルール更新後の通知",
  737. disable: "一時的に無効",
  738. disableSite: "無効状態の切り替え",
  739. disableSiteTips: "このサイトで既に無効になっています",
  740. enableSiteTips: "このサイトで既に有効になっています",
  741. enable: "ページめくりを有効にする",
  742. toTop: "トップに戻る",
  743. toBottom: "ページの下部に移動",
  744. current: "現在のページ",
  745. forceIframe: "強制ステッチ",
  746. cancelForceIframe: "強制ステッチをキャンセル",
  747. configure: "設定ページを開く",
  748. firstUpdate: "ここをクリックしてルールを初期化します",
  749. update: "更新ルール",
  750. click2update: "今すぐルールを更新してください",
  751. loadNow: "今すぐページをめくる",
  752. loadConfirm: "数ページめくりたいですか?(0は途切れない)",
  753. noNext: "次のページが見つかりません、新しいルールを作成してください",
  754. passSec: "#t#秒前に更新",
  755. passMin: "#t#分前に更新",
  756. passHour: "#t#時間前に更新",
  757. passDay: "#t#日前に更新",
  758. cantDel: "組み込みルールを削除できません",
  759. confirmDel: "このルールを削除してもよろしいですか?",
  760. updateSucc: "更新に成功しました",
  761. beginUpdate: "更新中、お待ちください",
  762. customUrls: "インポートルールのURL、1行に1つ",
  763. customRules: "【東方永頁機】の形式でカスタムルールを入力してください <a href='#t#'>✍️寄稿ルール</a>",
  764. save: "設定を保存",
  765. loadingText: "少女祈祷中...",
  766. opacity: "不透明値",
  767. opacityPlaceholder: "0: 隠す",
  768. hideBar: "ページ区切り文字を非表示にします",
  769. hideBarButNoStop: "非表示にするが停止しない",
  770. dbClick2Stop: "空白部分をダブルクリックしてページめくりを一時停止します",
  771. sortTitle: "並べ替えは、次のルールの更新後に有効になります",
  772. autoRun: "自動的に有効",
  773. autoLoadNum: "指定したページ数を自動的に読み込みます",
  774. turnRate: "ページの端からページの高さの【X】倍になったらページをめくる",
  775. inputPageNum: "ジャンプするページ番号を入力",
  776. enableHistory: "ページめくり後の履歴を書く",
  777. enableHistoryAfterInsert: "スプライシングの直後に履歴レコードを書き込みます。それ以外の場合は、閲覧後に書き込みます",
  778. contentVisibility: "contentVisibility を自動的に切り替えてレンダリング パフォーマンスを向上させる",
  779. initRun: "Webページを開いた直後にページをめくる",
  780. preload: "事前に次のページを読む",
  781. click2ImportRule: "以下をクリックして、ルールベースを追加します:",
  782. forceAllBody: "フルページ埋め込み?",
  783. openInNewTab: "スプライスされたページのコンテンツを新しいページで開きます",
  784. importSucc: "インポート完了",
  785. import: "インポート",
  786. editCurrent: "現在のルールの編集",
  787. editBlacklist: "ブラックリストのURLを編集し、1行ずつ、サポート? *ワイルドカード",
  788. upBtnImg: "トップアイコンに戻る",
  789. downBtnImg: "フッターアイコンに移動",
  790. sideControllerIcon: "サイドバー アイコン",
  791. loadingTextTitle: "テキストをロード",
  792. dbClick2StopCtrl: "Ctrlキー",
  793. dbClick2StopAlt: "Altキー",
  794. dbClick2StopShift: "Shiftキー",
  795. dbClick2StopMeta: "Metaキー",
  796. dbClick2StopKey: "Shortcutキー",
  797. pageElementCss: "ページ本文フレームの STYLE",
  798. customCss: "カスタム css",
  799. firstAlert: "ルールベースをインポートしていないため、インポートする適切なルールベースを選択してください",
  800. picker: "Pagetualページ要素ピッカー",
  801. closePicker: "Pagetualピッカーを閉じる",
  802. pickerPlaceholder: "わからない場合は空のままにしてください",
  803. pickerCheck: "セレクターをチェックしてコピー",
  804. switchSelector: "クリックして要素を切り替えます",
  805. gotoEdit: "現在のセレクターでルールを編集する",
  806. manualMode: "スプライシングを無効にします。手動で右の矢印キーを使用してページをめくります",
  807. clickMode: "スティッチングを無効にします。ページの最後までスクロールすると、次のページが自動的にクリックされます",
  808. pageBarMenu: "ページバーの中央をクリックしてメニューをポップアップ表示",
  809. nextSwitch: "次のページに切り替え",
  810. arrowToScroll: "左矢印キーで前へ、右矢印キーで次へ",
  811. sideController: "サイドバーにページング コントロール バーを表示する",
  812. sideControllerScroll: "スクロール スイッチ",
  813. sideControllerAlways: "常に表示",
  814. hideLoadingIcon: "読み込み中のアニメーションを隠す",
  815. hideBarArrow: "分割線の位置矢印を隠す",
  816. duplicate: "Pagetual の重複インストールが検出されました。他のスクリプト マネージャで永続的なページ マシンを削除してください!",
  817. forceStateIframe: "iframe にページ全体を埋め込む",
  818. forceStateDynamic: "iframe 経由で動的コンテンツを読み込む",
  819. forceStateDisable: "このステーションでのページめくりを無効にする",
  820. autoScrollRate: "スクロール速度 (1~1000)",
  821. disableAutoScroll: "自動スクロールを停止します",
  822. enableAutoScroll: "自動スクロールを有効にする",
  823. toggleAutoScroll: "自動スクロールの切り替え",
  824. ruleRequest: "ルール要求",
  825. page: "Page ",
  826. prevPage: "Prev page",
  827. nextPage: "Next page",
  828. errorRulesMustBeArray: "Rules must be a Array!",
  829. errorJson: "JSON error, check again!",
  830. editSuccess: "Edit successfully",
  831. errorWrongUrl: "Wrong url, check again!",
  832. errorAlreadyExists: "Already exists!",
  833. settingsSaved: "The settings are saved, refresh to view",
  834. iframe: "Iframe",
  835. dynamic: "Dynamic",
  836. reloadPage: "Edit completed, reload page now?",
  837. copied: "Copied",
  838. noValidContent: "有効なコンテンツが検出されませんでした。クリックして表示",
  839. outOfDate: "スクリプトが古くなっています。最新バージョンに更新してください。",
  840. hideBarTips: "ページネーション バーを非表示にします。没入型エクスペリエンス",
  841. setConfigPage: "現在のページをデフォルト設定ページとして設定",
  842. wedata2github: "wedata アドレスを github ウェアハウスのミラー アドレスに変更",
  843. addOtherProp: "ルールプロパティを追加",
  844. addNextSelector: "セレクターのコンテンツを nextLink として追加",
  845. addPageSelector: "セレクタ コンテンツを pageElement として追加",
  846. propName: "ルールのプロパティ名を入力してください",
  847. propValue: "ルールのプロパティ値を入力してください",
  848. customFirst: "ローカルカスタムルールのキャッシュを無視する",
  849. rulesExample: "カスタムルールの詳しい説明",
  850. lastPage: "最後のページに到達しました",
  851. lastPageTips: "最後のページに到達した時にヒントを表示する"
  852. }
  853. },
  854. {
  855. name: "Русский",
  856. match: ["ru", "ru-RU"],
  857. lang: {
  858. enableDebug: "Включить отладку",
  859. updateNotification: "Уведомление после обновления правила",
  860. disable: "Выключить",
  861. disableSite: "Включить/выключить на сайте",
  862. disableSiteTips: "Выключено для этого сайта",
  863. enableSiteTips: "Включено для этого сайта",
  864. enable: "Включить",
  865. toTop: "Наверх",
  866. toBottom: "Вниз",
  867. current: "Текущая страница",
  868. forceIframe: "Подгрузить ещё страницу",
  869. cancelForceIframe: "Отменить подгрузку",
  870. configure: "Настройки",
  871. firstUpdate: "Нажмите здесь, чтобы инициализировать правила",
  872. update: "Обновить правила",
  873. click2update: "Нажмите, чтобы обновить правила",
  874. loadNow: "Загрузить следующую страницу",
  875. loadConfirm: "Сколько страниц вы хотите загрузить? (0 означает бесконечность)",
  876. noNext: "Ссылка на следующую страницу не найдена. Пожалуйста, создайте новое правило",
  877. passSec: "Обновлено #t# секунд назад",
  878. passMin: "Обновлено #t# минут назад",
  879. passHour: "Обновлено #t# часов назад",
  880. passDay: "Обновлено #t# дней назад",
  881. cantDel: "Нельзя удалить правила по умолчанию",
  882. confirmDel: "Вы уверены, что хотите удалить эту ссылку?",
  883. updateSucc: "Правила обновлены",
  884. beginUpdate: "Обновление. Пожалуйста, немного подождите",
  885. customUrls: "Ссылки с правилами для импорта. Одна ссылка на строку",
  886. customRules: "Введите пользовательские правила в формате Pagetual. <a href='#t#'>✍️Улучшить встроенные правила</a>",
  887. save: "Сохранить настройки",
  888. loadingText: "Следующая страница подгружается…",
  889. opacity: "Прозрачность",
  890. opacityPlaceholder: "0 - скрыть",
  891. hideBar: "Скрыть разделитель страниц",
  892. hideBarButNoStop: "Скрыть, но не останавливать",
  893. dbClick2Stop: "Двойной клик на странице для выключения",
  894. sortTitle: "Правило сортировки применится после следующего обновления правил",
  895. autoRun: "Автозапуск (режим черного списка)",
  896. autoLoadNum: "Количество страниц для предзагрузки",
  897. turnRate: "Подгрузить страницу, когда она будет в 【X】 раз больше высоты страницы от конца страницы",
  898. inputPageNum: "Введите номер страницы для перехода",
  899. enableHistory: "Записать историю после переключения страниц",
  900. enableHistoryAfterInsert: "Записать запись истории сразу после вставки, иначе записать после просмотра",
  901. contentVisibility: "Автоматически переключать contentVisibility для повышения производительности рендеринга",
  902. initRun: "Подгружать страницы сразу после открытия",
  903. preload: "Предзагрузка следующей страницы",
  904. click2ImportRule: "Нажмите, чтобы импортировать базовые правила: ",
  905. forceAllBody: "Присоединить страницу целиком?",
  906. openInNewTab: "Открыть дополнительные ссылки в новой вкладке",
  907. importSucc: "Импорт завершен",
  908. import: "Импорт",
  909. editCurrent: "Изменить правило для текущего сайта",
  910. editBlacklist: "Изменить черный список. Одна ссылка на строку. Поддерживаются метасимволы: ? и *",
  911. upBtnImg: "Иконка перехода к началу",
  912. downBtnImg: "Иконка перехода к концу",
  913. sideControllerIcon: "Значок боковой панели",
  914. loadingTextTitle: "Текст во время загрузки",
  915. dbClick2StopCtrl: "Ctrl",
  916. dbClick2StopAlt: "Alt",
  917. dbClick2StopShift: "Shift",
  918. dbClick2StopMeta: "Meta",
  919. dbClick2StopKey: "Клавиша",
  920. pageElementCss: "Пользовательский стиль для основных элементов страницы",
  921. customCss: "Полный пользовательский CSS",
  922. firstAlert: "Вы не импортировали базовое правило. Пожалуйста, выберите соответствующее правило для импорта",
  923. picker: "Pagetual: выбор элемента страницы",
  924. closePicker: "Закрыть окно Pagetual",
  925. pickerPlaceholder: "Если не знаете, что тут писать — оставьте поле пустым",
  926. pickerCheck: "Проверить и скопировать селектор",
  927. switchSelector: "Нажмите для выбора элемента",
  928. gotoEdit: "Перейти к редактированию правила с текущим селектором",
  929. manualMode: "Отключить автоматическую загрузку страниц. Загружать вручную с помощью стрелки вправо (или вызова события 'pagetual.next')",
  930. clickMode: "Отключить \"сшивание\" страниц. При прокрутке до конца автоматически переходить на следующую страницу",
  931. pageBarMenu: "Открывать меню кликом на середину панели страниц",
  932. nextSwitch: "Переключить ссылку на следующую страницу",
  933. arrowToScroll: "Листать страницы клавишами со стрелками влево и вправо",
  934. sideController: "Показать справа панель перемещения по вкладке",
  935. sideControllerScroll: "Переключатель прокрутки",
  936. sideControllerAlways: "Всегда показывать",
  937. hideLoadingIcon: "Скрыть анимацию загрузки",
  938. hideBarArrow: "Скрыть кнопки перемещения на разделителе",
  939. duplicate: "Похоже, Pagetual установлен несколько раз. Пожалуйста, удалите Pagetual из других менеджеров скриптов!",
  940. forceStateIframe: "Вставить полную страницу как iframe",
  941. forceStateDynamic: "Загружать динамический контент через iframe",
  942. forceStateDisable: "Отключить перелистывание страниц на этой станции",
  943. autoScrollRate: "Скорость прокрутки (1~1000)",
  944. disableAutoScroll: "Остановить автоматическую прокрутку",
  945. enableAutoScroll: "Включить автопрокрутку",
  946. toggleAutoScroll: "Переключить автопрокрутку",
  947. ruleRequest: "Запрос правил",
  948. page: "Страница ",
  949. prevPage: "Предыдущая страница",
  950. nextPage: "Следующая страница",
  951. errorRulesMustBeArray: "Правила должны быть массивом!",
  952. errorJson: "Ошибка разбора JSON. Пожалуйста, исправьте его",
  953. editSuccess: "Редактирование успешно",
  954. errorWrongUrl: "Ссылка некорректна. Пожалуйста, исправьте её",
  955. errorAlreadyExists: "Уже существует!",
  956. settingsSaved: "Настройки сохранены. Обновите страницы",
  957. iframe: "iframe",
  958. dynamic: "Динамически",
  959. reloadPage: "Редактирование завершено. Обновить страницу?",
  960. copied: "Скопировано",
  961. noValidContent: "Действительный контент не обнаружен, нажмите для просмотра",
  962. outOfDate: "Скрипт устарел, своевременно обновляйте до последней версии!",
  963. hideBarTips: "Скрыть панель разбиения на страницы, иммерсивный опыт",
  964. setConfigPage: "Установить текущую страницу в качестве страницы конфигурации по умолчанию",
  965. wedata2github: "Изменить адрес wedata на зеркальный адрес на складе github",
  966. addOtherProp: "Добавить свойство правила",
  967. addNextSelector: "Добавить содержимое селектора как nextLink",
  968. addPageSelector: "Добавить содержимое селектора как pageElement",
  969. propName: "Введите имя свойства правила",
  970. propValue: "Введите значение свойства правила",
  971. customFirst: "Игнорировать кеш для локальных пользовательских правил",
  972. rulesExample: "Подробное объяснение настраиваемых правил",
  973. lastPage: "Достигнута последняя страница",
  974. lastPageTips: "Показывать подсказки при достижении последней страницы"
  975. }
  976. }
  977. ];
  978. var langList = {};
  979. langData.forEach(lang => {
  980. langList[lang.match[0]] = lang.name;
  981. });
  982. var i18nData = langData[0].lang;
  983. function setLang(la) {
  984. for (let i = 0; i < langData.length; i++) {
  985. let lang = langData[i];
  986. if (lang && lang.match.indexOf(la) !== -1) {
  987. i18nData = lang.lang;
  988. if (lang.encode) {
  989. for (let k in i18nData) {
  990. i18nData[k] = decodeURI(i18nData[k]);
  991. }
  992. }
  993. break;
  994. }
  995. }
  996. }
  997. setLang(lang);
  998. var enableDebug = true;
  999. var _GM_xmlhttpRequest, _GM_registerMenuCommand, _GM_notification, _GM_addStyle, _GM_openInTab, _GM_info, _GM_setClipboard;
  1000. function i18n(name, param) {
  1001. return i18nData[name] ? i18nData[name].replace("#t#", param) : name;
  1002. }
  1003.  
  1004. function debug(str, title) {
  1005. if (enableDebug) {
  1006. console.log(
  1007. `%cPagetual v.${_GM_info.script.version}】 ${title ? title : 'debug'}:`,
  1008. 'color: yellow;font-size: large;font-weight: bold;background-color: darkblue;',
  1009. str
  1010. );
  1011. }
  1012. }
  1013.  
  1014. if (typeof GM_xmlhttpRequest !== 'undefined') {
  1015. _GM_xmlhttpRequest = GM_xmlhttpRequest;
  1016. } else if (typeof GM !== 'undefined' && typeof GM.xmlHttpRequest !== 'undefined') {
  1017. _GM_xmlhttpRequest = GM.xmlHttpRequest;
  1018. } else {
  1019. _GM_xmlhttpRequest = (f) => {fetch(f.url, {method: f.method || 'GET', body: f.data, headers: f.headers}).then(response => response.text()).then(data => {f.onload && f.onload({response: data})}).catch(f.onerror && f.onerror())};
  1020. }
  1021. if (typeof GM_registerMenuCommand !== 'undefined') {
  1022. _GM_registerMenuCommand = GM_registerMenuCommand;
  1023. } else if (typeof GM !== 'undefined' && typeof GM.registerMenuCommand !== 'undefined') {
  1024. _GM_registerMenuCommand = GM.registerMenuCommand;
  1025. } else {
  1026. _GM_registerMenuCommand = (s, f) => {debug(s); debug(f);};
  1027. }
  1028. if (typeof GM_info !== 'undefined') {
  1029. _GM_info = GM_info;
  1030. } else if (typeof GM !== 'undefined' && typeof GM.info !== 'undefined') {
  1031. _GM_info = GM.info;
  1032. } else {
  1033. _GM_info = {script: {}};
  1034. }
  1035. if (typeof GM_notification !== 'undefined') {
  1036. _GM_notification = GM_notification;
  1037. } else if (typeof GM !== 'undefined' && typeof GM.notification !== 'undefined') {
  1038. _GM_notification = GM.notification;
  1039. } else {
  1040. _GM_notification = (s) => {showTips(String(s.text || s));};
  1041. }
  1042. if (typeof GM_openInTab !== 'undefined') {
  1043. _GM_openInTab = GM_openInTab;
  1044. } else if (typeof GM !== 'undefined' && typeof GM.openInTab !== 'undefined') {
  1045. _GM_openInTab = GM.openInTab;
  1046. } else {
  1047. _GM_openInTab = (s,t) => {window.open(s); debug(t);};
  1048. }
  1049. if (typeof GM_addStyle !== 'undefined') {
  1050. _GM_addStyle = GM_addStyle;
  1051. } else if (typeof GM !== 'undefined' && typeof GM.addStyle !== 'undefined') {
  1052. _GM_addStyle = GM.addStyle;
  1053. } else {
  1054. _GM_addStyle = cssStr => {
  1055. let styleEle = document.createElement("style");
  1056. styleEle.innerHTML = cssStr;
  1057. document.head.appendChild(styleEle);
  1058. return styleEle;
  1059. };
  1060. }
  1061. if (typeof GM_setClipboard !== 'undefined') {
  1062. _GM_setClipboard = GM_setClipboard;
  1063. } else if (typeof GM !== 'undefined' && typeof GM.setClipboard !== 'undefined') {
  1064. _GM_setClipboard = GM.setClipboard;
  1065. } else {
  1066. _GM_setClipboard = (s, i) => {debug(s); debug(i);};
  1067. }
  1068. const _unsafeWindow = (typeof unsafeWindow === 'undefined') ? window : unsafeWindow;//兼容 ios userscripts 的寫法
  1069. const storage = {
  1070. supportGM: typeof GM_getValue === 'function' && typeof GM_getValue('a', 'b') !== 'undefined',
  1071. supportGMPromise: typeof GM !== 'undefined' && typeof GM.getValue === 'function' && typeof GM.getValue('a', 'b') !== 'undefined' && typeof GM.getValue('a', 'b').then === 'function',
  1072. supportCrossSave: function() {
  1073. return this.supportGM || this.supportGMPromise;
  1074. },
  1075. mxAppStorage: (function() {
  1076. try {
  1077. return window.external.mxGetRuntime().storage;
  1078. } catch(e) {
  1079. }
  1080. })(),
  1081. operaUJSStorage: (function() {
  1082. try {
  1083. return window.opera.scriptStorage;
  1084. } catch(e) {
  1085. }
  1086. })(),
  1087. setItem: function(key, value) {
  1088. if (this.supportGMPromise) {
  1089. GM.setValue(key, value);
  1090. if (value === "" && typeof GM !== 'undefined' && typeof GM.deleteValue !== 'undefined') {
  1091. GM.deleteValue(key);
  1092. }
  1093. } else if (this.supportGM) {
  1094. GM_setValue(key, value);
  1095. if (value === "" && typeof GM_deleteValue !== 'undefined') {
  1096. GM_deleteValue(key);
  1097. }
  1098. } else if (this.operaUJSStorage) {
  1099. this.operaUJSStorage.setItem(key, value);
  1100. } else if (this.mxAppStorage) {
  1101. this.mxAppStorage.setConfig(key, value);
  1102. } else if (window.localStorage) {
  1103. window.localStorage.setItem(key, value);
  1104. }
  1105. },
  1106. getItem: function(key, cb) {
  1107. var value;
  1108. if (this.supportGMPromise) {
  1109. value = GM.getValue(key).then(v => {cb(v);});
  1110. return;
  1111. } else if (this.supportGM) {
  1112. value = GM_getValue(key);
  1113. } else if (this.operaUJSStorage) {
  1114. value = this.operaUJSStorage.getItem(key);
  1115. } else if (this.mxAppStorage) {
  1116. value = this.mxAppStorage.getConfig(key);
  1117. } else if (window.localStorage) {
  1118. value = window.localStorage.getItem(key);
  1119. }
  1120. cb(value);
  1121. }
  1122. };
  1123. async function getData(key) {
  1124. return new Promise((resolve) => {
  1125. storage.getItem(key, value => {
  1126. resolve(value);
  1127. });
  1128. });
  1129. }
  1130. async function getListData(list, key) {
  1131. return new Promise((resolve) => {
  1132. storage.getItem(list, listData => {
  1133. let value;
  1134. if (listData) {
  1135. for(var i = 0; i < listData.length; i++) {
  1136. let data = listData[i];
  1137. if (data.k === key) {
  1138. value = data.v;
  1139. break;
  1140. }
  1141. }
  1142. }
  1143. resolve(value);
  1144. });
  1145. });
  1146. }
  1147. function setListData(list, key, value, length) {
  1148. storage.getItem(list, listData => {
  1149. if (!listData) {
  1150. listData = [];
  1151. }
  1152. listData = listData.filter(data => data && data.k !== key);
  1153. if (value !== "") {
  1154. listData.unshift({k: key, v: value});
  1155. if (listData.length > (length || 100)) {
  1156. listData.pop();
  1157. }
  1158. }
  1159. storage.setItem(list, listData);
  1160. });
  1161. }
  1162. const isMobile = ('ontouchstart' in document.documentElement);
  1163. const configPage = [`https://pagetual.hoothin.com/${lang === 'zh-CN' ? 'cn/' : ''}rule.html`,
  1164. "https://github.com/hoothin/UserScripts/tree/master/Pagetual",
  1165. "https://hoothin.github.io/UserScripts/Pagetual/"];
  1166. const firstRunPage = "https://pagetual.hoothin.com/firstRun";
  1167. const guidePage = /^https?:\/\/.*pagetual.*rule\.html/i;
  1168. const ruleImportUrlReg = /greasyfork\.org\/.*scripts\/438684(\-[^\/]*)?(\/discussions|\/?$|\/feedback)|github\.com\/hoothin\/UserScripts\/(tree\/master\/Pagetual|issues)|^https:\/\/pagetual\.hoothin\.com\/.*firstRun\.html/i;
  1169. const allOfBody = "body>*";
  1170. const mainSel = ["article,.article","[role=main],main,.main,#main","#results"];
  1171. const nextTextReg1 = new RegExp("\u005e\u7ffb\u003f\u005b\u4e0b\u540e\u5f8c\u6b21\u005d\u005b\u4e00\u30fc\u0031\u005d\u003f\u005b\u9875\u9801\u5f20\u5f35\u005d\u007c\u005e\u006e\u0065\u0078\u0074\u005b\u005c\u0073\u005f\u002d\u005d\u003f\u0070\u0061\u0067\u0065\u005c\u0073\u002a\u005b\u203a\u003e\u2192\u00bb\u005d\u003f\u0024\u007c\u6b21\u306e\u30da\u30fc\u30b8\u007c\u005e\u6b21\u3078\u003f\u0024\u007c\u0412\u043f\u0435\u0440\u0435\u0434", "i");
  1172. const nextTextReg2 = new RegExp("\u005e\u0028\u005b\u4e0b\u540e\u5f8c\u6b21\u005d\u005b\u4e00\u30fc\u0031\u005d\u003f\u005b\u7ae0\u8bdd\u8a71\u8282\u7bc0\u5e45\u005d\u007c\u006e\u0065\u0078\u0074\u002e\u003f\u0063\u0068\u0061\u0070\u0074\u0065\u0072\u007c\u00bb\u007c\u003e\u003e\u0029\u0028\u005b\u003a\uff1a\u005c\u002d\u005f\u2014\u005c\u0073\u005c\u002e\u3002\u003e\u0023\u00b7\u005c\u005b\u3010\u3001\uff08\u005c\u0028\u002f\u002c\uff0c\uff1b\u003b\u2192\u005d\u007c\u0024\u0029", "i");
  1173. const lazyImgAttr = ["data-lazy-src", "data-lazy", "data-isrc", "data-url", "data-orig-file", "zoomfile", "file", "original", "load-src", "imgsrc", "real_src", "src2", "origin-src", "data-lazyload", "data-lazyload-src", "data-lazy-load-src", "data-ks-lazyload", "data-ks-lazyload-custom", "data-src", "data-defer-src", "data-actualsrc", "data-cover", "data-original", "data-thumb", "data-imageurl", "data-placeholder", "lazysrc"];
  1174. var rulesData = {uninited: true, firstRun: true, sideController: !isMobile}, ruleUrls, updateDate, clickedSth = false, loadNowNum = 5, autoScrollRate = 50;
  1175. var isPause = false, manualPause = false, isHideBar = false, isLoading = false, curPage = 1, forceState = 0, autoScroll = 0, autoScrollInterval, bottomGap = 1000, autoLoadNum = -1, nextIndex = 0, stopScroll = false, clickMode = false, openInNewTab = 0, charset = "UTF-8", charsetValid = true, urlWillChange = false, hidePageBar = false;
  1176. var tryTimes = 0, showedLastPageTips = false, rate = 1, author = '';
  1177.  
  1178. function getBody(doc) {
  1179. return doc.body || doc.querySelector('body') || doc;
  1180. }
  1181.  
  1182. function getElementByXpath(xpath, doc, contextNode) {
  1183. if (doc && doc.ownerDocument) doc = doc.ownerDocument;
  1184. doc = (doc && doc.evaluate) ? doc : document;
  1185. contextNode = contextNode || doc;
  1186. try {
  1187. let xpathNode = (s, d, n) => {
  1188. let result = d.evaluate(s, n, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null);
  1189. return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue;
  1190. };
  1191. let selSplit = xpath.split(" =>> ");
  1192. if (selSplit.length === 2) {
  1193. let ele = xpathNode(selSplit[0], doc, contextNode);
  1194. if (ele && ele.shadowRoot) {
  1195. return xpathNode(selSplit[1], ele.shadowRoot, ele.shadowRoot);
  1196. }
  1197. } else {
  1198. return xpathNode(xpath, doc, contextNode);
  1199. }
  1200. } catch (err) {
  1201. debug(`Invalid xpath: ${xpath}`);
  1202. }
  1203. return null;
  1204. }
  1205.  
  1206. function getAllElementsByXpath(xpath, contextNode, doc) {
  1207. if (doc && doc.ownerDocument) doc = doc.ownerDocument;
  1208. doc = (doc && doc.evaluate) ? doc : document;
  1209. contextNode = contextNode || doc;
  1210. var result = [];
  1211. try {
  1212. var query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1213. for (var i = 0; i < query.snapshotLength; i++) {
  1214. var node = query.snapshotItem(i);
  1215. if (node.nodeType === 1) {
  1216. result.push(node);
  1217. }
  1218. }
  1219. } catch (err) {
  1220. debug(`Invalid xpath: ${xpath}`);
  1221. }
  1222. return result;
  1223. }
  1224.  
  1225. function isXPath(xpath) {
  1226. if (!xpath) {
  1227. return false;
  1228. }
  1229. return /^\(*(descendant::|\.\/|\/|id\()/.test(xpath);
  1230. }
  1231.  
  1232. function getAllElements(sel, doc, contextNode) {
  1233. try {
  1234. if (sel.indexOf(" =>> ") !== -1) {
  1235. let result = getElement(sel, doc, contextNode);
  1236. return result && [result];
  1237. }
  1238. if (!isXPath(sel)) {
  1239. return doc.querySelectorAll(sel);
  1240. }
  1241. } catch(e) {
  1242. debug(e, 'Error selector');
  1243. }
  1244. return getAllElementsByXpath(sel, contextNode, doc);
  1245. }
  1246.  
  1247. function getElement(sel, doc, contextNode, bySort) {
  1248. try {
  1249. if (!isXPath(sel)) {
  1250. let checkShadow = s => {
  1251. let selSplit = s.split(" =>> ");
  1252. if (selSplit.length === 2) {
  1253. let ele = doc.querySelector(selSplit[0]);
  1254. return ele && ele.shadowRoot && ele.shadowRoot.querySelector(selSplit[1]);
  1255. } else return doc.querySelector(s);
  1256. };
  1257. if (!bySort) {
  1258. return checkShadow(sel);
  1259. } else {
  1260. let selArr = sel.split(",");
  1261. try {
  1262. for (let i = 0; i < selArr.length; i++) {
  1263. let ele = checkShadow(selArr[i].trim());
  1264. if (ele) {
  1265. return ele;
  1266. }
  1267. }
  1268. } catch(e) {
  1269. return checkShadow(sel);
  1270. }
  1271. return null;
  1272. }
  1273. }
  1274. } catch(e) {
  1275. debug(e, 'Error selector');
  1276. }
  1277. return getElementByXpath(sel, doc, contextNode);
  1278. }
  1279.  
  1280. function compareNodeName(node, names) {
  1281. if (!node || !node.nodeName || !node.nodeName.toLowerCase) {
  1282. return false;
  1283. }
  1284. let nodeName = node.nodeName.toLowerCase();
  1285. for (let i = 0; i < names.length; i++) {
  1286. if (names[i] === nodeName) {
  1287. return true;
  1288. }
  1289. }
  1290. return false;
  1291. }
  1292.  
  1293. function geneSelector(ele, addID, exact) {
  1294. let selector = ele.nodeName.toLowerCase();
  1295. //Google id class都是隨機。百度更過分,style script順序都是隨機的
  1296. if (selector !== "html" && selector !== "body") {
  1297. let hasId = false;
  1298. if (addID && ele.id && /^[a-z_][\w\-_]*$/i.test(ele.id)) {
  1299. if (ele.ownerDocument && ele.ownerDocument.querySelectorAll("#" + ele.id).length === 1) {
  1300. hasId = true;
  1301. selector = '#' + ele.id;
  1302. }
  1303. }
  1304. if (!hasId) {
  1305. let className = "";
  1306. if (ele.className) {
  1307. let classList = ele.classList;
  1308. for (let i = 0; i < classList.length; i++) {
  1309. let c = classList[i];
  1310. if (c !== 'scrolling' && /^[a-z_][\w\-_]*$/.test(c) && !/\d{4,}/.test(c)) {
  1311. className += '.' + c;
  1312. }
  1313. }
  1314. selector += className;
  1315. }
  1316. let parent = ele.parentElement;
  1317. if (parent) {
  1318. if (exact) {
  1319. let i, nth = 0, all = 0;
  1320. for (i = 0; i < parent.children.length; i++) {
  1321. if (parent.children[i].nodeName === ele.nodeName) {
  1322. all++;
  1323. if (parent.children[i] === ele) {
  1324. nth = all;
  1325. }
  1326. if (nth > 0 && all > 1) {
  1327. break;
  1328. }
  1329. }
  1330. }
  1331. selector += (all === 1 ? "" : `:nth-of-type(${nth})`);
  1332. } else if (!className && !hasId && parent.children.length > 1 && !compareNodeName(parent, ["html"])) {
  1333. let prevE = ele.previousElementSibling;
  1334. if (prevE && prevE.className) {
  1335. let classList = prevE.classList;
  1336. for (let i = 0; i < classList.length; i++) {
  1337. let c = classList[i];
  1338. if (c !== 'scrolling' && /^[a-z_][\w\-_]*$/.test(c) && !/\d{4,}/.test(c)) {
  1339. className += '.' + c;
  1340. }
  1341. }
  1342. if (className) {
  1343. selector = prevE.nodeName.toLowerCase() + className + "+" + selector;
  1344. }
  1345. }
  1346. if (!className) {
  1347. let i, nth = 0, all = 0;
  1348. for (i = 0; i < parent.children.length; i++) {
  1349. if (parent.children[i].nodeName === ele.nodeName) {
  1350. all++;
  1351. if (parent.children[i] === ele) {
  1352. nth = all;
  1353. }
  1354. if (nth > 0 && all > 1) {
  1355. break;
  1356. }
  1357. }
  1358. }
  1359. selector += (all === 1 ? "" : `:nth-of-type(${nth})`);
  1360. }
  1361. }
  1362. selector = geneSelector(parent, addID, exact) + ' > ' + selector;
  1363. }
  1364. }
  1365. }
  1366. return selector;
  1367. }
  1368.  
  1369. function createXPathFromElement(elm) {
  1370. let allNodes = document.getElementsByTagName('*'), segs;
  1371. for (segs = []; elm && elm.nodeType === 1; elm = elm.parentNode) {
  1372. if (compareNodeName(elm, ["body", "html"])) {
  1373. segs.unshift(elm.localName.toLowerCase());
  1374. continue;
  1375. }
  1376. if (elm.hasAttribute && elm.hasAttribute('id')) {
  1377. var uniqueIdCount = 0;
  1378. for (var n = 0; n < allNodes.length; n++) {
  1379. if (allNodes[n].hasAttribute('id') && allNodes[n].id === elm.id) {
  1380. uniqueIdCount++;
  1381. }
  1382. if (uniqueIdCount > 1) {
  1383. break;
  1384. }
  1385. }
  1386. if ( uniqueIdCount === 1) {
  1387. segs.unshift('id("' + elm.getAttribute('id') + '")');
  1388. return segs.join('/');
  1389. } else {
  1390. segs.unshift(elm.localName.toLowerCase() + '[@id="' + elm.getAttribute('id') + '"]');
  1391. }
  1392. } else if (elm.hasAttribute && elm.hasAttribute('class')) {
  1393. segs.unshift(elm.localName.toLowerCase() + '[@class="' + elm.getAttribute('class') + '"]');
  1394. } else {
  1395. let i, sib;
  1396. for (i = 1, sib = elm.previousSibling; sib; sib = sib.previousSibling) {
  1397. if (sib.localName === elm.localName) {
  1398. i++;
  1399. }
  1400. }
  1401. segs.unshift(elm.localName.toLowerCase() + '[' + i + ']');
  1402. }
  1403. }
  1404. return segs.length ? '/' + segs.join('/') : null;
  1405. }
  1406.  
  1407. const escapeHTMLPolicy = (_unsafeWindow.trustedTypes && _unsafeWindow.trustedTypes.createPolicy) ? _unsafeWindow.trustedTypes.createPolicy('pagetual_default', {
  1408. createHTML: (string, sink) => string
  1409. }) : null;
  1410.  
  1411. function createHTML(html) {
  1412. return escapeHTMLPolicy ? escapeHTMLPolicy.createHTML(html) : html;
  1413. }
  1414.  
  1415. const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
  1416.  
  1417. async function sleep(time) {
  1418. await new Promise((resolve) => {
  1419. setTimeout(() => {
  1420. resolve();
  1421. }, time);
  1422. });
  1423. }
  1424.  
  1425. class RuleParser {
  1426. constructor() {
  1427. this.hpRules = [];
  1428. this.smartRules = [];
  1429. this.customRules = [];
  1430. this.rules = [];
  1431. this.pageDoc = document;
  1432. this.nextLinkHref = null;
  1433. this.nextTitle = "";
  1434. this.oldUrl = "";
  1435. this.curUrl = location.href;
  1436. this.curSiteRule = {};
  1437. }
  1438.  
  1439. async initSavedRules(callback) {
  1440. var self = this;
  1441. let smartRules = await getData("smartRules");
  1442. if (smartRules) self.smartRules = smartRules;
  1443. let hpRules = await getData("hpRules");
  1444. if (hpRules) self.hpRules = hpRules;
  1445. let customRules = await getData("customRules");
  1446. if (customRules) self.customRules = customRules;
  1447. if (_unsafeWindow.pagetualRules && _unsafeWindow.pagetualRules.length) {
  1448. _unsafeWindow.pagetualRules.forEach(rule => {
  1449. rule.isScript = true;
  1450. });
  1451. self.customRules = _unsafeWindow.pagetualRules.concat(self.customRules);
  1452. }
  1453. let rules = await getData("rules");
  1454. if (rules) self.rules = rules;
  1455. callback();
  1456. }
  1457.  
  1458. saveCurSiteRule() {
  1459. /*if(!this.curSiteRule || !this.curSiteRule.url || this.curSiteRule.smart || this.curSiteRule.url.length<13)return;
  1460. this.hpRules=this.hpRules.filter(item=>{return item&&item.url!=this.curSiteRule.url});
  1461. this.hpRules.unshift(this.curSiteRule);
  1462. if(this.hpRules.length>30){
  1463. this.hpRules.pop();
  1464. }
  1465. storage.setItem("hpRules", this.hpRules);*/
  1466. }
  1467.  
  1468. requestJSON(url, callback) {
  1469. _GM_xmlhttpRequest({
  1470. url: url,
  1471. method: 'GET',
  1472. timeout: 1000000,
  1473. headers: {
  1474. 'accept': 'application/json,text/html',
  1475. 'Referer': url,
  1476. },
  1477. onload: function(res) {
  1478. let json = null;
  1479. try {
  1480. json = JSON.parse(res.response || res.responseText);
  1481. } catch(e) {
  1482. debug(e, 'Error json');
  1483. }
  1484. callback(json);
  1485. },
  1486. onerror: function(e) {
  1487. callback(null, e);
  1488. },
  1489. ontimeout: function(e) {
  1490. callback(null, e);
  1491. }
  1492. });
  1493. }
  1494.  
  1495. formatRule(item, from) {
  1496. if (item.data && item.data.url) {
  1497. let result = {
  1498. name: item.name,
  1499. from: from,
  1500. action: item.data.forceIframe === "true" ? 1 : undefined,
  1501. url: item.data.url,
  1502. pageElement: item.data.pageElement,
  1503. nextLink: item.data.nextLink,
  1504. insert: item.data.insertBefore||undefined,
  1505. updatedAt: item.updated_at
  1506. };
  1507. let _css = (item.data.Stylus || '') + (item.data.CSS || '');
  1508. if (_css) result.css = _css;
  1509. if (item.data.bookmarklet) result.pageAction = item.data.bookmarklet;
  1510. return result;
  1511. } else {
  1512. item.from = from;
  1513. return item;
  1514. }
  1515. return null;
  1516. }
  1517.  
  1518. addRuleByUrl(url, from, callback) {
  1519. if (url.indexOf("?") === -1) {
  1520. url = url + "?" + Date.now();
  1521. } else {
  1522. url = url + "&" + Date.now();
  1523. }
  1524. this.requestJSON(url, (json,err) => {
  1525. if (!json) {
  1526. debug(err, "Failed to update " + url + " rules!");
  1527. }
  1528. this.addRules(json, from);
  1529. callback(json, err);
  1530. });
  1531. }
  1532.  
  1533. addRules(rules, from) {
  1534. if (rules && rules.length > 0) {
  1535. let first = -1;
  1536. this.rules = this.rules.filter((item, i) => {
  1537. if (item.from === from) {
  1538. if (first === -1) first = i;
  1539. return false;
  1540. } else return true;
  1541. });
  1542. if (first === -1) first = 0;
  1543. rules.forEach(item => {
  1544. let rule = this.formatRule(item, from);
  1545. if (rule) {
  1546. this.rules.splice(first, 0, rule)
  1547. }
  1548. });
  1549. }
  1550. }
  1551.  
  1552. ruleMatchPre(r) {
  1553. if (r.include) {
  1554. let include;
  1555. if (Array && Array.isArray && Array.isArray(r.include)) {
  1556. include = r.include.every((sel, i) => {
  1557. let ele = getElement(sel, document);
  1558. return !!ele;
  1559. });
  1560. } else include = getElement(r.include, document);
  1561. if (!include) return false;
  1562. }
  1563. if (r.exclude) {
  1564. let exclude;
  1565. if (Array && Array.isArray && Array.isArray(r.exclude)) {
  1566. exclude = !r.exclude.every((sel, i) => {
  1567. let ele = getElement(sel, document);
  1568. return !ele;
  1569. });
  1570. } else exclude = getElement(r.exclude, document);
  1571. if (exclude) return false;
  1572. }
  1573. return true;
  1574. }
  1575.  
  1576. ruleMatchReady(r) {
  1577. let findIndex = 0;
  1578. if (r.nextLink && r.nextLink !== 0) {
  1579. let nextLinkSel = r.nextLink, nextLink;
  1580. if (Array && Array.isArray && Array.isArray(nextLinkSel)) {
  1581. nextLink = !nextLinkSel.every((sel, i) => {
  1582. let ele = getElement(sel, document);
  1583. if (ele) findIndex = i;
  1584. return !ele;
  1585. });
  1586. } else nextLink = getElement(nextLinkSel, document);
  1587. if (!nextLink) return false;
  1588. }
  1589. if (r.pageElement) {
  1590. let pageElementSel = r.pageElement, pageElement;
  1591. if (Array && Array.isArray && Array.isArray(pageElementSel)) {
  1592. pageElementSel = pageElementSel[findIndex];
  1593. }
  1594. pageElement = getElement(pageElementSel, document);
  1595. if (!pageElement) return false;
  1596. }
  1597. if (r.insert) {
  1598. let insertSel = r.insert, insert;
  1599. if (Array && Array.isArray && Array.isArray(insertSel)) {
  1600. insertSel = insertSel[findIndex];
  1601. }
  1602. insert = getElement(insertSel, document);
  1603. if (!insert) return false;
  1604. }
  1605. //if (findIndex !== 0) nextIndex = findIndex;
  1606. return true;
  1607. }
  1608.  
  1609. ruleMatch(r) {
  1610. return this.ruleMatchPre(r) && this.ruleMatchReady(r);
  1611. }
  1612.  
  1613. scrollToShow(sel, doc) {
  1614. let exclude = getElement(sel, doc);
  1615. if (exclude) {
  1616. var actualTop = exclude.offsetTop;
  1617. var current = exclude.offsetParent;
  1618. while (current !== null) {
  1619. actualTop += current.offsetTop;
  1620. current = current.offsetParent;
  1621. }
  1622. getBody(doc).scrollTop = 0;
  1623. doc.documentElement.scrollTop = 0;
  1624. let maxHeight = Math.max(getBody(doc).scrollHeight, doc.documentElement.scrollHeight);
  1625. getBody(doc).scrollTop = actualTop - 10;
  1626. doc.documentElement.scrollTop = actualTop - 10;
  1627. setTimeout(() => {
  1628. while (actualTop < maxHeight) {
  1629. actualTop += 200;
  1630. getBody(doc).scrollTop = actualTop;
  1631. doc.documentElement.scrollTop = actualTop;
  1632. }
  1633. }, 0);
  1634. return false;
  1635. }
  1636. return true;
  1637. }
  1638.  
  1639. waitElement(doc, selArr) {
  1640. if (!selArr) selArr = this.curSiteRule.waitElement;
  1641. if (!Array.isArray(selArr)) {
  1642. selArr = [selArr];
  1643. }
  1644. let includeSel = selArr[0].trim(), excludeSel;
  1645. if (selArr.length === 2) {
  1646. excludeSel = selArr[1].trim().replace(/^!/, '');
  1647. } else if (includeSel.indexOf('!') === 0) {
  1648. excludeSel = includeSel.replace(/^!/, '');
  1649. includeSel = '';
  1650. }
  1651. if (includeSel) {
  1652. let include = getElement(includeSel, doc);
  1653. if (!include) {
  1654. if (doc !== document) {
  1655. getBody(doc).scrollTop = 9999999;
  1656. doc.documentElement.scrollTop = 9999999;
  1657. }
  1658. return false;
  1659. }
  1660. }
  1661. if (doc === document) return true;
  1662. if (excludeSel) {
  1663. if (!this.scrollToShow(excludeSel, doc)) {
  1664. if (!loadingDiv.offsetParent && this.insert.parentNode) {
  1665. this.insertElement(loadingDiv);
  1666. }
  1667. return false;
  1668. }
  1669. }
  1670. return true;
  1671. }
  1672.  
  1673. runPageBar(pageBar) {
  1674. if (this.curSiteRule.pageBar && this.curSiteRule.pageBar !== 0) {
  1675. try {
  1676. ((typeof this.curSiteRule.pageBar === 'function') ? this.curSiteRule.pageBar : Function("pageBar",'"use strict";' + this.curSiteRule.pageBar))(pageBar);
  1677. } catch(e) {
  1678. debug(e);
  1679. }
  1680. }
  1681. }
  1682.  
  1683. runWait(cb) {
  1684. let checkEval = null, waitTime = 0;
  1685. if (this.curSiteRule.waitElement) {
  1686. checkEval = async doc => {
  1687. return await this.waitElement(doc);
  1688. };
  1689. } else if(this.curSiteRule.wait) {
  1690. if (isNaN(this.curSiteRule.wait)) {
  1691. try {
  1692. checkEval = (typeof this.curSiteRule.wait === 'function') ? this.curSiteRule.wait : new AsyncFunction("doc", '"use strict";' + this.curSiteRule.wait);
  1693. } catch(e) {
  1694. debug(e);
  1695. }
  1696. } else {
  1697. waitTime = this.curSiteRule.wait;
  1698. }
  1699. }
  1700. cb(checkEval, waitTime);
  1701. }
  1702.  
  1703. findNoNext() {
  1704. if (!this.curSiteRule || !this.curSiteRule.smart || this.curSiteRule.nextLink === 0 || this.possibleRule) return;
  1705. let self = this;
  1706. self.curSiteRule.nextLink = 0;
  1707. self.smartRules = self.smartRules.filter(item => {return item && item.url !== self.curSiteRule.url;});
  1708. self.smartRules.unshift(self.curSiteRule);
  1709. storage.setItem("smartRules", self.smartRules);
  1710. }
  1711.  
  1712. async getRule(callback) {
  1713. var href = location.href.slice(0, 500);
  1714. if (noRuleTest) {
  1715. this.curSiteRule = {};
  1716. this.curSiteRule.url = href;
  1717. this.curSiteRule.smart = true;
  1718. callback();
  1719. return;
  1720. }
  1721. if (_unsafeWindow.pagetualRule) {
  1722. this.curSiteRule = _unsafeWindow.pagetualRule;
  1723. if (!this.curSiteRule.url) this.curSiteRule.url = ".";
  1724. this.curSiteRule.isScript = true;
  1725. }
  1726. if (this.curSiteRule && this.curSiteRule.url && !this.curSiteRule.smart) {
  1727. let urlReg = new RegExp(this.curSiteRule.url, "i");
  1728. if (urlReg.test(href) && this.ruleMatch(this.curSiteRule)) {
  1729. return callback();
  1730. }
  1731. }
  1732. if (this.possibleRule) {
  1733. let urlReg = new RegExp(this.possibleRule.url, "i");
  1734. if (urlReg.test(href) && this.ruleMatch(this.possibleRule)) {
  1735. this.curSiteRule = this.possibleRule;
  1736. debug(this.curSiteRule, 'Match');
  1737. return callback();
  1738. }
  1739. }
  1740. this.curSiteRule = {};
  1741. var self = this;
  1742.  
  1743. function setRule(r) {
  1744. if (self.preSiteRule) {
  1745. href = location.href.slice(0, 500);
  1746. let urlReg = new RegExp(self.preSiteRule.url, "i");
  1747. if (urlReg.test(href) && self.ruleMatch(self.preSiteRule)) {
  1748. self.curSiteRule = self.preSiteRule;
  1749. return callback();
  1750. }
  1751. }
  1752. if (r.from === 2) {
  1753. delete r.autoLoadNum;
  1754. delete r.history;
  1755. delete r.sideController;
  1756. if (r.pageBar === 0) delete r.pageBar;
  1757. }
  1758. if (!r.smart) {
  1759. self.insert = null;
  1760. self.curSiteRule = r;
  1761. self.preSiteRule = r;
  1762. if (r.enable !== 0) debug(r, 'Match');
  1763. } else if (!self.curSiteRule || !self.curSiteRule.smart) self.curSiteRule = r;
  1764. callback();
  1765. }
  1766.  
  1767. function checkRule(r) {
  1768. if (r.from === 1 && r.url.length <= 13) return false;
  1769. let urlReg = new RegExp(r.url, "i");
  1770. if (urlReg.test(href)) {
  1771. if (!self.ruleMatchPre(r)) return false;
  1772. if (r.url.length > 15 && r.from !== 1) {
  1773. self.possibleRule = r;
  1774. }
  1775. if (r.waitElement) {
  1776. let waitTime = 500;
  1777. let checkReady = () => {
  1778. setTimeout(() => {
  1779. if (!self.waitElement(document, r.waitElement) || !self.ruleMatchReady(r)) {
  1780. checkReady();
  1781. } else {
  1782. setRule(r);
  1783. }
  1784. }, parseInt(waitTime));
  1785. };
  1786. checkReady();
  1787. debug(r, 'Wait for');
  1788. return true;
  1789. } else if (r.wait) {
  1790. let waitTime = 500, checkEval, maxCheckTimes = 50;
  1791. if (isNaN(r.wait)) {
  1792. try {
  1793. checkEval = (typeof r.wait === 'function') ? r.wait : AsyncFunction("doc",'"use strict";' + r.wait);
  1794. } catch(e) {
  1795. debug(e, 'Error when checkeval');
  1796. }
  1797. } else {
  1798. waitTime = r.wait;
  1799. }
  1800. let checkReady = () => {
  1801. if (maxCheckTimes-- <= 0) {
  1802. debug("Wait for rule ready but failed");
  1803. setRule(r);
  1804. return;
  1805. }
  1806. setTimeout(async() => {
  1807. if (!self.ruleMatchReady(r) || (checkEval && !await checkEval(document))) {
  1808. checkReady();
  1809. } else {
  1810. setRule(r);
  1811. }
  1812. }, parseInt(waitTime));
  1813. };
  1814. checkReady();
  1815. debug(r, 'Wait for');
  1816. return true;
  1817. }
  1818. if (r.pinUrl) {
  1819. setRule(r);
  1820. return true;
  1821. }
  1822. if (!self.ruleMatchReady(r)) {
  1823. return false;
  1824. }
  1825. setRule(r);
  1826. return true;
  1827. }
  1828. return false;
  1829. }
  1830.  
  1831. function checkHpRules() {
  1832. for (let i in self.hpRules) {
  1833. let rule = self.hpRules[i];
  1834. if (!rule || !rule.url || rule.smart) continue;
  1835. if (checkRule(rule)) return true;
  1836. }
  1837. return false;
  1838. }
  1839.  
  1840. function checkCustomRules() {
  1841. for (let i in self.customRules) {
  1842. let rule = self.customRules[i];
  1843. if (!rule || !rule.url) continue;
  1844. if (checkRule(rule)) return true;
  1845. }
  1846. return false;
  1847. }
  1848.  
  1849. if (rulesData.customFirst) {
  1850. if (checkCustomRules()) return;
  1851. await sleep(1);
  1852. if (checkHpRules()) return;
  1853. } else {
  1854. if (checkHpRules()) return;
  1855. await sleep(1);
  1856. if (checkCustomRules()) return;
  1857. }
  1858. await sleep(1);
  1859.  
  1860. for (let i in this.smartRules) {
  1861. let rule = this.smartRules[i];
  1862. if (!rule || !rule.url || !rule.smart) continue;
  1863. if (href === rule.url) {
  1864. setRule(rule);
  1865. return;
  1866. } else if (rule.listenUrlChange === false && href.replace(/[^\/]+$/, "") === rule.url) {
  1867. setRule(rule);
  1868. return;
  1869. }
  1870. }
  1871. let r = 0;
  1872. async function searchByTime() {
  1873. while (document.hidden) {
  1874. await sleep(1000);
  1875. }
  1876. setTimeout(() => {
  1877. let end = r + 20;
  1878. end = end > self.rules.length ? self.rules.length : end;
  1879. for (; r < end; r++) {
  1880. let rule = self.rules[r];
  1881. if (checkRule(rule)) return;
  1882. }
  1883. if (end >= self.rules.length) {
  1884. if (document.documentElement && document.documentElement.className && document.documentElement.className.indexOf && document.documentElement.className.indexOf('discourse') !== -1) {
  1885. setRule({url: href.replace(/[^\/]+$/, ""), smart: true, nextLink: 0, listenUrlChange: false});
  1886. } else {
  1887. setRule({url: href, smart: true});
  1888. }
  1889. return;
  1890. } else {
  1891. searchByTime();
  1892. }
  1893. }, 1);
  1894. }
  1895. searchByTime();
  1896. }
  1897.  
  1898. addToHpRules(instead) {
  1899. try {
  1900. if (this.curSiteRule.isScript) return;
  1901. if (!this.hpRules) this.hpRules = [];
  1902. let url = this.curSiteRule && this.curSiteRule.url, self = this;
  1903. let href = location.href.slice(0, 500);
  1904. let matchedRules = this.hpRules.filter(rule => rule != self.curSiteRule && new RegExp(rule.url, "i").test(href) && self.ruleMatch(rule));
  1905. if (url) matchedRules.unshift(this.curSiteRule);
  1906. matchedRules.sort((a, b) => {
  1907. if ((a.include || a.exclude) && (!b.include && !b.exclude)) {
  1908. return -1;
  1909. } else if ((b.include || b.exclude) && (!a.include && !a.exclude)) {
  1910. return 1;
  1911. } else {
  1912. if ((a.nextLink || a.pageElement) && (!b.nextLink && !b.pageElement)) {
  1913. return -1;
  1914. } else if ((b.nextLink || b.pageElement) && (!a.nextLink && !a.pageElement)) {
  1915. return 1;
  1916. } else {
  1917. if (a.url.length > b.url.length) {
  1918. return -1;
  1919. } else if (a.url.length < b.url.length) {
  1920. return 1;
  1921. } else {
  1922. return 0;
  1923. }
  1924. }
  1925. }
  1926. });
  1927. this.hpRules = this.hpRules.filter(item => {
  1928. return item && !matchedRules.find(rule => item.url == rule.url && JSON.stringify(item) == JSON.stringify(rule));
  1929. });
  1930. if (instead) {
  1931. if (url) {
  1932. this.hpRules.unshift(this.curSiteRule);
  1933. matchedRules = [];
  1934. }
  1935. } else {
  1936. this.hpRules = matchedRules.concat(this.hpRules);
  1937. }
  1938. if (matchedRules && matchedRules.length) this.curSiteRule = matchedRules[0];
  1939. if (this.hpRules.length > 30) {
  1940. this.hpRules.pop();
  1941. }
  1942. if (!rulesData.sort) rulesData.sort = [1];
  1943. this.hpRules.sort((a, b) => {
  1944. let aSort = -1, bSort = -1;
  1945. for (let s = 0; s < rulesData.sort.length; s++) {
  1946. if (a.from == rulesData.sort[s]) aSort = s;
  1947. if (b.from == rulesData.sort[s]) bSort = s;
  1948. if (aSort > -1 && bSort > -1) break;
  1949. }
  1950. return aSort - bSort;
  1951. });
  1952. storage.setItem("hpRules", this.hpRules);
  1953. } catch (e) {
  1954. debug(e);
  1955. }
  1956. }
  1957.  
  1958. replaceElement(doc) {
  1959. if (!doc || doc === document) return;
  1960. let replaceElementSel = this.curSiteRule.replaceElement;
  1961. if (replaceElementSel) {
  1962. if (!Array.isArray(replaceElementSel)) {
  1963. replaceElementSel = [replaceElementSel];
  1964. }
  1965. replaceElementSel.forEach(sel => {
  1966. let pageEles = getAllElements(sel, document);
  1967. let replaceEles = getAllElements(sel, doc);
  1968. for (let i = 0; i < pageEles.length; i++) {
  1969. let replaceEle = replaceEles[i];
  1970. let pageEle = pageEles[i];
  1971. if (replaceEle) {
  1972. pageEle.parentNode.replaceChild(replaceEle.cloneNode(true), pageEle);
  1973. } else break;
  1974. }
  1975. });
  1976. }
  1977. }
  1978.  
  1979. refreshByClick() {
  1980. let refreshByClickSel = this.curSiteRule.refreshByClick;
  1981. if (refreshByClickSel) {
  1982. let self = this;
  1983. if (!this.refreshByClickHandler) {
  1984. this.refreshByClickHandler = e => {
  1985. if (!self.refreshing) {
  1986. self.refreshing = true;
  1987. setTimeout(() => {
  1988. self.refreshing = false;
  1989. let checkEles = getAllElements(refreshByClickSel, document);
  1990. for (let i = 0; i < checkEles.length; i++) {
  1991. let curEle = checkEles[i];
  1992. if (curEle === e.target || curEle.contains(e.target)) {
  1993. ruleParser.urlChanged();
  1994. isPause = true;
  1995. if (!ruleParser.nextLinkHref) isLoading = false;
  1996. break;
  1997. }
  1998. }
  1999. }, 300);
  2000. }
  2001. }
  2002. }
  2003. document.removeEventListener("click", this.refreshByClickHandler);
  2004. document.addEventListener("click", this.refreshByClickHandler);
  2005. }
  2006. }
  2007.  
  2008. getValidSize(ele, win) {
  2009. if (!win) return {h: 0, w: 0};
  2010. let eleStyle = win.getComputedStyle(ele);
  2011. if (!ele.offsetParent && (eleStyle.position !== "fixed" || eleStyle.opacity === 0)) {
  2012. return {h: 0, w: 0};
  2013. }
  2014. if (ele.children && ele.children.length === 1 && (ele.offsetWidth === 0 || ele.offsetHeight === 0)) {
  2015. ele = ele.children[0];
  2016. }
  2017. let h = ele.scrollHeight, w;
  2018. if (eleStyle.overflow === "hidden") {
  2019. h = ele.offsetHeight;
  2020. w = ele.offsetWidth;
  2021. } else w = parseInt(ele.offsetWidth || ele.scrollWidth);
  2022. if (h === 0 && ele.parentNode && ele.parentNode.children.length === 1) {
  2023. h = ele.parentNode.scrollHeight;
  2024. }
  2025. while (h === 0 && ele.children && ele.children.length === 1) {
  2026. ele = ele.children[0];
  2027. h = ele.scrollHeight;
  2028. }
  2029. if (h === 0 && ele.children && ele.children.length) {
  2030. let maxChildSize = {h: 0}, self = this;
  2031. [].forEach.call(ele.children, el => {
  2032. let childSize = self.getValidSize(el, win);
  2033. if (childSize.h > maxChildSize.h) maxChildSize = childSize;
  2034. });
  2035. if (maxChildSize.h !== 0) return maxChildSize;
  2036. }
  2037. const maxNum = 2147483647;
  2038. let moreChild = ele.children[0], minOffsetTop = maxNum;
  2039. while (moreChild) {
  2040. if ((moreChild.offsetParent === ele || moreChild.offsetParent === ele.offsetParent)) {
  2041. let curOffsetTop = moreChild.offsetParent === ele.offsetParent ? moreChild.offsetTop - ele.offsetTop : moreChild.offsetTop;
  2042. if (curOffsetTop < minOffsetTop) {
  2043. minOffsetTop = curOffsetTop;
  2044. }
  2045. }
  2046. moreChild = moreChild.nextElementSibling;
  2047. }
  2048. if (h && minOffsetTop !== maxNum && minOffsetTop > 0) {
  2049. h -= minOffsetTop;
  2050. }
  2051. return {h: h, w: w};
  2052. }
  2053.  
  2054. checkTargetChildren(ele, curWin, articleNum, curHeight) {
  2055. let pf = false;
  2056. if (ele.parentNode) {
  2057. let paStyle = curWin.getComputedStyle(ele.parentNode);
  2058. let paDisplay = paStyle.display;
  2059. let paOverflow = paStyle.overflow;
  2060. pf = (paDisplay.indexOf('flex') !== -1 && paStyle.flexDirection.indexOf("row") === 0 && paStyle.flexWrap !== "wrap") || compareNodeName(ele.parentNode, ["ul"]) || paDisplay.indexOf('grid') !== -1 || paOverflow === "hidden";
  2061. }
  2062. let curStyle = curWin.getComputedStyle(ele);
  2063. if (ele.children.length > 1) {
  2064. if (articleNum > 1) {
  2065. return ">article";
  2066. } else {
  2067. let hasText = false;
  2068. for (let i in ele.childNodes) {
  2069. let child = ele.childNodes[i];
  2070. if (child.nodeType === 3 && child.nodeValue.trim() !== '') {
  2071. hasText = true;
  2072. break;
  2073. }
  2074. }
  2075. let gridArea = curStyle.gridArea;
  2076. if (gridArea && gridArea !== "auto" && gridArea !== "auto / auto / auto / auto") {
  2077. return ">*";
  2078. } else {
  2079. let middleChild = ele.children[parseInt(ele.children.length / 2)];
  2080. if ((curStyle.display === 'flex' && curStyle.flexDirection.indexOf("row") === 0 && curStyle.flexWrap !== "wrap") || (curStyle.float === "none" && curStyle.display !== "table-cell" && (rulesData.opacity !== 0 || hasText) && !pf)) {
  2081. return "";
  2082. } else if ((middleChild.style && middleChild.style.position === "absolute" && middleChild.style.left && middleChild.style.top) || compareNodeName(ele, ["ul"]) || curHeight === 0) {
  2083. return "";
  2084. } else {
  2085. return ">*";
  2086. }
  2087. }
  2088. }
  2089. } else if (pf || curStyle.position === "absolute") {
  2090. return ">*";
  2091. }
  2092. return "";
  2093. }
  2094.  
  2095. getPageElement(doc, curWin, dontFind) {
  2096. if (doc === document && this.docElementValid()) {
  2097. return this.docPageElement;
  2098. }
  2099. let pageElement = null;
  2100. let self = this;
  2101. let body = getBody(doc);
  2102. if (this.curSiteRule.pageElement) {
  2103. let pageElementSel = this.curSiteRule.pageElement;
  2104. if (Array && Array.isArray && Array.isArray(pageElementSel)) {
  2105. pageElementSel = pageElementSel[nextIndex < pageElementSel.length ? nextIndex : 0];
  2106. }
  2107. pageElement = getAllElements(pageElementSel, doc);
  2108. if (this.curSiteRule.smart && (!pageElement || pageElement.length === 0)) {
  2109. const childSelMatch = />\s*\*$/;
  2110. const targetChild = childSelMatch.test(pageElementSel);
  2111. if (targetChild) pageElementSel = pageElementSel.replace(childSelMatch, "");
  2112. let pageElementSelSplit = pageElementSel.split(">");
  2113. while(pageElementSelSplit && pageElementSelSplit.length > 5) {
  2114. pageElementSelSplit.shift();
  2115. let tempSel = pageElementSelSplit.join(">");
  2116. pageElement = getAllElements(tempSel, doc);
  2117. if (pageElement && pageElement.length === 1) {
  2118. if (targetChild) {
  2119. pageElement = pageElement.children;
  2120. }
  2121. this.curSiteRule.pageElement = tempSel + (targetChild ? ">*" : "");
  2122. break;
  2123. }
  2124. }
  2125. if (!pageElement || pageElement.length === 0) {
  2126. pageElementSel = pageElementSel.replace(/:nth-of-type\(\d+\)/g, "");
  2127. pageElement = getAllElements(pageElementSel, doc);
  2128. if (pageElement && pageElement.length === 1) {
  2129. if (targetChild) {
  2130. pageElement = pageElement.children;
  2131. }
  2132. this.curSiteRule.pageElement = pageElementSel + (targetChild ? ">*" : "");
  2133. }
  2134. }
  2135. }
  2136. if (this.curSiteRule.smart && pageElement && pageElement.length && curWin && curWin !== _unsafeWindow) {
  2137. if (pageElement.length === 1 && !pageElement[0].src && pageElement[0].innerHTML.trim() === "") {
  2138. pageElement = null;
  2139. } else {
  2140. let parent = pageElement[0].parentNode;
  2141. let loading = parent.querySelector('[class*=loading]');
  2142. if (loading && loading.offsetParent && loading.offsetHeight > parent.offsetHeight>>2) {
  2143. pageElement = null;
  2144. }
  2145. }
  2146. }
  2147. }
  2148. if (pageElement && pageElement.length === 1 && pageElement[0].style.display === 'none') {
  2149. pageElement = [body];
  2150. }
  2151. if (this.curSiteRule.smart && pageElement && pageElement.length > 0 && compareNodeName(pageElement[0], ["tr"])) {
  2152. let mainTr = this.insert.parentNode.querySelectorAll('tr'), mainTdNum = 0, newTdNum = 0;
  2153. mainTr = mainTr[mainTr.length - 1];
  2154. [].forEach.call(mainTr.children, el => {
  2155. if (compareNodeName(el, ["td", "th"])) {
  2156. mainTdNum += el.colSpan || 1;
  2157. }
  2158. });
  2159. [].forEach.call(pageElement[0].children, el => {
  2160. if (compareNodeName(el, ["td", "th"])) {
  2161. newTdNum += el.colSpan || 1;
  2162. }
  2163. });
  2164. if (mainTdNum !== newTdNum) {
  2165. this.curSiteRule.pageElement = this.curSiteRule.pageElement.replace(/> *table.*/, ">table");
  2166. this.getInsert(true);
  2167. return this.getPageElement(doc, curWin, dontFind);
  2168. }
  2169. }
  2170. if ((this.curSiteRule.smart || !this.curSiteRule.pageElement) && (!pageElement || pageElement.length == 0) && curWin && !dontFind) {
  2171. if (!body) return null;
  2172. let bodyHeight = parseInt(body.offsetHeight || body.scrollHeight);
  2173. let curHeight = bodyHeight, curWidth = 0;
  2174. let windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2175. let windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2176. let needCheckNext = (doc == document && this.initNext), nextLeftPos = 0;
  2177. if (needCheckNext && this.initNext.getBoundingClientRect) {
  2178. nextLeftPos = this.initNext.getBoundingClientRect().left;
  2179. }
  2180. function checkElement(ele) {
  2181. if (compareNodeName(ele, ["pre", "code"])) {
  2182. self.curSiteRule.pageElement = geneSelector(ele.parentNode);
  2183. debug(self.curSiteRule.pageElement, 'Page element');
  2184. return [ele.parentNode];
  2185. }
  2186. if (ele.children && ele.children.length === 1) {
  2187. let hasText = false;
  2188. for (let i in ele.childNodes) {
  2189. let child = ele.childNodes[i];
  2190. if (child.nodeType === 3 && child.nodeValue.trim() !== '') {
  2191. hasText = true;
  2192. break;
  2193. }
  2194. }
  2195. if (!hasText) {
  2196. ele = ele.children[0];
  2197. let validSize = self.getValidSize(ele, curWin);
  2198. curHeight = validSize.h;
  2199. curWidth = validSize.w;
  2200. }
  2201. }
  2202. if (compareNodeName(ele, ["picture"]) || !ele.innerText || ele.innerText.trim() === '') {
  2203. self.curSiteRule.pageElement = geneSelector(ele.parentNode) + ">" + ele.nodeName.toLowerCase();
  2204. debug(self.curSiteRule.pageElement, 'Page element');
  2205. let eles = [];
  2206. for (let i = 0; i < ele.parentNode.children.length; i++) {
  2207. let curNode = ele.parentNode.children[i];
  2208. if (curNode.nodeName === ele.nodeName && curNode.id === ele.id && curNode.className === ele.className) {
  2209. eles.push(curNode);
  2210. }
  2211. }
  2212. return eles;
  2213. }
  2214. if (compareNodeName(ele, ["form"]) && ele.parentNode !== getBody(document)) {
  2215. self.curSiteRule.pageElement = geneSelector(ele) + ">*";
  2216. debug(self.curSiteRule.pageElement, 'Page element');
  2217. return ele.children;
  2218. }
  2219. if (ele.children.length === 0 && !self.curSiteRule.pageElement) {
  2220. if (compareNodeName(ele.parentNode, ["p"])) ele = ele.parentNode;
  2221. self.curSiteRule.pageElement = geneSelector(ele.parentNode) + ">" + ele.nodeName.toLowerCase();
  2222. debug(self.curSiteRule.pageElement, 'Page element');
  2223. return getAllElements(self.curSiteRule.pageElement, doc);
  2224. }
  2225. let i, minHeight = curHeight * 0.52, curMaxEle = null, curMaxArea = 0, minWidth = Math.min(curWidth * 0.38, 500);
  2226. let isHori, preOffsetTop = -1;
  2227. let articleNum = 0;
  2228. for (i = 0; i < ele.children.length; i++) {
  2229. let curNode = ele.children[i];
  2230. if (ele !== body && /^H\d$/i.test(curNode.nodeName) && curNode.offsetParent) {
  2231. curMaxEle = null;
  2232. break;
  2233. }
  2234. if (compareNodeName(curNode, ["canvas", "nav"])) continue;
  2235. let curStyle = curWin.getComputedStyle(curNode);
  2236. if (!curNode.offsetParent && (curStyle.position !== "fixed" || curStyle.opacity === 0)) {
  2237. continue;
  2238. }
  2239. if (!compareNodeName(curNode, ["img"]) && curNode.querySelector('img') === null && /^\s*$/.test(curNode.innerText)) continue;
  2240. if (needCheckNext && !curNode.contains(self.initNext) && getElementTop(curNode) > windowHeight) {
  2241. continue;
  2242. }
  2243. if (compareNodeName(curNode, ["article"])) articleNum++;
  2244. let validSize = self.getValidSize(curNode, curWin);
  2245. let h = validSize.h;
  2246. let w = validSize.w;
  2247. if (isNaN(h) || isNaN(w) || !h || !w) continue;
  2248. isHori = Math.abs(preOffsetTop - curNode.offsetTop) <= 20 ? true : (preOffsetTop === -1 && curNode.nextElementSibling && curNode.nextElementSibling.offsetTop === curNode.offsetTop);
  2249. if (isHori && h <= 50) continue;
  2250. /*if (isHori && nextLeftPos && curMaxEle && curWidth > 500 && curHeight > 500) {
  2251. let curRect = curNode.getBoundingClientRect();
  2252. if (curRect.left > windowWidth>>2 && curRect.left <= nextLeftPos && curRect.right > nextLeftPos) {
  2253. continue;
  2254. }
  2255. }*/
  2256. let a = h * w, moreChild = curNode.children[0];
  2257. while (moreChild) {
  2258. let validSize = self.getValidSize(moreChild, curWin);
  2259. let ch = validSize.h;
  2260. let cw = validSize.w;
  2261. if (h < ch) {
  2262. h = ch;
  2263. }
  2264. if (moreChild.innerText !== "" && ch && cw) {
  2265. a += ch * cw;
  2266. }
  2267. moreChild = moreChild.nextElementSibling;
  2268. }
  2269. let isMax = false;
  2270. if (isHori) {
  2271. if (curMaxEle) {
  2272. if (w > curWidth && (windowWidth>>1) > curWidth) {
  2273. isMax = true;
  2274. } else if (w + 300 > curWidth && a > curMaxArea) {
  2275. isMax = true;
  2276. }
  2277. }
  2278. } else {
  2279. if (curMaxEle && curMaxEle.offsetParent === curNode.offsetParent && curMaxEle.offsetTop === curNode.offsetTop) {
  2280. if (curMaxArea * 2 > a) continue;
  2281. }
  2282. isMax = curMaxArea < a;
  2283. }
  2284. if (curMaxEle === null || isMax) {
  2285. if (isHori) {
  2286. if (w < minWidth) {
  2287. continue;
  2288. }
  2289. }
  2290. if (h < minHeight) {
  2291. if (!needCheckNext || h < (minHeight>>1)) {
  2292. continue;
  2293. }
  2294. if (!ele.contains(self.initNext)) {
  2295. continue;
  2296. } else if (!curNode.contains(self.initNext) && h < curHeight >> 1) {
  2297. continue;
  2298. }
  2299. }
  2300. curHeight = h;
  2301. curMaxArea = a;
  2302. curWidth = w;
  2303. curMaxEle = curNode;
  2304. preOffsetTop = curNode.offsetTop;
  2305. }
  2306. }
  2307. let curHeightPercent = curHeight / bodyHeight;
  2308. if (curMaxEle && curHeightPercent <= 0.18) {
  2309. let article;
  2310. for (let i = 0; i < mainSel.length; i++) {
  2311. article = doc.querySelectorAll(mainSel[i]);
  2312. if (article && article.length === 1) break;
  2313. }
  2314. if (article && article.length === 1) {
  2315. article = article[0];
  2316. let childrenEnd = self.checkTargetChildren(article, curWin, articleNum, curHeight);
  2317. self.curSiteRule.pageElement = article.nodeName.toLowerCase() + (article.id ? "#" + article.id : "") + (article.className ? "." + article.className.replace(/ /g, ".") : "") + childrenEnd;
  2318. debug(self.curSiteRule.pageElement, 'Page element');
  2319. return childrenEnd ? article.children : [article];
  2320. }
  2321. curMaxEle = null;
  2322. }
  2323. if (curMaxEle && (!compareNodeName(curMaxEle, ["ul"]) || curHeightPercent > 0.8)) {
  2324. let sameClassNum = 0, hasDifferent = false;
  2325. if (curMaxEle.className) {
  2326. for(i = 0; i < ele.children.length; i++) {
  2327. let curNode = ele.children[i];
  2328. if (curMaxEle !== curNode && curNode.style.display !== 'none' && curMaxEle.className === curNode.className && curMaxEle.nodeName === curNode.nodeName){
  2329. sameClassNum++;
  2330. } else if (curMaxEle.className !== curNode.className) {
  2331. hasDifferent = true;
  2332. }
  2333. }
  2334. }
  2335. if (sameClassNum < 2 || (sameClassNum < 5 && hasDifferent)) {
  2336. return checkElement(curMaxEle);
  2337. }
  2338. }
  2339. if (ele.nodeName === "APP-ROOT") {
  2340. isPause = true;
  2341. debug(ele, "Angular root");
  2342. return null;
  2343. }
  2344. while (compareNodeName(ele, ["p", "br", "td"])) {
  2345. ele = ele.parentNode;
  2346. }
  2347. if (compareNodeName(ele, ["tbody"])) {
  2348. self.curSiteRule.pageElement = geneSelector(ele) + ">*";
  2349. if (ele.children.length > 0 && ele.children[0].querySelector("th")) {
  2350. self.curSiteRule.pageElement += ":not(:first-child)";
  2351. }
  2352. debug(self.curSiteRule.pageElement, 'Page element');
  2353. return ele.children;
  2354. }
  2355. let imgs = ele.querySelectorAll('img');
  2356. if (imgs.length === 1) {
  2357. let img = imgs[0];
  2358. if (img.offsetWidth > ele.offsetWidth / 3 * 2 && img.offsetHeight > ele.offsetHeight / 2) {
  2359. ele = img;
  2360. }
  2361. }
  2362. let childrenEnd = self.checkTargetChildren(ele, curWin, articleNum, curHeight);
  2363. if (childrenEnd) {
  2364. self.curSiteRule.pageElement = geneSelector(ele) + childrenEnd;
  2365. ele = ele.children;
  2366. } else {
  2367. if (ele.scrollHeight === 0 && ele.parentNode.children.length === 1) {
  2368. ele = ele.parentNode;
  2369. }
  2370. self.curSiteRule.pageElement = geneSelector(ele);
  2371. ele = [ele];
  2372. }
  2373. debug(self.curSiteRule.pageElement, 'Page element');
  2374. return ele;
  2375. }
  2376. pageElement = checkElement(body);
  2377. if (doc === document && pageElement && pageElement.length > 0 && self.initNext) {
  2378. let posEle = pageElement[pageElement.length - 1];
  2379. while (posEle && !posEle.offsetParent) {
  2380. posEle = posEle.previousElementSibling || posEle.parentNode;
  2381. }
  2382. if (posEle && posEle.scrollHeight === 0 && posEle.lastElementChild) posEle = posEle.lastElementChild;
  2383. let lastBottom = forceState !== 2 && forceState !== 3 && posEle && getElementBottom(posEle);
  2384. if (lastBottom && getElementTop(self.initNext) - lastBottom > 1000) {
  2385. debug("Stop as too long between next & page element, try to enable Force-Join mode.");
  2386. isPause = true;
  2387. pageElement = [];
  2388. sideController.remove();
  2389. } else {
  2390. if (pageElement.length === 1 && compareNodeName(pageElement[0], ["img"])) {
  2391. self.curSiteRule.pageBar = 0;
  2392. }
  2393. }
  2394. }
  2395. //if(pageElement)this.saveCurSiteRule();
  2396. }
  2397.  
  2398. if (doc !== document) {
  2399. this.setPageElementCss(pageElement);
  2400. this.lazyImgAction(pageElement, doc);
  2401. this.filterEles(doc, pageElement);
  2402. } else if (!this.docPageElement) {
  2403. this.setPageElementCss(pageElement, true);
  2404. this.docPageElement = pageElement;
  2405. this.filterEles(doc, pageElement);
  2406. if (this.nextLinkHref) {
  2407. this.openInNewTab(pageElement);
  2408. }
  2409. }
  2410. return pageElement;
  2411. }
  2412.  
  2413. showAddedElements() {
  2414. if (!this.addedElementsIsHide) return;
  2415. if (this.addedElePool && this.addedElePool.length) {
  2416. this.addedElePool.forEach(ele => {
  2417. ele.classList && ele.classList.remove("pagetual-hide");
  2418. });
  2419. }
  2420. this.addedElementsIsHide = false;
  2421. }
  2422.  
  2423. hideAddedElements() {
  2424. if (this.addedElePool && this.addedElePool.length) {
  2425. this.addedElePool.forEach(ele => {
  2426. ele.classList && ele.classList.add("pagetual-hide");
  2427. });
  2428. }
  2429. this.addedElementsIsHide = true;
  2430. }
  2431.  
  2432. toggleAddedElements() {
  2433. if (this.addedElementsIsHide) {
  2434. this.showAddedElements();
  2435. } else {
  2436. this.hideAddedElements();
  2437. }
  2438. }
  2439.  
  2440. changeVisibility() {
  2441. let contentVisibility = this.curSiteRule.contentVisibility || rulesData.contentVisibility;
  2442. if (!contentVisibility) return;
  2443. if (!this.changingVisibility) {
  2444. clearTimeout(this.changeVisibilityTimer);
  2445. this.changeVisibilityTimer = setTimeout(() => {
  2446. this.changingVisibility = true;
  2447. this.changeVisibility();
  2448. }, 300);
  2449. return;
  2450. }
  2451. this.changingVisibility = false;
  2452. if (!this.visibilityItems || !this.visibilityItems.length || this.visibleIndex < 0) return;
  2453. let tempIndex = this.visibleIndex, findVisible = false, lastVisible = 0;
  2454. let viewPortHeight = window.innerHeight || document.documentElement.clientHeight || getBody(document).clientHeight;
  2455. let checkItem = this.visibilityItems[tempIndex];
  2456. while(checkItem) {
  2457. if (checkItem.offsetParent) {
  2458. if (!checkItem.style.containIntrinsicSize) return;
  2459. let clientRect = checkItem.getBoundingClientRect();
  2460. let top = clientRect && clientRect.top;
  2461. let bottom = clientRect && clientRect.bottom;
  2462. if (bottom > 0 && top < viewPortHeight) {
  2463. if (!findVisible) {
  2464. findVisible = true;
  2465. lastVisible = tempIndex;
  2466. }
  2467. checkItem.style.contentVisibility = "visible";
  2468. } else {
  2469. if (top < viewPortHeight && checkItem.style.contentVisibility === "auto") {
  2470. break;
  2471. } else checkItem.style.contentVisibility = "auto";
  2472. }
  2473. }
  2474. if (tempIndex === 0) break;
  2475. tempIndex--;
  2476. checkItem = this.visibilityItems[tempIndex];
  2477. }
  2478. tempIndex = this.visibleIndex + 1;
  2479. if (findVisible) {
  2480. this.visibleIndex = lastVisible;
  2481. }
  2482. checkItem = this.visibilityItems[tempIndex];
  2483. while(checkItem) {
  2484. if (checkItem.offsetParent) {
  2485. if (!checkItem.style.containIntrinsicSize) return;
  2486. let clientRect = checkItem.getBoundingClientRect();
  2487. let top = clientRect && clientRect.top;
  2488. let bottom = clientRect && clientRect.bottom;
  2489. if (bottom > 0 && top < viewPortHeight) {
  2490. findVisible = true;
  2491. lastVisible = tempIndex;
  2492. checkItem.style.contentVisibility = "visible";
  2493. } else {
  2494. if (findVisible && checkItem.style.contentVisibility === "auto") {
  2495. break;
  2496. } else checkItem.style.contentVisibility = "auto";
  2497. }
  2498. }
  2499. if (tempIndex === this.visibilityItems.length - 1) break;
  2500. tempIndex++;
  2501. checkItem = this.visibilityItems[tempIndex];
  2502. }
  2503. if (findVisible) {
  2504. this.visibleIndex = lastVisible;
  2505. }
  2506. }
  2507.  
  2508. setPageElementCss(pageElement, init) {
  2509. let self = this;
  2510. if (pageElement && pageElement.length > 0) {
  2511. let pageElementCss = this.curSiteRule.pageElementCss || rulesData.pageElementCss;
  2512. if (!pageElementCss && init && !this.nextLinkHref) return;
  2513. let contentVisibility = this.curSiteRule.contentVisibility || rulesData.contentVisibility;
  2514. if (!contentVisibility && !pageElementCss) return;
  2515. [].forEach.call(pageElement, (ele, i) => {
  2516. if (!compareNodeName(ele, ["link", "meta", "style", "script"])) {
  2517. if (pageElementCss) {
  2518. if (pageElementCss !== '0' && !ele.dataset.pagetualPageElement) {
  2519. ele.style.cssText = (ele.style.cssText || '') + pageElementCss;
  2520. ele.dataset.pagetualPageElement = 1;
  2521. }
  2522. }
  2523. if (contentVisibility) {
  2524. ele.style.containIntrinsicSize = `auto ${ele.offsetHeight || self.preVisibleHeight || 100}px`;
  2525. if (ele.style.containIntrinsicSize) {
  2526. if (ele.offsetHeight) self.preVisibleHeight = ele.offsetHeight;
  2527. if (init) {
  2528. ele.style.contentVisibility = "visible";
  2529. self.visibilityItems.push(ele);
  2530. self.visibleIndex++;
  2531. } else {
  2532. ele.style.contentVisibility = emuIframe ? "visible" : "auto";
  2533. }
  2534. }
  2535. }
  2536. }
  2537. });
  2538. }
  2539. }
  2540.  
  2541. clearAddedElements() {
  2542. if (this.addedElePool && this.addedElePool.length) {
  2543. this.addedElePool.forEach(ele => {
  2544. if (ele.parentNode) ele.parentNode.removeChild(ele);
  2545. });
  2546. }
  2547. this.addedElePool = [];
  2548. sideController.remove();
  2549. }
  2550.  
  2551. linkHasHref(link) {
  2552. return link.href && link.href.replace && !this.hrefIsJs(link.href);
  2553. }
  2554.  
  2555. hrefIsJs(href) {
  2556. return /^(javascript|#|$)/.test(href.trim().replace("#p{", "").replace(location.href, ""));
  2557. }
  2558.  
  2559. async querySelectorList(source, list, defaultView) {
  2560. for (let i = 0; i < list.length; i++) {
  2561. await sleep(1);
  2562. let sel = list[i];
  2563. let result = getAllElements(sel, source);
  2564. if (result.length > 0) {
  2565. if (defaultView) {
  2566. for (let i = result.length - 1; i >= 0; i--) {
  2567. let ele = result[i];
  2568. if (isVisible(ele, defaultView)) return ele;
  2569. }
  2570. }
  2571. return result[result.length - 1];
  2572. }
  2573. }
  2574. return null;
  2575. }
  2576.  
  2577. verifyElement(ele) {
  2578. let verifyHandler = e => {
  2579. if (e.nodeType == 9) return true;
  2580. if (e.style.display === "none" || e.getAttribute("aria-disabled") === "true") {
  2581. return false;
  2582. }
  2583. if (e.className) {
  2584. if (/slick|slide|gallery|disabled\s*$/i.test(e.className)) {
  2585. return false;
  2586. } else if (e.classList) {
  2587. if (e.classList.contains('disabled') || e.classList.contains('active')) {
  2588. return false;
  2589. }
  2590. }
  2591. }
  2592. let ariaLabel = e.getAttribute("aria-label");
  2593. if (ariaLabel && /slick|slide|gallery/i.test(ariaLabel)) return false;
  2594. return true;
  2595. };
  2596. if (!ele) return false;
  2597. let i = 0;
  2598. while (ele && i++ < 6) {
  2599. if (!verifyHandler(ele)) return false;
  2600. ele = ele.parentNode;
  2601. }
  2602. return true;
  2603. }
  2604.  
  2605. async getPage(doc, exist) {
  2606. let body = getBody(doc);
  2607. let canSave = false;//發現頁碼選擇器在其他頁對不上,還是別保存了
  2608. let url = this.curUrl.slice(0, 250).replace("index.php?", "?");
  2609. let _url = url.replace(/\.s?html?$/i, "").toLowerCase();
  2610. let pageNum = 1, preStr = "", afterStr = "";
  2611. let pageTwoReg = /^[\/\?&]?[_-]?(p|page)?=?\/?2(\/[^\/]*$|\?|&|$)/i;
  2612. let pageMatch1 = url.match(/(.*[\?&]p(?:age)?=)(\d+)($|[#&].*)/i);
  2613. let doubtTextReg = /^\s*(»|>>)\s*$/;
  2614. if (pageMatch1) {
  2615. preStr = pageMatch1[1];
  2616. pageNum = parseInt(pageMatch1[2]);
  2617. afterStr = pageMatch1[3];
  2618. } else {
  2619. let pageMatch2 = url.match(/(.*[a-z\/\-_](?:p|page)?\/?)(\d+)(\.s?html?$|\/?$)/i);
  2620. if (pageMatch2) {
  2621. preStr = pageMatch2[1];
  2622. pageNum = parseInt(pageMatch2[2]);
  2623. afterStr = pageMatch2[3];
  2624. if (/^\/?$/.test(afterStr) && !/(p(age)?|_|\-|\/)$/.test(preStr)) {
  2625. preStr = "";
  2626. afterStr = "";
  2627. }
  2628. }
  2629. }
  2630. if (pageNum > 999) {
  2631. pageNum = 1;
  2632. preStr = "";
  2633. afterStr = "";
  2634. }
  2635. let curPage = doc, i, cur, jsNext;
  2636. let next1, next2, next3, next4, nextJs1, nextJs2;
  2637. let selectorList = [
  2638. ".page-next>a",
  2639. "a.next_page",
  2640. "#next_page",
  2641. ".curPage+a",
  2642. ".nextPage",
  2643. ".pagination-next>a",
  2644. "a[data-pagination=next]",
  2645. ".pageButtonsCurrent+a",
  2646. "a[class*=nextpage]",
  2647. "li.page-current+li>a",
  2648. "[class^=pag] a[rel=next]",
  2649. "[class^=Pag] [aria-label=next]",
  2650. "[aria-label='Next Page']",
  2651. "[aria-label='Next page']",
  2652. "[aria-label='next page']",
  2653. ".pagination-nav__item--next>a",
  2654. "a.pageright",
  2655. ".page-numbers.current+a",
  2656. "a.page-numbers.next",
  2657. "body [class*=pagination] li.active+span+li>a",
  2658. "body [class*=pagination] li.active+li>a",
  2659. "body [class^=pag] .current+a",
  2660. ".page_current+a",
  2661. "input[value='next']",
  2662. "input[value='Next page']",
  2663. "input[value='下一页']",
  2664. "input[value='下一頁']",
  2665. "a#pb_next",
  2666. "a#rightFix",
  2667. "a#btnPreGn",
  2668. "a.page-next",
  2669. "a.pages-next",
  2670. "a.page.right",
  2671. ".paging>.active+.item",
  2672. "a#next",
  2673. ".next>a",
  2674. ".next>button",
  2675. "a[alt=next]",
  2676. ".pg_area>em+a",
  2677. "button.next:not([disabled])",
  2678. ".btn_next:not([disabled])",
  2679. ".btn-next:not([disabled])",
  2680. "a#linkNext",
  2681. "body a[class*=page__next]",
  2682. "body [class*=pager]>a.next",
  2683. "body [class*=pagination-next]>a",
  2684. "body [class*=pagination-next]>button",
  2685. "body [class*=page--current]+li>a",
  2686. "body [class*=Pages]>.curr+a",
  2687. "body [class*=pagination] [class*=next]",
  2688. ".page>em+a",
  2689. "[name*=nextPage]",
  2690. '//button[contains(@class, "Page")][text()="Next"]',
  2691. '//button[contains(@class, "page")][text()="next"]'
  2692. ];
  2693. let next = await this.querySelectorList(body, selectorList, doc.defaultView);
  2694. if (!next) {
  2695. await sleep(1);
  2696. let nexts = body.querySelectorAll("a.next");
  2697. const prevReg = /^\s*([上前首尾]|previous)/i;
  2698. for (i = 0; i < nexts.length; i++) {
  2699. let n = nexts[i];
  2700. if (this.verifyElement(n) && this.linkHasHref(n) && !prevReg.test(n.innerText.trim())) {
  2701. next = n;
  2702. break;
  2703. }
  2704. }
  2705. }
  2706. if (next) {
  2707. let innerText = next.innerText;
  2708. let isJs = !this.linkHasHref(next);
  2709. if (innerText && nextTextReg2.test(innerText.trim())) {
  2710. if (isJs) {
  2711. if (this.verifyElement(next)) {
  2712. nextJs2 = next;
  2713. }
  2714. } else {
  2715. next2 = next;
  2716. }
  2717. next = null;
  2718. } else {
  2719. if (isJs) {
  2720. if (this.verifyElement(next)) {
  2721. jsNext = next;
  2722. }
  2723. next = null;
  2724. }
  2725. }
  2726. }
  2727. if (!next) {
  2728. await sleep(1);
  2729. next = body.querySelector("a.curr+a") ||
  2730. body.querySelector("div.wp-pagenavi>span.current+a,div.page-nav>span.current+a,div.article-paging>span+a") ||
  2731. body.querySelector(".number>ul>li.active+li>a,.pager a.next");
  2732. }
  2733. if (!next) {
  2734. await sleep(1);
  2735. let pageDiv = body.querySelector(".pages>ul,.page_no>ul");
  2736. if (pageDiv) {
  2737. cur = pageDiv.querySelector("li>b,li>strong");
  2738. if (cur) next = cur.parentNode.nextElementSibling;
  2739. if (next) next = next.querySelector("a");
  2740. }
  2741. }
  2742. if (!next) {
  2743. await sleep(1);
  2744. next = body.querySelector(".pages>a[href='javascript:;']+a");
  2745. if (next && (next.href === "javascript:;" || next.getAttribute("href") === "#")) next = null;
  2746. }
  2747. if (!next) {
  2748. await sleep(1);
  2749. let pageDiv = body.querySelector(".pagination");
  2750. if (pageDiv) {
  2751. cur = pageDiv.querySelector("[class*=current],.page-selected");
  2752. if (cur) next = cur.parentNode.nextElementSibling;
  2753. if (next) next = next.querySelector("a");
  2754. }
  2755. }
  2756. if (!next) {
  2757. await sleep(1);
  2758. cur = body.querySelector(".paginator td strong");
  2759. if (cur) {
  2760. while (cur && !compareNodeName(cur, ["td"])) {
  2761. cur = cur.parentNode;
  2762. }
  2763. next = cur && cur.nextElementSibling;
  2764. if (next) next = next.querySelector("a");
  2765. }
  2766. }
  2767. if (!next) {
  2768. await sleep(1);
  2769. let pageDivs = body.querySelectorAll("[class*=pagination],[class*=Pagination]");
  2770. if (pageDivs && pageDivs.length) {
  2771. for (let i = pageDivs.length - 1; i >= 0; i--) {
  2772. let p = pageDivs[i];
  2773. if (/(next\s*(»|>>|>|›|→|❯)?|&gt;|▶|>|›|→|❯)/i.test(p.title || p.value || '')) {
  2774. next = p.querySelector("a,button,[type='button']") || p;
  2775. break;
  2776. } else if (/^(next\s*(»|>>|>|›|→|❯)?|&gt;|▶|>|›|→|❯)$/i.test((p.innerText || '').trim())) {
  2777. next = p.querySelector("a,button,[type='button']") || p;
  2778. break;
  2779. }
  2780. }
  2781. if (next && !this.linkHasHref(next)) {
  2782. if (!jsNext) jsNext = next;
  2783. next = null;
  2784. }
  2785. }
  2786. }
  2787. if (!next) {
  2788. let isApp = !!body.querySelector("main#app");
  2789. let aTags = body.querySelectorAll("a,button,[type='button'],.btn-action");
  2790. for (i = aTags.length - 1; i >= 0; i--) {
  2791. if (next1) break;
  2792. if (i % 100 === 0) {
  2793. await sleep(1);
  2794. }
  2795. let aTag = aTags[i];
  2796. let title = aTag.title || "";
  2797. let value = aTag.value || "";
  2798. let innerText = aTag.innerText || "";
  2799. if (innerText === "" || (title !== "" && title.length < innerText.length)) {
  2800. innerText = title;
  2801. }
  2802. if (innerText === "" || (value !== "" && value.length < innerText.length)) {
  2803. innerText = value;
  2804. }
  2805. if (innerText !== "") {
  2806. if (innerText === "§") continue;
  2807. innerText = innerText.trim();
  2808. if (innerText.length > 80) continue;
  2809. }
  2810. if (!this.verifyElement(aTag)) continue;
  2811. if (aTag.dataset && aTag.dataset.preview) continue;
  2812. let availableHref = aTag.href && aTag.href.length < 250 && !/^(javascript:|#)/.test(aTag.href);
  2813. if (availableHref && /next\-?(page)?$|\/video\/|\/vod\/play\//i.test(aTag.href)) continue;
  2814. if (compareNodeName(aTag.parentNode, ["blockquote"])) continue;
  2815. if (aTag.previousElementSibling && /\b(play|volume)\b/.test(aTag.previousElementSibling.className)) continue;
  2816. if (aTag.nextElementSibling && /\b(play|volume)\b/.test(aTag.nextElementSibling.className)) continue;
  2817. let isJs = !this.linkHasHref(aTag);
  2818. if (exist && isJs && !aTag.offsetParent) continue;
  2819. if (innerText) {
  2820. innerText = innerText.split(/\n/)[0].replace(/ /g, '');
  2821. if (isJs && /^(»|>>|>|›|→|❯)$/.test(innerText)) continue;
  2822. if (innerText && innerText.length <= 25) {
  2823. if (!next1) {
  2824. if (nextTextReg1.test(innerText)) {
  2825. if (isJs) {
  2826. if (!nextJs1) nextJs1 = aTag;
  2827. } else {
  2828. next1 = aTag;
  2829. }
  2830. }
  2831. }
  2832. if (!next4) {
  2833. if (!next2) {
  2834. if (nextTextReg2.test(innerText) || /nextpage|pager\-older/i.test(aTag.className) || /^(»|>>)$/.test(innerText)) {
  2835. if (isJs) {
  2836. if (!nextJs2) nextJs2 = aTag;
  2837. } else {
  2838. next2 = aTag;
  2839. }
  2840. }
  2841. }
  2842. if (!isApp && !next3 && !isJs) {
  2843. if (/^(next\s*(»|>>|>|›|→|❯)?|&gt;|▶|>|›|→|❯)$/i.test(aTag.textContent) && aTag.parentNode.hasAttribute && !aTag.parentNode.hasAttribute("jsaction")) {
  2844. next3 = aTag;
  2845. }
  2846. }
  2847. }
  2848. }
  2849. }
  2850. if (isJs) continue;
  2851. if (!next4) {
  2852. let prevEle = aTag.previousElementSibling;
  2853. if (prevEle && compareNodeName(prevEle, ["b", "span", "strong"])) {
  2854. if (/^\d+$/.test(aTag.innerText.trim()) && /^\d+$/.test(prevEle.innerText.trim()) && parseInt(aTag.innerText) === parseInt(prevEle.innerText) + 1) {
  2855. next4 = aTag;
  2856. }
  2857. }
  2858. }
  2859. if (urlWillChange) continue;
  2860. if (!next4 && availableHref) {
  2861. let aHref = aTag.href.indexOf("http") === 0 ? aTag.href : this.canonicalUri(aTag.href);
  2862. if (aHref.indexOf(location.hostname) === -1) continue;
  2863. let _aHref = aHref.replace("?&", "?").replace("index.php?", "?");
  2864. if (preStr || afterStr) {
  2865. let _aHrefTrim = _aHref;
  2866. if (preStr) _aHrefTrim = _aHrefTrim.replace(preStr, "");
  2867. if (afterStr) _aHrefTrim = _aHrefTrim.replace(afterStr, "");
  2868. if (_aHrefTrim == pageNum + 1) {
  2869. next4 = aTag;
  2870. }
  2871. } else if (this.curUrl !== aHref) {
  2872. _aHref = _aHref.replace(/\.s?html?$/i, "").toLowerCase();
  2873. if (_aHref.indexOf(_url) !== -1) {
  2874. let pageTwoMatch = _aHref.replace(_url, "").match(pageTwoReg);
  2875. if (pageTwoMatch) {
  2876. afterStr = pageTwoMatch[2];
  2877. next4 = aTag;
  2878. }
  2879. }
  2880. }
  2881. if (next4 && !/page/.test(next4.href)) {
  2882. let curHref = next4.getAttribute("href");
  2883. let curPageReg = new RegExp("(.*)" + (pageNum + 1) + afterStr.replace(/([\.\?])/g, '\\$1'));
  2884. let otherPageHref = curHref.replace(curPageReg, `$1${pageNum}${afterStr}`);
  2885. let otherPageEle = body.querySelector(`a[href='${otherPageHref}']`);
  2886. if (!otherPageEle) {
  2887. otherPageHref = curHref.replace(curPageReg, `$1${pageNum + 2}${afterStr}`);
  2888. otherPageEle = body.querySelector(`a[href='${otherPageHref}']`);
  2889. }
  2890. if (otherPageEle) {
  2891. let parent = otherPageEle.parentNode;
  2892. if (parent && parent.parentNode) {
  2893. parent = parent.parentNode;
  2894. if (parent.parentNode) {
  2895. parent = parent.parentNode;
  2896. }
  2897. }
  2898. if (parent && parent.contains(next4) && !/^\d+$/.test(next4.innerText.trim())) {
  2899. next4 = null;
  2900. }
  2901. }
  2902. }
  2903. }
  2904. }
  2905. if (next2 && doubtTextReg.test(next2.innerText)) {
  2906. next2 = this.verifyNext(next2, doc, false);
  2907. }
  2908. if (nextJs2 && doubtTextReg.test(nextJs2.innerText)) {
  2909. nextJs2 = this.verifyNext(nextJs2, doc, true);
  2910. }
  2911. if (next3) {
  2912. next3 = this.verifyNext(next3, doc, false);
  2913. }
  2914. }
  2915. if (!next) next = next1 || next4 || next3 || next2;
  2916. if (!next && location.pathname + location.search !== "/") {
  2917. next = jsNext || nextJs1 || nextJs2;
  2918. if (next && next.parentNode.className && next.parentNode.className.indexOf && next.parentNode.className.indexOf('tab') !== -1) next = null;
  2919. }
  2920. if (next && next.classList && (next.classList.contains("results-more") || next.classList.contains("no"))) next = null;
  2921. if (next && next.hasAttribute && next.hasAttribute("disabled")) next = null;
  2922. if (next && next.parentNode.href && compareNodeName(next.parentNode, ["a"])) next = next.parentNode;
  2923. return {next:next, canSave:canSave};
  2924. }
  2925.  
  2926. verifyNext(next, doc, isJs) {
  2927. if (!next) return null;
  2928. if (!isJs) {
  2929. let href = next.getAttribute("href");
  2930. if (href && !/\d/.test(next.getAttribute("href"))) {
  2931. return null;
  2932. }
  2933. }
  2934. if (next.previousElementSibling && compareNodeName(next.previousElementSibling, ["br"])) return null;
  2935. let eles = [];
  2936. if (next.innerText && next.innerText.indexOf("\n") === -1) {
  2937. eles = getAllElements(`//${next.nodeName}[text()='${next.innerText}']`, doc);
  2938. }
  2939. if (eles.length >= 2 && eles[0].href !== eles[1].href) {
  2940. next = null;
  2941. } else if (doc === document) {
  2942. let left = getElementLeft(next);
  2943. if (left < 20 || (document.documentElement.scrollWidth > 500 && left < 250)) {
  2944. next = null;
  2945. } else {
  2946. let top = getElementTop(next);
  2947. if (top < 20 || (left < window.innerWidth / 3 && top < window.innerHeight / 3)) {
  2948. next = null;
  2949. } else {
  2950. let bottom = top + next.offsetHeight || 0;
  2951. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  2952. if (scrollH - bottom < 10) next = null;
  2953. }
  2954. }
  2955. }
  2956. return next;
  2957. }
  2958.  
  2959. canonicalUri(src) {
  2960. if (!src) {
  2961. return "";
  2962. }
  2963. if (src.charAt(0) === "#") return this.curUrl + src;
  2964. if (src.charAt(0) === "?") return this.curUrl.replace(/^([^\?#]+).*/, "$1" + src);
  2965. let origin = location.protocol + '//' + location.host;
  2966. let url = this.basePath || origin;
  2967. url = url.replace(/(\?|#).*/, "");
  2968. if (/https?:\/\/[^\/]+$/.test(url)) url = url + '/';
  2969. if (url.indexOf("http") !== 0) url = origin + url;
  2970. var root_page = /^[^\?#]*\//.exec(url)[0],
  2971. root_domain = /^\w+\:\/\/\/?[^\/]+/.exec(root_page)[0],
  2972. absolute_regex = /^\w+\:\/\//;
  2973. this.updateUrl = false;
  2974. while (src.indexOf("../") === 0) {
  2975. src = src.substr(3);
  2976. root_page = root_page.replace(/\/[^\/]+\/$/, "/");
  2977. this.updateUrl = true;
  2978. }
  2979. src = src.replace(/\.\//, "");
  2980. if (/^\/\/\/?/.test(src)) {
  2981. src = location.protocol + src;
  2982. }
  2983. return (absolute_regex.test(src) ? src : ((src.charAt(0) === "/" ? root_domain : root_page) + src));
  2984. }
  2985.  
  2986. getLinkByPage(url, pageNum) {
  2987. if (!url) return null;
  2988. if (this.curSiteRule.pageNum) {
  2989. let result = this.curSiteRule.pageNum;
  2990. let strMatch = result.match(/\{.*?}/);
  2991. if (!strMatch) return null;
  2992. let urlReg = new RegExp("(" + result.replace(strMatch[0], ")\\d+(") + ")", "i");
  2993. let code = strMatch[0].replace(/^{/, "").replace(/}$/, "").replace(/\$p/g, pageNum);
  2994. if (code === pageNum) {
  2995. result = url.replace(urlReg, "$1" + code + "$2");
  2996. } else {
  2997. try {
  2998. code = Function('"use strict";return ' + code)();
  2999. if (code && code % 1 == 0) {
  3000. result = url.replace(urlReg, "$1" + code + "$2");
  3001. } else return null;
  3002. } catch(e) {
  3003. debug(e);
  3004. }
  3005. }
  3006. if (result != url) {
  3007. return result;
  3008. }
  3009. }
  3010. return url.replace(/([&\/\?](p=|page[=\/_-]?))\d+/i, "$1" + pageNum).replace(/([_-])\d+\./i, "$1" + pageNum + ".");
  3011. }
  3012.  
  3013. getPageNumFromUrl(url, defaultPage) {
  3014. if (!url) return defaultPage;
  3015. if (this.curSiteRule.pageNum) {
  3016. let result = this.curSiteRule.pageNum;
  3017. let strMatch = result.match(/\{.*?}/);
  3018. if (!strMatch) return defaultPage;
  3019. let urlReg = new RegExp(".*" + result.replace(strMatch[0], "(\\d+)") + ".*", "i");
  3020. let curShowNum = url.replace(urlReg, "$1");
  3021. if (curShowNum !== url) {
  3022. let code = strMatch[0].replace(/^{/, "").replace(/}$/, "");
  3023. if (code === "$p") {
  3024. return curShowNum;
  3025. } else {
  3026. try {
  3027. let page1 = parseInt(Function('"use strict";return ' + code.replace("$p", "0"))());
  3028. let page2 = parseInt(Function('"use strict";return ' + code.replace("$p", "1"))());
  3029. let numGap = page2 - page1;
  3030. let _page = (parseInt(curShowNum) - page1) / numGap;
  3031. if (_page && _page % 1 === 0) return _page;
  3032. else {
  3033. this.curSiteRule.pageNum = null;
  3034. return defaultPage;
  3035. }
  3036. } catch(e) {
  3037. debug(e);
  3038. }
  3039. }
  3040. } else {
  3041. return defaultPage;
  3042. }
  3043. }
  3044. let pageNum = url.replace(/.*[&\/\?](p=|page[=\/_-]?)(\d+).*/i, "$2");
  3045. return pageNum === url ? defaultPage : (pageNum.length > 4 ? defaultPage : pageNum);
  3046. }
  3047.  
  3048. reachedLastPage() {
  3049. if (rulesData.lastPageTips) {
  3050. showTips(i18n("lastPage"), "", 800);
  3051. }
  3052. _unsafeWindow.postMessage({
  3053. action: "lastPage",
  3054. command: 'pagetual'
  3055. }, '*');
  3056. if (sideController.inited) {
  3057. sideController.frame.classList.add("end");
  3058. }
  3059. }
  3060.  
  3061. async getNextLink(doc, exist) {
  3062. let nextLink = null, page, href;
  3063. let getNextLinkByForm = (form, submitBtn, n) => {
  3064. let params = [];
  3065. let formData = new FormData(form);
  3066. if (submitBtn && submitBtn.getAttribute) {
  3067. let btnValue, btnName;
  3068. btnName = submitBtn.getAttribute("name");
  3069. btnValue = submitBtn.getAttribute("value");
  3070. if (btnName && btnValue) params = [btnName + "=" + encodeURIComponent(btnValue)];
  3071. }
  3072. for (let [key, value] of formData) {
  3073. if (n && /^(p|page)$/i.test(key)) {
  3074. params.push(key + '=' + n);
  3075. } else {
  3076. params.push(key + '=' + encodeURIComponent(value));
  3077. }
  3078. }
  3079. params = params.join('&');
  3080. return form.action + (form.action.indexOf('?') === -1 ? '?' : '&') + params + (form.method === 'post' ? '#p{' + params + '}' : '');
  3081. };
  3082. if (this.curSiteRule.pageElementByJs) {
  3083. this.nextLinkHref = "#";
  3084. return true;
  3085. } else if (this.curSiteRule.nextLinkByJs) {
  3086. try {
  3087. let over = _url => {};
  3088. let targetUrl = await ((typeof this.curSiteRule.nextLinkByJs === 'function') ? this.curSiteRule.nextLinkByJs : new AsyncFunction("doc", '"use strict";' + this.curSiteRule.nextLinkByJs))(doc);
  3089. if (targetUrl) nextLink = {href: targetUrl};
  3090. } catch(e) {
  3091. debug(e);
  3092. }
  3093. } else if (this.curSiteRule.nextLinkByUrl) {
  3094. let targetUrl = this.curUrl.replace(new RegExp(this.curSiteRule.nextLinkByUrl[0], "i"), this.curSiteRule.nextLinkByUrl[1]);
  3095. if (targetUrl !== this.curUrl) {
  3096. let includeSel = this.curSiteRule.nextLinkByUrl[2];
  3097. let excludeSel = this.curSiteRule.nextLinkByUrl[3];
  3098. if (includeSel) {
  3099. includeSel = includeSel.trim();
  3100. if (!getElement(includeSel, doc)) {
  3101. this.nextLinkHref=false;
  3102. return null;
  3103. }
  3104. }
  3105. if (excludeSel) {
  3106. excludeSel = excludeSel.trim();
  3107. if (getElement(excludeSel, doc)) {
  3108. this.nextLinkHref=false;
  3109. return null;
  3110. }
  3111. }
  3112. let reps = targetUrl.match(/{.*?}/g);
  3113. if (reps) {
  3114. reps.forEach(rep => {
  3115. let code = rep.replace("{", "").replace("}", "").replace(/\(\)/g, "0");
  3116. let result = code.match(/^(\d*)\+1$/);
  3117. if (result) {
  3118. result = parseInt(result[1] || 1) + 1;
  3119. } else {
  3120. try {
  3121. result = Function('"use strict";return ' + code)();
  3122. } catch(e) {
  3123. debug(e);
  3124. }
  3125. }
  3126. targetUrl = targetUrl.replace(rep, result);
  3127. });
  3128. }
  3129. }
  3130. nextLink = {href: targetUrl};
  3131. } else if (typeof this.curSiteRule.nextLink !== 'undefined') {
  3132. let nextLinkSel = this.curSiteRule.nextLink;
  3133. if (nextLinkSel != 0) {
  3134. if (Array && Array.isArray && Array.isArray(nextLinkSel)) {
  3135. nextLink = getElement(nextLinkSel[nextIndex], doc, null, true);
  3136. if (!nextLink && curPage === 1 && nextIndex !== 0) {
  3137. nextIndex = 0;
  3138. nextLink = getElement(nextLinkSel[nextIndex], doc, null, true);
  3139. }
  3140. } else nextLink = getElement(nextLinkSel, doc, null, true);
  3141. }
  3142. if (nextLink && (this.curSiteRule.action == 0 || this.curSiteRule.action == 1 || this.curSiteRule.action == 2)) {
  3143. let form = doc.querySelector('#search-form');
  3144. if (!nextLink.href && nextLink.hasAttribute && nextLink.hasAttribute("onclick") && form) {
  3145. if (/^\d+$/.test(nextLink.innerText)) {
  3146. nextLink.href = getNextLinkByForm(form, nextLink, nextLink.innerText);
  3147. }
  3148. } else if (compareNodeName(nextLink, ["input"]) || nextLink.type === "submit") {
  3149. form = nextLink.parentNode;
  3150. while (form) {
  3151. if (compareNodeName(form, ["form"])) break;
  3152. else form = form.parentNode;
  3153. }
  3154. if (form) {
  3155. nextLink.href = getNextLinkByForm(form, nextLink);
  3156. }
  3157. }
  3158. if (nextLink.href && this.curSiteRule.action != 0) {
  3159. nextLink.href = nextLink.href.replace(/#p{.*/, "");
  3160. }
  3161. }
  3162. } else {
  3163. page = await this.getPage(doc, exist);
  3164. nextLink = page.next;
  3165. if (nextLink) {
  3166. if (compareNodeName(nextLink, ["input"]) || nextLink.type === "submit") {
  3167. if (!/next/i.test(nextLink.getAttribute("onclick"))) {
  3168. let form = nextLink.parentNode;
  3169. while (form) {
  3170. if (compareNodeName(form, ["form"])) break;
  3171. else form = form.parentNode;
  3172. }
  3173. if (form) {
  3174. nextLink.href = getNextLinkByForm(form, nextLink);
  3175. }
  3176. }
  3177. }
  3178. let parent = nextLink;
  3179. while (parent && !compareNodeName(parent, ["body"])) {
  3180. if (parent.hasAttribute && parent.hasAttribute("disabled")) {
  3181. this.nextLinkHref = false;
  3182. return null;
  3183. }
  3184. if (parent.className && parent.classList) {
  3185. if (parent.classList.contains("noClick") || parent.classList.contains("no-pages") || parent.classList.contains("disabled")) {
  3186. this.nextLinkHref = false;
  3187. return null;
  3188. }
  3189. }
  3190. if (parent.style && parent.style.display === "none") {
  3191. this.nextLinkHref = false;
  3192. return null;
  3193. }
  3194. parent = parent.parentNode;
  3195. }
  3196. if (doc === document) {
  3197. if (!this.linkHasHref(nextLink)) {
  3198. if ((clickedSth && this.curSiteRule.smart) || !isVisible(nextLink, _unsafeWindow)) {
  3199. this.nextLinkHref = false;
  3200. return null;
  3201. }
  3202. let video = document.querySelector("video,iframe[id*=play],[id*=play]>iframe,iframe[src*=player],iframe[src*=m3u8]");
  3203. if (video) {
  3204. if (video.offsetParent && video.name !== 'pagetual-iframe') {
  3205. let scrollWidth = video.scrollWidth || video.offsetWidth;
  3206. let scrollHeight = video.scrollHeight || video.offsetHeight;
  3207. if (compareNodeName(video, ["iframe"])) {
  3208. } else if (scrollWidth > 100 && scrollHeight > 100) {
  3209. let winWidth = window.innerWidth || document.documentElement.clientWidth;
  3210. let winHeight = window.innerHeight || document.documentElement.clientHeight;
  3211. if (scrollWidth > winWidth>>1 && scrollHeight > winHeight>>1) {
  3212. debug("Disable when large media found");
  3213. } else {
  3214. video = null;
  3215. }
  3216. } else {
  3217. video = null;
  3218. }
  3219. } else {
  3220. video = null;
  3221. }
  3222. }
  3223. if (video) {
  3224. isPause = true;
  3225. this.clearAddedElements();
  3226. this.nextLinkHref = false;
  3227. return null;
  3228. }
  3229. }
  3230.  
  3231. let nextLinkCs = _unsafeWindow.getComputedStyle(nextLink);
  3232. if (nextLinkCs.cursor === "not-allowed") {
  3233. this.nextLinkHref = false;
  3234. return null;
  3235. }
  3236. this.initNext = nextLink;
  3237. }
  3238. let form = doc.querySelector('#search-form');
  3239. if (!nextLink.href && nextLink.hasAttribute("onclick") && form) {
  3240. if (form && /^\d+$/.test(nextLink.innerText)) {
  3241. href = getNextLinkByForm(form, nextLink, nextLink.innerText);
  3242. }
  3243. }
  3244. }
  3245. }
  3246. if (nextLink) {
  3247. if (!this.checkStopSign(nextLink, doc)) {
  3248. if (curPage > 1) {
  3249. this.reachedLastPage();
  3250. }
  3251. return null;
  3252. }
  3253. if (this.curSiteRule.action == 3) {
  3254. if (doc == document) debug(nextLink, 'Next link');
  3255. this.nextLinkHref = '#';
  3256. } else {
  3257. let needUrl = (this.curSiteRule.action == 0 || this.curSiteRule.action == 1 || this.curSiteRule.action == 2);
  3258. if (!href) href = nextLink.href;
  3259. if (href && nextLink.getAttribute) {
  3260. let _href = nextLink.getAttribute("href");
  3261. if (_href) {
  3262. let realHref = _href.replace(location.href, "");
  3263. if (realHref.charAt(0) === "#" || realHref === "?"){
  3264. href = "#";
  3265. } else {
  3266. href = _href;
  3267. }
  3268. } else if (_href === "") {
  3269. href = _href;
  3270. }
  3271. }
  3272.  
  3273. if (needUrl && (href === "" || href === null)) {
  3274. this.nextLinkHref = false;
  3275. } else if (needUrl && /^(javascript:|#)/.test(href)) {
  3276. this.nextLinkHref = false;
  3277. } else {
  3278. this.nextLinkHref = (href && !/^(javascript:|#)/.test(href)) ? this.canonicalUri(href) : "#";
  3279. let tempUrl = this.nextLinkHref;
  3280. if (tempUrl !== "#" && (this.compareUrl(tempUrl, this.initUrl) || this.compareUrl(tempUrl, this.curUrl) || this.compareUrl(tempUrl, this.curUrl + "#") || this.compareUrl(tempUrl, this.oldUrl) || this.compareUrl(tempUrl, this.oldUrl + "#"))) {
  3281. this.nextLinkHref = false;
  3282. } else if (doc === document) {
  3283. debug(nextLink, 'Next link');
  3284. }
  3285. }
  3286. }
  3287. } else {
  3288. this.nextLinkHref = false;
  3289. }
  3290. this.nextLinkEle = nextLink;
  3291. this.preload();
  3292. return nextLink;
  3293. }
  3294.  
  3295. compareUrl(url1, url2) {
  3296. if (url1 === url2) return true;
  3297. if (!url1 || !url2) return false;
  3298. let url1Arr = url1.split("?");
  3299. let url2Arr = url2.split("?");
  3300. if (url1Arr[0] != url2Arr[0]) return false;
  3301. if (!url1Arr[1] || !url2Arr[1]) return false;
  3302. url1Arr = url1Arr[1].split("&").sort().join("&");
  3303. url2Arr = url2Arr[1].split("&").sort().join("&");
  3304. return url1Arr === url2Arr;
  3305. }
  3306.  
  3307. filterEles(doc, eles) {
  3308. let filter = this.curSiteRule.filter;
  3309. if (!filter || !eles || eles.length === 0) return;
  3310. if (eles.length === 1) {
  3311. eles = eles[0].children;
  3312. if (eles.length === 1) {
  3313. eles = eles[0].children;
  3314. }
  3315. }
  3316. if (typeof filter === "string") {
  3317. if (/^\d+$/.test(filter)) {
  3318. filter = {count: parseInt(filter)};
  3319. } else filter = {words: filter};
  3320. }
  3321. [].forEach.call(eles, ele => {
  3322. if (!ele.parentNode) return;
  3323. let canKeep = (() => {
  3324. let innerText = (ele.innerText && ele.innerText.trim()) || "";
  3325. if (filter.count) {
  3326. if (innerText.length < filter.count) return false;
  3327. }
  3328. if (filter.words) {
  3329. let wordsRegExp = new RegExp(filter.words, "i");
  3330. if (innerText && wordsRegExp.test(innerText)) return false;
  3331. }
  3332. if (filter.link) {
  3333. let linkRegExp = new RegExp(filter.link, "i");
  3334. if (compareNodeName(ele, ["a"]) && linkRegExp.test(ele.href)) return false;
  3335. let aChildren = ele.querySelectorAll("a");
  3336. for (let i = 0; i < aChildren.length; i++) {
  3337. let child = aChildren[i];
  3338. if (linkRegExp.test(child.href)) return false;
  3339. }
  3340. }
  3341. if (filter.selector) {
  3342. if (getElement(filter.selector, doc, ele)) return false;
  3343. }
  3344. return true;
  3345. })();
  3346. if (!canKeep) {
  3347. ele.parentNode.removeChild(ele);
  3348. }
  3349. });
  3350. }
  3351.  
  3352. checkStopSign(nextLink, doc) {
  3353. if (this.curSiteRule.stopSign) {
  3354. let typeArray = Array && Array.isArray && Array.isArray(this.curSiteRule.stopSign);
  3355. let typeObject = !typeArray && (this.curSiteRule.stopSign.include || this.curSiteRule.stopSign.exclude || this.curSiteRule.stopSign.pageNum);
  3356. if (typeArray || typeObject) {
  3357. let includeSel, excludeSel, curSign, maxSign;
  3358. if (typeArray) {
  3359. includeSel = this.curSiteRule.stopSign[0];
  3360. excludeSel = this.curSiteRule.stopSign[1];
  3361. curSign = this.curSiteRule.stopSign[2];
  3362. maxSign = this.curSiteRule.stopSign[3];
  3363. if (Array && Array.isArray && Array.isArray(includeSel) && !curSign) {
  3364. curSign = includeSel;
  3365. includeSel = false;
  3366. }
  3367. if (excludeSel && Array && Array.isArray && Array.isArray(excludeSel) && !maxSign) {
  3368. maxSign = excludeSel;
  3369. excludeSel = false;
  3370. }
  3371. } else {
  3372. includeSel = this.curSiteRule.stopSign.include;
  3373. excludeSel = this.curSiteRule.stopSign.exclude;
  3374. curSign = this.curSiteRule.stopSign.pageNum;
  3375. }
  3376. if (includeSel) {
  3377. includeSel = includeSel.trim();
  3378. if (!getElement(includeSel, doc)) {
  3379. isPause = true;
  3380. this.nextLinkHref = false;
  3381. return false;
  3382. }
  3383. }
  3384. if (excludeSel) {
  3385. excludeSel = excludeSel.trim();
  3386. if (getElement(excludeSel, doc)) {
  3387. isPause = true;
  3388. this.nextLinkHref = false;
  3389. return false;
  3390. }
  3391. }
  3392. if (curSign) {
  3393. if (!maxSign) maxSign = curSign.slice(2);
  3394. let currentEle = getElement(curSign[0], doc);
  3395. let maxEle = getElement(maxSign[0], doc);
  3396. if (currentEle && maxEle) {
  3397. let currentSignNum, maxSignNum;
  3398. if (/\(.*\)/.test(curSign[1])) {
  3399. currentSignNum = currentEle.innerText.match(new RegExp(curSign[1]));
  3400. if (currentSignNum) currentSignNum = currentSignNum[1];
  3401. } else if (currentEle.getAttribute) {
  3402. currentSignNum = currentEle.getAttribute(curSign[1]);
  3403. }
  3404. if (/\(.*\)/.test(maxSign[1])) {
  3405. maxSignNum = maxEle.innerText.match(new RegExp(maxSign[1]));
  3406. if (maxSignNum) maxSignNum = maxSignNum[1];
  3407. } else if (maxEle.getAttribute) {
  3408. maxSignNum = maxEle.getAttribute(maxSign[1]);
  3409. }
  3410. if (currentSignNum && maxSignNum && currentSignNum == maxSignNum) {
  3411. isPause = true;
  3412. this.nextLinkHref = false;
  3413. return false;
  3414. }
  3415. }
  3416. }
  3417. } else {
  3418. try {
  3419. let stopSign = ((typeof this.curSiteRule.stopSign === 'function') ? this.curSiteRule.stopSign : Function("doc", "nextLink", '"use strict";' + this.curSiteRule.stopSign))(doc, nextLink);
  3420. if (stopSign) {
  3421. isPause = true;
  3422. this.nextLinkHref = false;
  3423. return false;
  3424. }
  3425. } catch(e) {
  3426. debug(e);
  3427. }
  3428. }
  3429. }
  3430. return true;
  3431. }
  3432.  
  3433. preloadImageHandler() {
  3434. if (this.preloadingImage || !this.unCheckedImgs.length) return;
  3435. this.preloadingImage = true;
  3436. setTimeout(() => {
  3437. this.preloadingImage = false;
  3438. this.preloadImageHandler();
  3439. }, 10);
  3440. let iSrc = this.unCheckedImgs.shift();
  3441. let img = document.createElement('img');
  3442. img.src = iSrc;
  3443. this.preloadDiv.appendChild(img);
  3444. }
  3445.  
  3446. preload() {
  3447. if (!rulesData.preload) return;
  3448. if (this.curSiteRule.preload === 0) return;
  3449. if (!this.nextLinkHref || this.nextLinkHref == "#") return;
  3450. if (this.readyStateUnComplete) return;
  3451. if (document.readyState !== 'complete') {
  3452. this.readyStateUnComplete = true;
  3453. let self = this;
  3454. window.addEventListener("load", e => {
  3455. self.readyStateUnComplete = false;
  3456. self.preload();
  3457. });
  3458. return;
  3459. }
  3460. let self = this, url = this.nextLinkHref;
  3461. let postParams = url.match(/#p{(.*)}$/);
  3462. if (postParams) {
  3463. postParams = postParams[1];
  3464. url = url.replace(/#p{.*/, "");
  3465. }
  3466. _GM_xmlhttpRequest({
  3467. url: url,
  3468. method: postParams ? 'POST' : 'GET',
  3469. data: postParams,
  3470. overrideMimeType: 'text/html;charset=' + charset,
  3471. headers: {
  3472. 'Referer': location.href,
  3473. 'User-Agent': navigator.userAgent,
  3474. "Content-Type": (postParams ? "application/x-www-form-urlencoded" : "text/html") + ";charset=" + charset,
  3475. },
  3476. timeout: 10000,
  3477. onload: function(res) {
  3478. var doc = null;
  3479. try {
  3480. doc = document.implementation.createHTMLDocument('');
  3481. doc.documentElement.innerHTML = createHTML(res.response);
  3482. var body = getBody(doc);
  3483. if (!self.preloadDiv) {
  3484. self.preloadDiv = document.createElement('div');
  3485. self.preloadDiv.id = "pagetual-preload";
  3486. self.preloadDiv.style.cssText = 'display:none!important;';
  3487. getBody(document).appendChild(self.preloadDiv);
  3488. self.checkedImgs = {};
  3489. self.unCheckedImgs = [];
  3490. }
  3491. let code = self.curSiteRule.preloadImages;
  3492. if (code) {
  3493. let imgSrcArr = new Function("doc", '"use strict";' + code)(doc);
  3494. if (imgSrcArr && imgSrcArr.length) {
  3495. imgSrcArr.forEach(imgSrc => {
  3496. if (imgSrc && !self.checkedImgs[imgSrc]) {
  3497. self.checkedImgs[imgSrc] = true;
  3498. self.unCheckedImgs.push(imgSrc);
  3499. }
  3500. });
  3501. }
  3502. self.preloadImageHandler();
  3503. } else if (code !== 0 && code !== false) {
  3504. if (body && body.firstChild) {
  3505. self.lazyImgAction(body.children, doc);
  3506. }
  3507. [].forEach.call(doc.images, i => {
  3508. let iSrc = i.src;
  3509. if (iSrc && !self.checkedImgs[iSrc]) {
  3510. self.checkedImgs[iSrc] = true;
  3511. self.unCheckedImgs.push(iSrc);
  3512. }
  3513. });
  3514. self.preloadImageHandler();
  3515. }
  3516. }
  3517. catch(e) {
  3518. debug(e);
  3519. return;
  3520. }
  3521. }
  3522. });
  3523. }
  3524.  
  3525. getInsert(refresh) {
  3526. if (refresh) {
  3527. this.insert = null;
  3528. }
  3529. if (this.insert && this.insert.parentNode && document.documentElement.contains(this.insert)) {
  3530. return this.insert;
  3531. }
  3532. if (this.curSiteRule.insert) {
  3533. let insertSel = this.curSiteRule.insert;
  3534. if (Array && Array.isArray && Array.isArray(insertSel)) {
  3535. insertSel = insertSel[nextIndex < insertSel.length ? nextIndex : 0];
  3536. }
  3537. this.insert = getElement(insertSel, document, null, true);
  3538. } else {
  3539. this.docPageElement = null;
  3540. let pageElement = this.getPageElement(document, _unsafeWindow);
  3541. if (this.curSiteRule.smart && this.nextLinkHref == "#" && this.curSiteRule.pageElement === 'body') {
  3542. debug("Stop as jsNext & whole body");
  3543. isPause = true;
  3544. return null;
  3545. }
  3546. if (pageElement && pageElement.length > 0) {
  3547. let pEIndex = pageElement.length - 1;
  3548. let pELast = pageElement[pEIndex];
  3549. while(pELast && compareNodeName(pELast, ["link", "meta", "style", "script"])) {
  3550. pEIndex--;
  3551. pELast = pageElement[pEIndex];
  3552. }
  3553. this.insert = pELast.nextSibling ? pELast.nextSibling : pELast.parentNode.appendChild(document.createTextNode(' '));
  3554. }
  3555. }
  3556. return this.insert;
  3557. }
  3558.  
  3559. pageInit(doc, eles) {
  3560. let code = this.curSiteRule.pageInit;
  3561. if (code) {
  3562. let initFunc = ((typeof code == 'function') ? code : Function("doc", "eles", '"use strict";' + code));
  3563. let checkInit = (resolve) => {
  3564. try {
  3565. if (initFunc(doc, eles) === false) {
  3566. setTimeout(() => {
  3567. checkInit(resolve);
  3568. }, 100);
  3569. } else {
  3570. resolve(true);
  3571. }
  3572. } catch(e) {
  3573. resolve(false);
  3574. debug(e);
  3575. }
  3576. };
  3577. return new Promise((resolve) => {
  3578. checkInit(function(e) {
  3579. resolve(e)
  3580. });
  3581. })
  3582. }
  3583. }
  3584.  
  3585. pageAction(doc, eles) {
  3586. let code = this.curSiteRule.pageAction;
  3587. if (code) {
  3588. try {
  3589. ((typeof code == 'function') ? code : Function("doc", "eles", '"use strict";' + code))(doc, eles);
  3590. } catch(e) {
  3591. debug(e);
  3592. }
  3593. }
  3594. this.openInNewTab(eles);
  3595. this.replaceElement(doc);
  3596. }
  3597.  
  3598. openInNewTab(eles) {
  3599. if (openInNewTab) {
  3600. [].forEach.call(eles, ele => {
  3601. if (compareNodeName(ele, ["a"]) && ele.href && !/^(mailto:|javascript:)|#/.test(ele.href)) {
  3602. ele.setAttribute('target', openInNewTab == 1 ? '_blank' : '_self');
  3603. } else {
  3604. [].forEach.call(ele.querySelectorAll('a[href]:not([href^="mailto:"]):not([href^="javascript:"]):not([href^="#"])'), a => {
  3605. if (openInNewTab == 1) {
  3606. a.setAttribute('target', '_blank');
  3607. if (a.getAttribute('onclick') == 'atarget(this)') {
  3608. a.removeAttribute('onclick');
  3609. }
  3610. } else a.setAttribute('target', '_self');
  3611. });
  3612. }
  3613. });
  3614. }
  3615. }
  3616.  
  3617. lazyImgAction(eles, doc) {
  3618. if (!eles || eles.length == 0) return;
  3619. let lazyImgSrc = this.curSiteRule.lazyImgSrc;
  3620. if (lazyImgSrc === 0 || lazyImgSrc === '0') return;
  3621. let imgLazyAttrs = [];
  3622. let lazyAttrs = ["div[data-thumb]|data-src", "div.img|data-src", "div.lazy|data-src", "div.lazy|data-original", "a.lazy|data-bg", "a.lazyload|data-original"];
  3623. let removeProps = [];
  3624. let setLazyImg = img => {
  3625. let realSrc;
  3626. imgLazyAttrs.forEach(attr => {
  3627. realSrc = img.getAttribute(lazyImgSrc[0]);
  3628. if (realSrc) {
  3629. removeProps.forEach(prop => {
  3630. img.removeAttribute(prop.trim());
  3631. });
  3632. img.src = realSrc;
  3633. return;
  3634. }
  3635. })
  3636. if (!realSrc) {
  3637. let lazyAttr = "";
  3638. if (img.getAttribute("_src") && !img.src) {
  3639. lazyAttr = "_src";
  3640. realSrc = img.getAttribute(lazyAttr);
  3641. } else {
  3642. for (let i in lazyImgAttr) {
  3643. lazyAttr = lazyImgAttr[i];
  3644. let attrValue = img.getAttribute(lazyAttr);
  3645. if (attrValue) {
  3646. realSrc = attrValue;
  3647. break;
  3648. }
  3649. }
  3650. }
  3651. if (!realSrc && img._lazyrias && img._lazyrias.srcset) {
  3652. realSrc = img._lazyrias.srcset[img._lazyrias.srcset.length - 1];
  3653. lazyAttr = "_lazyrias";
  3654. }
  3655. if (!realSrc && img.srcset) {
  3656. lazyAttr = "srcset";
  3657. var srcs = img.srcset.split(/[xw],/i), largeSize = 0;
  3658. srcs.forEach(srci => {
  3659. let srcInfo = srci.trim().split(" "), curSize = parseInt(srcInfo[1]);
  3660. if (srcInfo[1] && curSize > largeSize) {
  3661. largeSize = curSize;
  3662. realSrc = srcInfo[0];
  3663. }
  3664. });
  3665. }
  3666. if (realSrc) {
  3667. img.src = realSrc;
  3668. img.removeAttribute("srcset");
  3669. img.removeAttribute(lazyAttr);
  3670. if (img.classList && img.classList.contains && img.classList.contains("lazy")) {
  3671. img.classList.remove("lazy");
  3672. }
  3673. if (img.style.display == "none") {
  3674. img.style.display = "";
  3675. }
  3676. if (img.style.visibility == "hidden") {
  3677. img.style.visibility = "";
  3678. }
  3679. if (img.style.opacity == 0) {
  3680. img.style.opacity = "";
  3681. }
  3682. }
  3683. }
  3684. };
  3685. if (lazyImgSrc) {
  3686. if (!Array.isArray(lazyImgSrc)) {
  3687. lazyAttrs = lazyImgSrc.split(",");
  3688. } else {
  3689. lazyAttrs = lazyImgSrc[0].split(",");
  3690. removeProps = lazyImgSrc[1].split(",");
  3691. }
  3692. }
  3693. lazyAttrs.forEach(attr => {
  3694. let attrArr = attr.split("|");
  3695. if (attrArr.length !== 2) {
  3696. imgLazyAttrs.push(attr.trim());
  3697. } else {
  3698. let selector = attrArr[0].trim();
  3699. let lazyAttr = attrArr[1].trim();
  3700. if (selector == "img") {
  3701. imgLazyAttrs.push(lazyAttr);
  3702. } else {
  3703. selector += "[" + lazyAttr + "]";
  3704. [].forEach.call(doc.querySelectorAll(selector), ele => {
  3705. ele.style.setProperty("background-image", "url(" + ele.getAttribute(lazyAttr) + ")", "important");
  3706. removeProps.forEach(prop => {
  3707. ele.removeAttribute(prop.trim());
  3708. });
  3709. });
  3710. }
  3711. }
  3712. });
  3713. [].forEach.call(doc.querySelectorAll("img,picture>source"), img => {
  3714. setLazyImg(img);
  3715. });
  3716. }
  3717.  
  3718. canListenUrlChange() {
  3719. if (this.curSiteRule) {
  3720. if (this.curSiteRule.listenUrlChange === true) return true;
  3721. if (this.curSiteRule.listenUrlChange === false) return false;
  3722. if (this.docElementValid()) {
  3723. return false;
  3724. }
  3725. }
  3726. return true;
  3727. }
  3728.  
  3729. docElementValid() {
  3730. return (this.docPageElement && document.documentElement.contains(this.docPageElement[0]));
  3731. }
  3732.  
  3733. urlChanged() {
  3734. urlChanged = true;
  3735. this.clearAddedElements();
  3736. }
  3737.  
  3738. initPage(callback) {
  3739. let self = this;
  3740. if (self.initing) return;
  3741. self.initing = true;
  3742. setTimeout(() => {
  3743. self.initing = false;
  3744. }, 100);
  3745. curPage = 1;
  3746. urlChanged = false;
  3747. tryTimes = 0;
  3748. this.clearAddedElements();
  3749. this.insert = null;
  3750. this.visibilityItems = [];
  3751. this.visibleIndex = -1;
  3752. this.pageDoc = document;
  3753. this.nextLinkHref = null;
  3754. this.curUrl = location.href;
  3755. this.oldUrl = "";
  3756. this.initUrl = location.href;
  3757. this.historyUrl = "";
  3758. this.possibleCheck = 0;
  3759. let base = document.querySelector("base");
  3760. this.basePath = (base && base.href) || location.href;
  3761. this.getRule(async () => {
  3762. if (self.curSiteRule.sideController === true || (self.curSiteRule.sideController !== false && rulesData.sideController)) {
  3763. isPause = manualPause;
  3764. }
  3765. hidePageBar = rulesData.opacity == 0 || self.curSiteRule.pageBar === 0;
  3766. if (typeof(self.curSiteRule.rate) !== "undefined") {
  3767. rate = self.curSiteRule.rate;
  3768. }
  3769. if (self.curSiteRule.enable == 0) {
  3770. debug("Stop as rule disable");
  3771. isPause = true;
  3772. _GM_registerMenuCommand(i18n("enable"), () => {
  3773. showTips(i18n("enableSiteTips"));
  3774. if(!self.customRules) {
  3775. self.customRules = [];
  3776. }
  3777. for (let i in self.customRules) {
  3778. if (self.customRules[i].url == self.curSiteRule.url) {
  3779. self.customRules.splice(i, 1);
  3780. break;
  3781. }
  3782. }
  3783. self.curSiteRule.enable = 1;
  3784. self.customRules.unshift(self.curSiteRule);
  3785. storage.setItem("customRules", self.customRules);
  3786. location.reload();
  3787. });
  3788. return;
  3789. }
  3790. if (rulesData.sideControllerAlways) {
  3791. sideController.setup();
  3792. }
  3793. //若是再亂匹配就不緩存wedata,或者只在找完本地規則之後再考慮wedata的緩存
  3794. if (self.curSiteRule.smart) {
  3795. delete self.curSiteRule.pageElement;
  3796. if (!self.possibleRule) {
  3797. self.smartRules = self.smartRules.filter(item => {return item && item.url != self.curSiteRule.url});
  3798. self.smartRules.unshift(self.curSiteRule);
  3799. if (self.smartRules.length > 100) {
  3800. self.smartRules.pop();
  3801. }
  3802. storage.setItem("smartRules", self.smartRules);
  3803. }
  3804. } else if (self.curSiteRule && self.curSiteRule.url.length > 13) {
  3805. self.addToHpRules();
  3806. }
  3807. let css = self.curSiteRule.css || rulesData.customCss;
  3808. if (css) {
  3809. let cssArr = css.split("inIframe:");
  3810. if (cssArr && cssArr.length) {
  3811. _GM_addStyle(cssArr[0]);
  3812. }
  3813. }
  3814. if (/sidesearch=(1|true)$/.test(self.curUrl)) {
  3815. openInNewTab = 0;
  3816. } else if (typeof self.curSiteRule.openInNewTab !== 'undefined') {
  3817. openInNewTab = self.curSiteRule.openInNewTab ? 1 : 2;
  3818. }
  3819. let autoClick = self.curSiteRule.autoClick;
  3820. if (autoClick) {
  3821. let autoClickBtn;
  3822. autoClickBtn = getElement(autoClick, document, null, true);
  3823. if (autoClickBtn) {
  3824. emuClick(autoClickBtn);
  3825. }
  3826. }
  3827. let code = self.curSiteRule.init;
  3828. if (code) {
  3829. try {
  3830. await ((typeof code == 'function') ? code : new AsyncFunction('doc', 'win', 'iframe', 'click', 'enter', 'input', 'sleep', '"use strict";' + code))(null, null, null, async sel => {await clickAction(sel, document)}, async sel => {await enterAction(sel, document)}, async (sel, v) =>{await inputAction(sel, v, document)}, async time => {await sleep(time)});
  3831. } catch(e) {
  3832. debug(e);
  3833. }
  3834. }
  3835. await self.getNextLink(document, true);
  3836. if (self.curSiteRule.pageNum && self.nextLinkHref && self.nextLinkHref != "#") {
  3837. let num1st = self.getPageNumFromUrl(location.href, 1);
  3838. let num2nd = self.getPageNumFromUrl(self.nextLinkHref, 1);
  3839. if (parseInt(num2nd) != parseInt(num1st) + 1) {
  3840. self.curSiteRule.pageNum = null;
  3841. }
  3842. }
  3843. if (self.curSiteRule.smart && self.nextLinkHref == false && self.possibleRule) {
  3844. let urlReg = new RegExp(self.possibleRule.url, "i");
  3845. function checkPossible () {
  3846. if (self.possibleCheck++ < 3) {
  3847. setTimeout(() => {
  3848. if (self.curSiteRule.smart) {
  3849. var href = location.href.slice(0, 500);
  3850. if (urlReg.test(href) && self.ruleMatch(self.possibleRule)) {
  3851. self.initPage(() => {});
  3852. } else checkPossible();
  3853. }
  3854. }, 3000);
  3855. }
  3856. }
  3857. checkPossible();
  3858. }
  3859. self.refreshByClick();
  3860. if (emuIframe && emuIframe.parentNode) {
  3861. emuIframe.parentNode.removeChild(emuIframe);
  3862. emuIframe = null;
  3863. }
  3864.  
  3865. let pageElementCss = self.curSiteRule.pageElementCss || rulesData.pageElementCss;
  3866. if (pageElementCss && pageElementCss !== '0') {
  3867. self.getPageElement(document, _unsafeWindow);
  3868. }
  3869. callback();
  3870. let initRun = typeof self.curSiteRule.initRun == 'undefined' ? rulesData.initRun : self.curSiteRule.initRun;
  3871. if (self.nextLinkHref) {
  3872. sideController.setup();
  3873. if (initRun && initRun != false) {
  3874. setTimeout(() => {
  3875. nextPage();
  3876. }, 300);
  3877. }
  3878. }
  3879. });
  3880. }
  3881.  
  3882. async hookUrlSetEle(ele, doc) {
  3883. let self = this;
  3884. return new Promise((resolve) => {
  3885. let catchUrl = e => {
  3886. ele.dataset.url = self.catchedUrl;
  3887. ele.setAttribute('onclick', 'window.open(this.dataset.url)');
  3888. window.removeEventListener('pagetual_openUrl', catchUrl);
  3889. resolve();
  3890. };
  3891. window.addEventListener('pagetual_openUrl', catchUrl);
  3892. emuClick(ele, doc);
  3893. });
  3894. }
  3895.  
  3896. async hookUrl(doc) {
  3897. let sel = this.curSiteRule.hookUrl;
  3898. if (!sel) return;
  3899. let self = this;
  3900. if (!this.initHook) {
  3901. this.initHook = true;
  3902. Object.defineProperty(doc.defaultView, 'open', {
  3903. get: function () {
  3904. return (s) => {
  3905. self.catchedUrl = s;
  3906. var e = new CustomEvent('pagetual_openUrl');
  3907. window.dispatchEvent(e);
  3908. }
  3909. }
  3910. });
  3911. }
  3912. let eles = getAllElements(sel, doc);
  3913. for (let i = 0; i < eles.length; i++) {
  3914. await sleep(1);
  3915. let ele = eles[i];
  3916. if (!ele.dataset.url) {
  3917. await this.hookUrlSetEle(ele, doc);
  3918. }
  3919. }
  3920. }
  3921.  
  3922. beginLoading() {
  3923. isLoading = true;
  3924. if (targetY >= 0) {
  3925. window.scrollTo({ top: targetY, behavior: 'instant'});
  3926. targetY = -1;
  3927. }
  3928. let lastScrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  3929. ruleParser.insertElement(loadingDiv);
  3930. if (forceState == 2) {
  3931. getBody(document).appendChild(loadingDiv);
  3932. } else {
  3933. let parent = loadingDiv.parentNode;
  3934. if (compareNodeName(parent, ["tbody"])) {
  3935. parent = parent.parentNode;
  3936. }
  3937. if (compareNodeName(parent, ["table"])) {
  3938. parent.parentNode.appendChild(loadingDiv);
  3939. }
  3940. }
  3941. getBody(document).scrollTop = lastScrollTop;
  3942. document.documentElement.scrollTop = lastScrollTop;
  3943. if (sideController.inited) {
  3944. sideController.frame.classList.add("loading");
  3945. }
  3946. }
  3947.  
  3948. insertElement(ele) {
  3949. if (!this.insert || !this.insert.parentNode) {
  3950. this.getInsert();
  3951. }
  3952. if (this.insert && this.insert.parentNode) {
  3953. let self = this;
  3954. if (ele.nodeName == "#document-fragment") {
  3955. [].forEach.call(ele.children, el => {
  3956. self.addedElePool.push(el);
  3957. });
  3958. } else {
  3959. this.addedElePool.push(ele);
  3960. }
  3961. if (this.curSiteRule.insertPos == 2 || this.curSiteRule.insertPos == "in") {
  3962. this.insert.appendChild(ele);
  3963. } else {
  3964. this.insert.parentNode.insertBefore(ele, this.insert);
  3965. }
  3966. }
  3967. }
  3968.  
  3969. noValidContent(url) {
  3970. if (!this.curSiteRule.nextLinkByUrl) showTips(i18n("noValidContent"), url);
  3971. }
  3972.  
  3973. async insertPage(doc, eles, url, callback, tried) {
  3974. this.oldUrl = this.curUrl;
  3975. let oldTitle = document.title;
  3976. try {
  3977. let oldTitle = this.pageDoc.title;
  3978. } catch (e) {}
  3979. this.pageDoc = doc;
  3980. this.curUrl = url;
  3981. isLoading = true;
  3982. let nextLink = await this.getNextLink(doc);
  3983. this.nextTitle = "";
  3984. if (this.curSiteRule.pageBarText) {
  3985. if (this.curSiteRule.pageBarText == 1 || this.curSiteRule.pageBarText == true) {
  3986. this.nextTitle = doc.title;
  3987. } else {
  3988. try {
  3989. this.nextTitle = ((typeof this.curSiteRule.pageBarText == 'function') ? this.curSiteRule.pageBarText : Function("doc",'"use strict";' + this.curSiteRule.pageBarText))(doc);
  3990. } catch(e) {
  3991. debug(e);
  3992. }
  3993. }
  3994. }
  3995. if (curPage == 1 && !tried && !nextLink && this.curSiteRule.smart && this.curSiteRule.pageElement && this.curSiteRule.action != 0) {
  3996. this.curSiteRule.action = 1;
  3997. this.curUrl = location.href;
  3998. isLoading = false;
  3999. return false;
  4000. }
  4001.  
  4002. if (targetY >= 0) {
  4003. window.scrollTo({ top: targetY, behavior: 'instant'});
  4004. targetY = -1;
  4005. }
  4006. let lastScrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  4007. this.getInsert();
  4008. await this.pageInit(doc, eles);
  4009. var self = this, newEles = [];
  4010. if (!eles || eles.length == 0 || !self.insert || !self.insert.parentNode) {
  4011. if (callback) callback(eles);
  4012. loadPageOver();
  4013. } else {
  4014. if (callback) callback(eles);
  4015. loadPageOver();
  4016. const collection = document.createDocumentFragment();
  4017. [].forEach.call(eles, ele => {
  4018. let newEle = ele.cloneNode(true);
  4019. let oldCanvass = ele.querySelectorAll("canvas");
  4020. let newCanvass = newEle.querySelectorAll("canvas");
  4021. if (self.updateUrl) {
  4022. [].forEach.call(newEle.querySelectorAll("img"), img => {
  4023. if (img.getAttribute("src")) img.src = self.canonicalUri(img.getAttribute("src"));
  4024. });
  4025. [].forEach.call(newEle.querySelectorAll("a"), a => {
  4026. if (a.getAttribute("href")) a.href = self.canonicalUri(a.getAttribute("href"));
  4027. });
  4028. }
  4029. for (let i = 0; i < oldCanvass.length; i++) {
  4030. let oldCanvas = oldCanvass[i];
  4031. let newCanvas = newCanvass[i];
  4032. newCanvas.getContext('2d').drawImage(oldCanvas, 0, 0);
  4033. }
  4034. if (!compareNodeName(newEle, ["style", "script"])) self.visibilityItems.push(newEle);
  4035. collection.appendChild(newEle)
  4036. newEles.push(newEle);
  4037. });
  4038. let css = this.curSiteRule.css;
  4039. let addCss = (parent) => {
  4040. if (css) {
  4041. let cssArr = css.split("inIframe:");
  4042. if (cssArr && cssArr.length == 2) {
  4043. let styleEle = document.createElement("style");
  4044. styleEle.innerHTML = cssArr[1];
  4045. parent.appendChild(styleEle);
  4046. }
  4047. }
  4048. };
  4049. if (this.curSiteRule.surround === "iframe") {
  4050. let ele = document.createElement("iframe");
  4051. ele.style.border = "unset";
  4052. ele.style.maxWidth = "100%";
  4053. ele.style.width = "100vw";
  4054. self.insertElement(ele);
  4055. try {
  4056. let doc = ele.contentDocument || ele.contentWindow.document;
  4057. doc.body.appendChild(collection);
  4058. ele.style.width = doc.body.scrollWidth + "px";
  4059. ele.style.height = doc.body.scrollHeight + "px";
  4060. doc.documentElement.style.overflow = "hidden";
  4061. doc.body.style.overflow = "hidden";
  4062. addCss(doc.body);
  4063. } catch(e) {
  4064. console.log(e);
  4065. }
  4066. } else if (this.curSiteRule.surround === "shadowDom") {
  4067. let ele = document.createElement("div");
  4068. self.insertElement(ele);
  4069. let shadowRoot = ele.attachShadow({ mode: "open" });
  4070. shadowRoot.appendChild(collection);
  4071. addCss(shadowRoot);
  4072. } else {
  4073. self.insertElement(collection);
  4074. }
  4075. }
  4076. getBody(document).scrollTop = lastScrollTop;
  4077. document.documentElement.scrollTop = lastScrollTop;
  4078. this.pageAction(doc, newEles);
  4079. let enableHistory = this.curSiteRule.history;
  4080. let enableHistoryAfterInsert = false;
  4081. if (enableHistory == 1) {
  4082. enableHistory = true;
  4083. } else if (enableHistory == 2) {
  4084. enableHistory = true;
  4085. enableHistoryAfterInsert = true;
  4086. } else if (enableHistory == 0) {
  4087. enableHistory = false;
  4088. } else {
  4089. enableHistory = rulesData.enableHistory;
  4090. enableHistoryAfterInsert = rulesData.enableHistoryAfterInsert;
  4091. }
  4092. if (enableHistory) {
  4093. this.historyUrl = enableHistoryAfterInsert ? this.curUrl : this.oldUrl;
  4094. if(this.historyUrl != location.href) {
  4095. let isJs = this.hrefIsJs(this.historyUrl);
  4096. if (!isJs) {
  4097. let historyTitle = enableHistoryAfterInsert ? doc.title : oldTitle;
  4098. _unsafeWindow.history.replaceState(undefined, historyTitle, this.historyUrl);
  4099. document.title = historyTitle;
  4100. }
  4101. }
  4102. }
  4103. isLoading = false;
  4104. _unsafeWindow.postMessage({
  4105. action: "insert",
  4106. command: 'pagetual'
  4107. }, '*');
  4108. return true;
  4109. }
  4110. }
  4111. var ruleParser = new RuleParser();
  4112.  
  4113. class SideController {
  4114. //static controller;
  4115. constructor() {
  4116. this.inited = false;
  4117. }
  4118.  
  4119. /*static getInstance() {
  4120. if (!SideController.controller) {
  4121. SideController.controller = new SideController();
  4122. }
  4123. return SideController.controller;
  4124. }*/
  4125.  
  4126. setup() {
  4127. if (ruleParser.curSiteRule.sideController === false) return;
  4128. if (!rulesData.sideController && !ruleParser.curSiteRule.sideController) return;
  4129. this.addToStage();
  4130. }
  4131.  
  4132. init() {
  4133. if (this.inited) return;
  4134. this.inited = true;
  4135. let self = this;
  4136. this.cssText = `
  4137. #pagetual-sideController {
  4138. position: fixed;
  4139. top: calc(50% - 83px);
  4140. left: calc(99% - 40px);
  4141. width: 40px;
  4142. border-radius: 20px;
  4143. box-shadow: rgb(0 0 0) 0px 0px 10px;
  4144. text-align: center;
  4145. background: #ffffffd0!important;
  4146. user-select: none;
  4147. z-index: 2147483646!important;
  4148. padding: 0!important;
  4149. opacity: 0.5;
  4150. transition: opacity .5s ease, background .5s, box-shadow .5s;
  4151. }
  4152. #pagetual-sideController.end {
  4153. opacity: 0.3;
  4154. }
  4155. #pagetual-sideController * {
  4156. font-weight: bold;
  4157. font-family: arial;
  4158. font-style: normal;
  4159. font-size: 20px!important;
  4160. color: black!important;
  4161. line-height: normal;
  4162. float: none;
  4163. text-align: center;
  4164. }
  4165. #pagetual-sideController.stop {
  4166. -webkit-filter: invert(100%);
  4167. filter: invert(100%);
  4168. }
  4169. .pagetual-sideController-btn {
  4170. padding: 5px 0;
  4171. cursor: pointer;
  4172. transition: transform .15s ease-in-out, opacity .3s ease;
  4173. }
  4174. #pagetual-sideController .pagetual-sideController-btn:hover {
  4175. transform: scale(1.5);
  4176. color: red!important;
  4177. }
  4178. #pagetual-sideController #pagetual-sideController-move > svg {
  4179. transition: transform .3s ease;
  4180. }
  4181. #pagetual-sideController #pagetual-sideController-move > svg:hover {
  4182. transform: scale(1.2);
  4183. }
  4184. #pagetual-sideController.minSize.loading #pagetual-sideController-move::before {
  4185. content: '';
  4186. position: absolute;
  4187. width: 34px;
  4188. height: 34px;
  4189. background-color: #1a232a;
  4190. background-repeat: no-repeat;
  4191. background-position: 0 0;
  4192. background-image: conic-gradient(transparent, #a8efff, transparent 30%);
  4193. -webkit-animation: rotate 1s linear infinite;
  4194. animation: rotate 1s linear infinite;
  4195. z-index: -1;
  4196. margin: -2px;
  4197. border-radius: 50%;
  4198. }
  4199. @keyframes rotate {
  4200. 100% {
  4201. transform: rotate(1turn);
  4202. }
  4203. }
  4204. #pagetual-sideController.minSize #pagetual-sideController-move > svg {
  4205. background: white;
  4206. opacity: 0;
  4207. }
  4208. #pagetual-sideController #pagetual-sideController-move > img,
  4209. #pagetual-sideController #pagetual-sideController-move > span {
  4210. width: 35px;
  4211. height: 35px;
  4212. cursor: pointer;
  4213. }
  4214. #pagetual-sideController.minSize #pagetual-sideController-move > img,
  4215. #pagetual-sideController.minSize #pagetual-sideController-move > span {
  4216. border-radius: 50px;
  4217. text-shadow: rgb(255 255 255) 0px 0px 10px;
  4218. }
  4219. #pagetual-sideController #pagetual-sideController-pagenum {
  4220. font-size: 15px!important;
  4221. line-height: 30px;
  4222. text-align: center;
  4223. position: absolute;
  4224. right: calc(50% - 15px);
  4225. top: calc(50% - 15px);
  4226. border: 1px solid #00000099;
  4227. display: inline-block;
  4228. width: 30px;
  4229. height: 30px;
  4230. box-sizing: border-box;
  4231. border-radius: 50%;
  4232. background: white;
  4233. opacity: 0;
  4234. transition: opacity .5s ease;
  4235. pointer-events: none;
  4236. }
  4237. #pagetual-sideController.minSize #pagetual-sideController-pagenum {
  4238. opacity: 1;
  4239. }
  4240. #pagetual-sideController:hover {
  4241. opacity: 1;
  4242. }
  4243. #pagetual-sideController>.extra {
  4244. bottom: 170px;
  4245. left: 0px;
  4246. width: 40px;
  4247. position: absolute;
  4248. }
  4249. #pagetual-sideController>.extra>svg {
  4250. width: 40px;
  4251. height: 30px;
  4252. opacity: 0.1;
  4253. cursor: pointer;
  4254. margin: 0 0 5px 0;
  4255. transition: opacity .3s ease;
  4256. }
  4257. #pagetual-sideController.minSize>.extra>svg {
  4258. opacity: 0;
  4259. }
  4260. #pagetual-sideController>.extra>svg:hover {
  4261. opacity: 1;
  4262. }
  4263. #pagetual-sideController.minSize {
  4264. box-shadow: rgb(0 0 0 / 0%) 0px 0px 0px;
  4265. background: #00000000!important;
  4266. pointer-events: none;
  4267. }
  4268. #pagetual-sideController.minSize #pagetual-sideController-move {
  4269. pointer-events: all;
  4270. }
  4271. #pagetual-sideController.minSize .pagetual-sideController-btn {
  4272. opacity: 0;
  4273. }
  4274. `;
  4275. let frame = document.createElement("div");
  4276. frame.id = "pagetual-sideController";
  4277. frame.innerHTML = createHTML(`
  4278. <div class="extra">
  4279. <svg id="loadNow" class="pagetual" viewBox="0 0 1030 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><title>${i18n("loadNow")}</title><path d="M712.106667 525.653333l-291.413334 247.893334a21.333333 21.333333 0 0 1-14.506666 5.546666 20.053333 20.053333 0 0 1-22.186667-19.2V264.106667a20.053333 20.053333 0 0 1 20.906667-19.2 20.906667 20.906667 0 0 1 14.506666 5.546666l291.413334 247.893334a17.92 17.92 0 0 1 1.28 27.306666zM512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z" fill="#5E5C5C"></path></svg>
  4280. <svg id="scroll" class="pagetual" viewBox="0 0 1030 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><title>${i18n("sideControllerScroll")}</title><path d="M912 544v82.64C912 846.096 732.912 1024 512 1024S112 846.096 112 626.64V544h800z" fill="#5E5C5C"></path><path d="M478.656 0v43.328a96 96 0 0 1-32.48 71.952c-27.68 24.448-41.968 48.128-42.896 71.04l-0.096 4.352v104c0 24.224 14.512 49.344 43.52 75.312a96 96 0 0 1 31.952 71.52V496H112.032L112 393.712C112 181.648 264.848 8.72 472.352 0.208L478.656 0z" fill="#999999"></path><path d="M534.24 0C747.584 5.232 912 179.504 912 393.728v102.256L534.208 496v-52.912a96 96 0 0 1 33.536-72.88c28.48-24.416 43.2-48.16 44.16-71.2l0.096-4.336v-104c0-24.352-14.928-49.52-44.784-75.488a96 96 0 0 1-33.008-72.432V0z" fill="#5E5C5C"></path></svg>
  4281. </div>
  4282. <div id="pagetual-sideController-top" class="pagetual-sideController-btn">⊼</div>
  4283. <div>
  4284. <div id="pagetual-sideController-pre" class="pagetual-sideController-btn">∧</div>
  4285. <div id="pagetual-sideController-move"><svg class="pagetual" width="30" height="30" style="border-radius: 15px;display: initial;position: relative;cursor: pointer;margin: 0;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"><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"></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"></path></svg><div id="pagetual-sideController-pagenum"></div></div>
  4286. <div id="pagetual-sideController-next" class="pagetual-sideController-btn">∨</div>
  4287. </div>
  4288. <div id="pagetual-sideController-bottom" class="pagetual-sideController-btn">⊻</div>
  4289. `);
  4290. frame.classList.add("stop");
  4291. let top = frame.querySelector("#pagetual-sideController-top");
  4292. let pre = frame.querySelector("#pagetual-sideController-pre");
  4293. let move = frame.querySelector("#pagetual-sideController-move");
  4294. let next = frame.querySelector("#pagetual-sideController-next");
  4295. let bottom = frame.querySelector("#pagetual-sideController-bottom");
  4296. let pagenum = frame.querySelector("#pagetual-sideController-pagenum");
  4297. let scroll = frame.querySelector("#scroll");
  4298. let loadNow = frame.querySelector("#loadNow");
  4299. if (rulesData.sideControllerScroll === false) {
  4300. scroll.style.display = "none";
  4301. }
  4302. if (rulesData.sideControllerLoadNow === false) {
  4303. loadNow.style.display = "none";
  4304. }
  4305. if (sideControllerIcon) move.innerHTML = sideControllerIcon;
  4306.  
  4307. frame.addEventListener("dblclick", e => {
  4308. e.preventDefault();
  4309. e.stopPropagation();
  4310. });
  4311.  
  4312. frame.addEventListener("mouseenter", e => {
  4313. clearTimeout(self.hideTimer);
  4314. frame.classList.remove("minSize");
  4315. });
  4316.  
  4317. frame.addEventListener("mouseleave", e => {
  4318. clearTimeout(self.hideTimer);
  4319. self.hideTimer = setTimeout(() => {
  4320. frame.classList.add("minSize");
  4321. }, 800);
  4322. });
  4323.  
  4324. document.body.addEventListener('touchstart', e => {
  4325. if (e.target === frame || frame.contains(e.target)) {
  4326. frame.classList.remove("minSize");
  4327. } else {
  4328. frame.classList.add("minSize");
  4329. }
  4330. });
  4331.  
  4332. scroll.addEventListener("click", e => {
  4333. autoScroll = (autoScroll ? 0 : prompt(i18n("autoScrollRate"), autoScrollRate)) || 0;
  4334. autoScroll = parseInt(autoScroll) || 0;
  4335. if (autoScroll < 0) autoScroll = 0;
  4336. if (autoScroll && autoScroll != autoScrollRate) {
  4337. autoScrollRate = autoScroll;
  4338. storage.setItem("autoScrollRate", autoScrollRate);
  4339. }
  4340. setListData("autoScroll", location.host + location.pathname, autoScroll);
  4341. startAutoScroll();
  4342. }, true);
  4343.  
  4344. loadNow.addEventListener("click", e => {
  4345. if (autoLoadNum != -1) {
  4346. autoLoadNum = -1;
  4347. return;
  4348. }
  4349. let loadNum = window.prompt(i18n("loadConfirm"), loadNowNum);
  4350. if (loadNum === "" || loadNum === null) return;
  4351. loadNum = Math.abs(parseInt(loadNum)) || 0;
  4352. if (loadNowNum != loadNum) {
  4353. loadNowNum = loadNum;
  4354. storage.setItem("loadNowNum", loadNowNum);
  4355. }
  4356. autoLoadNum = loadNum;
  4357. nextPage();
  4358. }, true);
  4359.  
  4360. pre.addEventListener("click", e => {
  4361. let prePageBar = getPageBar().preBar;
  4362. if (prePageBar) {
  4363. scrollToPageBar(prePageBar);
  4364. } else {
  4365. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  4366. targetY = scrollTop - (window.innerHeight || document.documentElement.clientHeight);
  4367. window.scrollTo({ top: targetY, behavior: 'smooth'});
  4368. }
  4369. }, true);
  4370.  
  4371. next.addEventListener("click", e => {
  4372. let pageBarObj = getPageBar();
  4373. let nextPageBar = pageBarObj.nextBar;
  4374. if (nextPageBar) {
  4375. scrollToPageBar(nextPageBar);
  4376. } else {
  4377. if (pageBarObj.preBar) {
  4378. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  4379. targetY = scrollH || 9999999;
  4380. window.scrollTo({ top: targetY, behavior: 'smooth'});
  4381. } else {
  4382. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  4383. targetY = scrollTop + (window.innerHeight || document.documentElement.clientHeight);
  4384. window.scrollTo({ top: targetY, behavior: 'smooth'});
  4385. }
  4386. }
  4387. }, true);
  4388.  
  4389. top.addEventListener("click", e => {
  4390. getBody(document).scrollTop=0;
  4391. document.documentElement.scrollTop=0;
  4392. e.preventDefault();
  4393. e.stopPropagation();
  4394. }, true);
  4395.  
  4396. bottom.addEventListener("click", e => {
  4397. if (!e.altKey && !e.ctrlKey && !e.shiftKey && !e.metaKey) {
  4398. changeStop(true);
  4399. }
  4400. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  4401. getBody(document).scrollTop = scrollH || 9999999;
  4402. document.documentElement.scrollTop = scrollH || 9999999;
  4403. e.preventDefault();
  4404. e.stopPropagation();
  4405. }, true);
  4406.  
  4407. let initX, initY, moving = false;
  4408. let removeTimer;
  4409. move.addEventListener("click", e => {
  4410. if (!moving) {
  4411. changeStop(!isPause, true);
  4412. }
  4413. }, true);
  4414. move.addEventListener("dblclick", e => {
  4415. clearTimeout(removeTimer);
  4416. document.removeEventListener("mousemove", mouseMoveHandler, true);
  4417. document.removeEventListener("mouseup", mouseUpHandler, true);
  4418. changeStop(!isPause, true);
  4419. if (isPause) {
  4420. ruleParser.hideAddedElements();
  4421. } else {
  4422. ruleParser.showAddedElements();
  4423. }
  4424. }, true);
  4425.  
  4426. move.oncontextmenu = e => {
  4427. e.preventDefault();
  4428. picker.start();
  4429. };
  4430.  
  4431. let clientX = e => {
  4432. if (e.type.indexOf('mouse') === 0) {
  4433. return e.clientX;
  4434. } else {
  4435. return e.changedTouches[0].clientX;
  4436. }
  4437. };
  4438.  
  4439. let clientY = e => {
  4440. if (e.type.indexOf('mouse') === 0) {
  4441. return e.clientY;
  4442. } else {
  4443. return e.changedTouches[0].clientY;
  4444. }
  4445. };
  4446.  
  4447. let mouseMoveHandler = e => {
  4448. if (moving) {
  4449. let windowHeight = window.innerHeight || document.documentElement.clientHeight;
  4450. let windowWidth = window.innerWidth || document.documentElement.clientWidth;
  4451. initX = (clientX(e) - 10 + 40) / windowWidth * 100;
  4452. initY = (clientY(e) - 83 + 83) / windowHeight * 100;
  4453. this.frame.style.top = `calc(${initY}% - 83px)`;
  4454. this.frame.style.left = `calc(${initX}% - 40px)`;
  4455. } else if (Math.abs(clientX(e) - initX) + Math.abs(clientY(e) - initY) > 5) {
  4456. moving = true;
  4457. clearTimeout(removeTimer);
  4458. }
  4459. };
  4460. let mouseUpHandler = e => {
  4461. clearTimeout(removeTimer);
  4462. document.removeEventListener("mousemove", mouseMoveHandler, true);
  4463. document.removeEventListener("mouseup", mouseUpHandler, true);
  4464. document.removeEventListener("touchmove", mouseMoveHandler, true);
  4465. document.removeEventListener("touchend", mouseUpHandler, true);
  4466. if (moving) {
  4467. rulesData.sideControllerPos = {x: parseInt(initX), y: parseInt(initY)};
  4468. storage.setItem("rulesData", rulesData);
  4469. }
  4470. };
  4471. let mouseDownHandler = e => {
  4472. initX = clientX(e);
  4473. initY = clientY(e);
  4474. moving = false;
  4475. clearTimeout(removeTimer);
  4476. removeTimer = setTimeout(() => {
  4477. if (e.type === "touchstart") {
  4478. picker.start();
  4479. } else {
  4480. self.remove();
  4481. }
  4482. }, 1500);
  4483. document.addEventListener("mousemove", mouseMoveHandler, true);
  4484. document.addEventListener("mouseup", mouseUpHandler, true);
  4485. document.addEventListener("touchmove", mouseMoveHandler, true);
  4486. document.addEventListener("touchend", mouseUpHandler, true);
  4487. e.stopPropagation();
  4488. e.preventDefault();
  4489. };
  4490.  
  4491. move.addEventListener("mousedown", mouseDownHandler, true);
  4492. move.addEventListener("touchstart", mouseDownHandler, { passive: false, capture: true });
  4493.  
  4494. this.frame = frame;
  4495. this.pagenum = pagenum;
  4496. if (rulesData.sideControllerPos) {
  4497. this.frame.style.top = `calc(${rulesData.sideControllerPos.y}% - 83px)`;
  4498. this.frame.style.left = `calc(${rulesData.sideControllerPos.x}% - 40px)`;
  4499. }
  4500. }
  4501.  
  4502. addToStage() {
  4503. this.init();
  4504. if (!this.styleEle || !this.styleEle.parentNode) {
  4505. this.styleEle = _GM_addStyle(this.cssText);
  4506. }
  4507. if (!isPause) {
  4508. this.frame.classList.remove("stop");
  4509. }
  4510. this.pagenum.innerHTML = createHTML(curPage);
  4511. this.frame.title = i18n("page") + curPage;
  4512. if (this.frame.parentNode) return;
  4513. getBody(document).appendChild(this.frame);
  4514. clearTimeout(this.hideTimer);
  4515. this.frame.classList.add("minSize");
  4516. }
  4517.  
  4518. remove() {
  4519. if (this.frame && this.frame.parentNode) this.frame.parentNode.removeChild(this.frame);
  4520. }
  4521. }
  4522. const sideController = new SideController();
  4523.  
  4524. class NextSwitch {
  4525. //static nextSwitch;
  4526. constructor() {
  4527. this.inited = false;
  4528. }
  4529.  
  4530. /*static getInstance() {
  4531. if (!NextSwitch.nextSwitch) {
  4532. NextSwitch.nextSwitch = new NextSwitch();
  4533. }
  4534. return NextSwitch.nextSwitch;
  4535. }*/
  4536.  
  4537. init() {
  4538. if (this.inited) return;
  4539. this.inited = true;
  4540. let self = this;
  4541. this.cssText = `
  4542. #pagetual-nextSwitch {
  4543. position: fixed;
  4544. top: 10px;
  4545. left: calc(50% - 160px);
  4546. background: aliceblue;
  4547. padding: 10px;
  4548. border-radius: 5px;
  4549. text-align: center;
  4550. opacity: 0.95;
  4551. color: #161616;
  4552. z-index: 2147483647;
  4553. font-size: 16px;
  4554. box-shadow: rgb(0 0 0) 0px 0px 10px;
  4555. }
  4556. #pagetual-nextSwitch>.title {
  4557. margin: -5px 45px 10px 45px;
  4558. font-size: 20px;
  4559. font-weight: bold;
  4560. border-bottom: 1px solid black;
  4561. user-select: none;
  4562. color: orangered;
  4563. }
  4564. #pagetual-nextSwitch>.group {
  4565. display: flex;
  4566. flex-direction: column;
  4567. }
  4568. #pagetual-nextSwitch>.group>span {
  4569. color: #161616;
  4570. cursor: pointer;
  4571. margin: 3px;
  4572. font-size: larger;
  4573. }
  4574. #pagetual-nextSwitch>.group>span:hover {
  4575. color: red;
  4576. }
  4577. #pagetual-nextSwitch>.group>span.current {
  4578. border: 2px dotted red;
  4579. border-radius: 10px;
  4580. }
  4581. #pagetual-nextSwitch>.closeSwitch {
  4582. position: absolute;
  4583. top: 3px;
  4584. right: 10px;
  4585. background: none;
  4586. border: none;
  4587. vertical-align: top;
  4588. transition: transform .15s ease-in-out;
  4589. float: right;
  4590. cursor: pointer;
  4591. }
  4592. #pagetual-nextSwitch svg {
  4593. width: 30px;
  4594. height: 30px;
  4595. vertical-align: middle;
  4596. fill: #161616;
  4597. overflow: hidden;
  4598. }
  4599. #pagetual-nextSwitch button:hover {
  4600. transform: scale(1.2);
  4601. }
  4602. `;
  4603. let frame = document.createElement("div");
  4604. frame.id = "pagetual-nextSwitch";
  4605. frame.innerHTML = createHTML(`
  4606. <div class="title">${i18n("nextSwitch")}</div>
  4607. <button type="button" class="closeSwitch">
  4608. <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2754">
  4609. <path d="M512 128c212 0 384 172 384 384s-172 384-384 384-384-172-384-384 172-384 384-384m0-64C264.8 64 64 264.8 64 512s200.8 448 448 448 448-200.8 448-448S759.2 64 512 64z m238.4 254.4l-45.6-45.6L512 467.2 318.4 273.6l-45.6 45.6L467.2 512 273.6 705.6l45.6 45.6L512 557.6l193.6 193.6 45.6-45.6L557.6 512l192.8-193.6z" p-id="2755">
  4610. </path>
  4611. </svg>
  4612. </button>
  4613. <div class="group"></div>
  4614. `);
  4615. let group = frame.querySelector(".group");
  4616. let closeBtn = frame.querySelector(".closeSwitch");
  4617. closeBtn.addEventListener("click", e => {
  4618. self.close();
  4619. }, true);
  4620. this.frame = frame;
  4621. let currentSpan;
  4622. ruleParser.curSiteRule.nextLink.forEach((link, i) => {
  4623. let span = document.createElement("span");
  4624. let target = getElement(link, document);
  4625. let index = "<b>" + (i + 1) + "</b>: ";
  4626. if (target) {
  4627. let targetInner = target.innerText.trim();
  4628. span.innerHTML = index + (targetInner || link);
  4629. } else {
  4630. span.innerHTML = index + "Not Found";
  4631. }
  4632. span.title = link;
  4633. span.addEventListener("click", e => {
  4634. if (currentSpan) currentSpan.classList.remove("current");
  4635. span.classList.add("current");
  4636. currentSpan = span;
  4637. nextIndex = i;
  4638. setListData("nextSwitch", location.host, nextIndex === 0 ? "" : nextIndex);
  4639. ruleParser.curUrl += "#pagetual";
  4640. ruleParser.oldUrl = ruleParser.curUrl;
  4641. autoLoadNum = -1;
  4642. if (!ruleParser.nextLinkHref) {
  4643. isLoading = false;
  4644. }
  4645. ruleParser.getNextLink(ruleParser.pageDoc || document);
  4646. self.close();
  4647. }, true);
  4648. if (i == nextIndex) {
  4649. span.classList.add("current");
  4650. currentSpan = span;
  4651. }
  4652. group.appendChild(span);
  4653. });
  4654. }
  4655.  
  4656. start() {
  4657. this.init();
  4658. if (!this.styleEle || !this.styleEle.parentNode) {
  4659. this.styleEle = _GM_addStyle(this.cssText);
  4660. }
  4661. document.documentElement.appendChild(this.frame);
  4662. }
  4663.  
  4664. close() {
  4665. if (this.frame.parentNode) this.frame.parentNode.removeChild(this.frame);
  4666. }
  4667. }
  4668. const nextSwitch = new NextSwitch();
  4669.  
  4670. class Picker {
  4671. //static picker;
  4672. constructor() {
  4673. this.inited = false;
  4674. }
  4675.  
  4676. /*static getInstance() {
  4677. if (!Picker.picker) {
  4678. Picker.picker = new Picker();
  4679. }
  4680. return Picker.picker;
  4681. }*/
  4682.  
  4683. init() {
  4684. if (this.inited) return;
  4685. this.inited = true;
  4686. let self = this;
  4687. this.signList = [];
  4688. this.cssText = `
  4689. body.pagetual-picker,
  4690. body.pagetual-picker *:hover,
  4691. body.pagetual-picker a:hover {
  4692. cursor: crosshair !important;
  4693. }
  4694. #pagetual-picker {
  4695. position: fixed;
  4696. top: 10px;
  4697. left: calc(50% - 178px);
  4698. background: aliceblue;
  4699. padding: 10px;
  4700. border-radius: 5px;
  4701. text-align: center;
  4702. opacity: 0.95;
  4703. color: #161616;
  4704. z-index: 2147483646;
  4705. font-size: 16px;
  4706. overflow: hidden;
  4707. box-shadow: rgb(0 0 0) 0px 0px 10px;
  4708. }
  4709. #pagetual-picker * {
  4710. margin: 0;
  4711. padding: 0;
  4712. font-family: Times New Roman;
  4713. overflow: initial;
  4714. user-select: none;
  4715. line-height: unset;
  4716. min-width: unset;
  4717. min-height: unset;
  4718. }
  4719. #pagetual-picker>.title {
  4720. margin: -5px 45px 10px 45px;
  4721. font-size: 20px;
  4722. font-weight: bold;
  4723. cursor: pointer;
  4724. border-bottom: 1px solid black;
  4725. user-select: none;
  4726. color: orangered;
  4727. height: initial;
  4728. width: initial;
  4729. position: initial;
  4730. transition: transform .3s ease;
  4731. }
  4732. #pagetual-picker>.title:hover {
  4733. transform: scale(1.1);
  4734. }
  4735. #pagetual-picker button {
  4736. background: none;
  4737. border: none;
  4738. vertical-align: top;
  4739. transition: transform .15s ease-in-out;
  4740. float: right;
  4741. cursor: pointer;
  4742. overflow: hidden;
  4743. background-color: unset!important;
  4744. }
  4745. #pagetual-picker button:hover {
  4746. transform: scale(1.2);
  4747. }
  4748. #pagetual-picker>.closePicker {
  4749. position: absolute;
  4750. top: 3px;
  4751. right: 10px;
  4752. }
  4753. #pagetual-picker>.logoIcon {
  4754. position: absolute;
  4755. top: 3px;
  4756. left: 10px;
  4757. }
  4758. #pagetual-picker>.logoIcon.showSign>svg>path {
  4759. fill: gray!important;
  4760. }
  4761. #pagetual-picker textarea{
  4762. display: inline-block;
  4763. width: calc(100% - 65px);
  4764. height: 20px;
  4765. min-width: 250px;
  4766. max-width: calc(65vw - 50px);
  4767. min-height: unset;
  4768. max-height: unset;
  4769. padding: 6px 12px;
  4770. font-size: 16px;
  4771. font-weight: 400;
  4772. line-height: 1.5;
  4773. color: #495057;
  4774. background-color: #fff;
  4775. background-clip: padding-box;
  4776. border: 1px solid #ced4da;
  4777. border-radius: 4px;
  4778. transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
  4779. box-sizing: content-box;
  4780. margin-right: 5px;
  4781. resize: both;
  4782. box-shadow: 0 1px 5px 1px #ddd;
  4783. overflow-wrap: anywhere;
  4784. }
  4785. #pagetual-picker textarea:focus {
  4786. color: black;
  4787. background-color: #fff;
  4788. border-color: #80bdff;
  4789. outline: 0;
  4790. box-shadow: 0 0 0 3.2px rgb(0 123 255 / 25%);
  4791. }
  4792. #pagetual-picker [type=checkbox],
  4793. #pagetual-picker [type=radio] {
  4794. line-height: 20px;
  4795. height: 25px;
  4796. width: 25px;
  4797. margin-left: 5px;
  4798. vertical-align: middle;
  4799. appearance: auto;
  4800. display: inline-block;
  4801. position: initial;
  4802. }
  4803. #pagetual-picker [type=checkbox]:after,
  4804. #pagetual-picker [type=radio]:after,
  4805. #pagetual-picker [type=checkbox]:before,
  4806. #pagetual-picker [type=radio]:before {
  4807. border: none;
  4808. background: none;
  4809. }
  4810. #pagetual-picker label {
  4811. font-size: 18px;
  4812. line-height: 25px;
  4813. vertical-align: middle;
  4814. display: inline-block;
  4815. color: black;
  4816. position: initial;
  4817. cursor: pointer;
  4818. }
  4819. #pagetual-picker .bottom {
  4820. text-align: left;
  4821. margin: 10px 0;
  4822. width: 100%;
  4823. }
  4824. #pagetual-picker .bottom>button {
  4825. float: right;
  4826. }
  4827. #pagetual-picker svg {
  4828. width: 30px;
  4829. height: 30px;
  4830. vertical-align: middle;
  4831. fill: #161616;
  4832. overflow: hidden;
  4833. }
  4834. #pagetual-picker svg * {
  4835. pointer-events: none;
  4836. }
  4837. #pagetual-picker .allpath {
  4838. font-size: 18px;
  4839. margin: 10px auto;
  4840. max-width: 330px;
  4841. word-break: break-all;
  4842. cursor: context-menu;
  4843. overflow: hidden;
  4844. max-height: 42px;
  4845. -moz-transition:max-height 1s ease-in;
  4846. -webkit-transition:max-height 1s ease-in;
  4847. transition:max-height 1s ease-in;
  4848. color: black;
  4849. }
  4850. #pagetual-picker .allpath:hover {
  4851. max-height: calc(100vh - 130px);
  4852. overflow: auto;
  4853. }
  4854. #pagetual-picker .allpath>span.path {
  4855. cursor: pointer;
  4856. }
  4857. #pagetual-picker .allpath>span.path:hover {
  4858. opacity: 0.6;
  4859. }
  4860. #pagetual-picker .allpath>span.path:hover,
  4861. #pagetual-picker .allpath>span.path.checked {
  4862. color: orangered;
  4863. }
  4864. #pagetual-picker .moreConfig {
  4865. display: flex;
  4866. justify-content: space-between;
  4867. border-top: 1px solid;
  4868. padding-top: 10px;
  4869. width: 100%;
  4870. }
  4871. #pagetual-picker .command {
  4872. width: 100%;
  4873. color: black!important;
  4874. text-align: center;
  4875. font-size: large;
  4876. margin-top: 10px;
  4877. box-shadow: 0 1px 6px 0 rgba(0, 0, 0, 0.12);
  4878. border-radius: 5px;
  4879. }
  4880. #pagetual-picker .command:hover {
  4881. color: orangered;
  4882. }
  4883. #pagetual-picker #showDetail {
  4884. float: initial;
  4885. margin-top: 10px;
  4886. }
  4887. #pagetual-picker.showDetail #showDetail {
  4888. float: right;
  4889. }
  4890. #pagetual-picker #showDetail>svg {
  4891. -moz-transition:transform 0.3s ease;
  4892. -webkit-transition:transform 0.3s ease;
  4893. transition:transform 0.3 ease;
  4894. }
  4895. #pagetual-picker.showDetail #showDetail>svg {
  4896. transform: rotate(180deg);
  4897. }
  4898. #pagetual-picker .tempRule {
  4899. display: none;
  4900. margin-top: 10px;
  4901. height: 300px;
  4902. min-height: 150px;
  4903. }
  4904. #pagetual-picker.showDetail .tempRule {
  4905. display: inline-block;
  4906. word-break: break-all;
  4907. }
  4908. #pagetual-picker #saveDetail {
  4909. display: none;
  4910. position: absolute;
  4911. bottom: 10px;
  4912. right: 8px;
  4913. }
  4914. #pagetual-picker.showDetail #saveDetail {
  4915. display: inline-block;
  4916. }
  4917. #pagetual-picker #saveDetail svg {
  4918. width: 35px;
  4919. height: 35px;
  4920. }
  4921. #pagetual-picker .addProp {
  4922. display: none;
  4923. flex-direction: column;
  4924. position: absolute;
  4925. bottom: 45px;
  4926. right: 12px;
  4927. }
  4928. #pagetual-picker.showDetail .addProp {
  4929. display: flex;
  4930. }
  4931. #pagetual-picker .addProp>button {
  4932. font-size: 30px;
  4933. font-family: Arial,sans-serif;
  4934. line-height: 35px;
  4935. color: #161616;
  4936. }
  4937. #pagetual-picker #edit{
  4938. -webkit-animation: jumpAnimation .6s 5;
  4939. animation: jumpAnimation .6s 5;
  4940. }
  4941. @keyframes jumpAnimation {
  4942. 0% {
  4943. transform: scale(1) translateY(0);
  4944. animation-timing-function: ease-out;
  4945. }
  4946. 50% {
  4947. transform: scale(1.2) translateY(-5px);
  4948. animation-timing-function: ease-in;
  4949. }
  4950. 100% {
  4951. transform: scale(1) translateY(0);
  4952. animation-timing-function: ease-out;
  4953. }
  4954. }
  4955. @-webkit-keyframes jumpAnimation {
  4956. 0% {
  4957. -webkit-transform: scale(1) translateY(0);
  4958. animation-timing-function: ease-out;
  4959. }
  4960. 50% {
  4961. -webkit-transform: scale(1.2) translateY(-5px);
  4962. animation-timing-function: ease-in;
  4963. }
  4964. 100% {
  4965. -webkit-transform: scale(1) translateY(0);
  4966. animation-timing-function: ease-out;
  4967. }
  4968. }
  4969. `;
  4970. this.mainSignDiv = this.createSignDiv();
  4971. this.allSignDiv = [];
  4972. let frame = document.createElement("div");
  4973. frame.id = "pagetual-picker";
  4974. frame.innerHTML = createHTML(`
  4975. <button title="Pagetual" type="button" class="logoIcon">
  4976. <svg width="30" height="30" class="upSvg pagetual" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><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" style="fill: #604b4a;" fill="#604b4a"></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" style="fill: #604b4a;" fill="#604b4a"></path></svg>
  4977. </button>
  4978. <div class="title" title="${i18n("configure")}">${i18n("picker")}</div>
  4979. <button title="${i18n("closePicker")}" type="button" class="closePicker">
  4980. <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M512 128c212 0 384 172 384 384s-172 384-384 384-384-172-384-384 172-384 384-384m0-64C264.8 64 64 264.8 64 512s200.8 448 448 448 448-200.8 448-448S759.2 64 512 64z m238.4 254.4l-45.6-45.6L512 467.2 318.4 273.6l-45.6 45.6L467.2 512 273.6 705.6l45.6 45.6L512 557.6l193.6 193.6 45.6-45.6L557.6 512l192.8-193.6z" style="fill: #604b4a;" fill="#604b4a"></path></svg>
  4981. </button>
  4982. <div class="allpath" title="${i18n("switchSelector")}"></div>
  4983. <div>
  4984. <textarea class="selector" spellcheck="false" name="selector" placeholder="${i18n("pickerPlaceholder")}"></textarea>
  4985. <button id="check" title="${i18n("pickerCheck")}" type="button">
  4986. <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M512 128a384 384 0 1 0 0 768 384 384 0 0 0 0-768z m0-85.333333c259.2 0 469.333333 210.133333 469.333333 469.333333s-210.133333 469.333333-469.333333 469.333333S42.666667 771.2 42.666667 512 252.8 42.666667 512 42.666667zM696.149333 298.666667L768 349.866667 471.594667 725.333333 256 571.733333l53.888-68.266666 143.744 102.4z" style="fill: #604b4a;" fill="#604b4a"></path></svg>
  4987. </button>
  4988. </div>
  4989. <div class="bottom">
  4990. <input name="xpath" id="checkbox_id" type="checkbox" />
  4991. <label for="checkbox_id">XPath</label>
  4992. <button id="edit" title="${i18n("gotoEdit")}" type="button">
  4993. <svg viewBox="0 0 1024 1024" style="color: orangered;fill: orangered;" version="1.1" xmlns="http://www.w3.org/2000/svg">
  4994. <path d="M775.84 392.768l-155.2-172.352L160.768 643.264l-38.368 187.936 190.56-12.832zM929.952 229.952l-131.2-150.944-0.288-0.32a16 16 0 0 0-22.592-0.96l-131.168 120.576 155.168 172.352 128.832-118.464a15.936 15.936 0 0 0 1.248-22.24zM96 896h832v64H96z">
  4995. </path>
  4996. </svg>
  4997. </button>
  4998. </div>
  4999. <div class="moreConfig">
  5000. <div title="${i18n('forceStateIframe')}">
  5001. <input name="forceState" id="forceStateIframe" type="radio" />
  5002. <label for="forceStateIframe">${i18n('iframe')}</label>
  5003. </div>
  5004. <div title="${i18n('forceStateDynamic')}">
  5005. <input name="forceState" id="forceStateDynamic" type="radio" />
  5006. <label for="forceStateDynamic">${i18n('dynamic')}</label>
  5007. </div>
  5008. <div title="${i18n('forceStateDisable')}">
  5009. <input name="forceState" id="forceStateDisable" type="radio" />
  5010. <label for="forceStateDisable">${i18n('disable')}</label>
  5011. </div>
  5012. </div>
  5013. <button id="nextSwitch" class="command" title="${i18n("nextSwitch")}" type="button">${i18n("nextSwitch")}</button>
  5014. <button id="loadNow" class="command" title="${i18n("loadNow")}" type="button">${i18n("loadNow")}</button>
  5015. <button id="autoScroll" class="command" title="${i18n("toggleAutoScroll")}" type="button"></button>
  5016. <button id="ruleRequest" class="command" title="${i18n("ruleRequest")}" type="button">${i18n("ruleRequest")}</button>
  5017. <div>
  5018. <textarea class="tempRule" spellcheck="false" placeholder="{Rule object}" title="Rule for current site"></textarea>
  5019. <button id="showDetail" title="" type="button">
  5020. <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M511.1 63.7c-247.4 0-448 200.6-448 448s200.6 448 448 448 448-200.6 448-448-200.6-448-448-448z m281.2 374.5L535.6 694.9c-12.5 12.5-32.8 12.5-45.3 0l-255.8-256c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l210.7 210.7c12.5 12.5 32.8 12.5 45.3 0l211.4-211.4c12.5-12.5 32.8-12.5 45.3 0 12.3 12.5 12.3 32.8-0.2 45.3z" style="fill: orangered;" fill="orangered"></path></svg>
  5021. </button>
  5022. <div class="addProp">
  5023. <button id="addOtherProp" title="${i18n("addOtherProp")}" type="button">+</button>
  5024. <button id="addNextSelector" title="${i18n("addNextSelector")}" type="button">></button>
  5025. <button id="addPageSelector" title="${i18n("addPageSelector")}" type="button">❏</button>
  5026. </div>
  5027. <button id="saveDetail" title="${i18n("save")}" type="button">
  5028. <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M704 128H192c-35.2 0-64 28.8-64 64v640c0 35.2 28.8 64 64 64h640c35.2 0 64-28.8 64-64V320L704 128zM256 256h320v128H256V256z m256 512c-70.4 0-128-57.6-128-128s57.6-128 128-128 128 57.6 128 128-57.6 128-128 128z" style="fill: orangered;" fill="orangered"></path></svg>
  5029. </button>
  5030. </div>
  5031. `);
  5032. let forceStateIframe = frame.querySelector("#forceStateIframe");//forceState 1 禁用 2 强嵌 3 动态
  5033. let forceStateDynamic = frame.querySelector("#forceStateDynamic");
  5034. let forceStateDisable = frame.querySelector("#forceStateDisable");
  5035. let clickRadio = e => {
  5036. let radio = e.currentTarget.querySelector('input');
  5037. if (radio.checked) {
  5038. forceState = "";
  5039. } else {
  5040. switch (radio.id) {
  5041. case "forceStateIframe":
  5042. forceState = 2;
  5043. break;
  5044. case "forceStateDynamic":
  5045. forceState = 3;
  5046. break;
  5047. case "forceStateDisable":
  5048. forceState = 1;
  5049. break;
  5050. default:
  5051. return;
  5052. }
  5053. }
  5054. setListData("forceState", location.host, forceState);
  5055. self.close();
  5056. setTimeout(() => {
  5057. location.reload();
  5058. }, 500);
  5059. };
  5060. forceStateIframe.parentNode.addEventListener("mousedown", clickRadio);
  5061. forceStateDynamic.parentNode.addEventListener("mousedown", clickRadio);
  5062. forceStateDisable.parentNode.addEventListener("mousedown", clickRadio);
  5063. if (forceState == 1) forceStateDisable.checked = true;
  5064. else if (forceState == 2) forceStateIframe.checked = true;
  5065. else if (forceState == 3) forceStateDynamic.checked = true;
  5066. let closeBtn = frame.querySelector(".closePicker");
  5067. let logoBtn = frame.querySelector(".logoIcon");
  5068. let title = frame.querySelector(".title");
  5069. let allpath = frame.querySelector(".allpath");
  5070. let selectorInput = frame.querySelector(".selector");
  5071. let xpath = frame.querySelector("#checkbox_id");
  5072. let checkBtn = frame.querySelector("#check");
  5073. let editBtn = frame.querySelector("#edit");
  5074. let nextSwitchBtn = frame.querySelector("#nextSwitch");
  5075. let autoScrollBtn = frame.querySelector("#autoScroll");
  5076. let loadNow = frame.querySelector("#loadNow");
  5077. let tempRule = frame.querySelector(".tempRule");
  5078. let showDetailBtn = frame.querySelector("#showDetail");
  5079. let saveDetailBtn = frame.querySelector("#saveDetail");
  5080. let addOtherProp = frame.querySelector("#addOtherProp");
  5081. let addNextSelector = frame.querySelector("#addNextSelector");
  5082. let addPageSelector = frame.querySelector("#addPageSelector");
  5083. let ruleRequestBtn = frame.querySelector("#ruleRequest");
  5084. ruleRequestBtn.addEventListener("click", e => {
  5085. _GM_openInTab("https://github.com/hoothin/UserScripts/issues/new?labels=Pagetual&template=custom-rule-request.md&title=Request%20Pagetual%20support%20for%20" + location.hostname + "#" + location.href, {active: true});
  5086. }, true);
  5087. autoScrollBtn.addEventListener("click", e => {
  5088. self.close();
  5089. autoScroll = (autoScroll ? 0 : prompt(i18n("autoScrollRate"), autoScrollRate)) || 0;
  5090. autoScroll = parseInt(autoScroll) || 0;
  5091. if (autoScroll < 0) autoScroll = 0;
  5092. if (autoScroll && autoScroll != autoScrollRate) {
  5093. autoScrollRate = autoScroll;
  5094. storage.setItem("autoScrollRate", autoScrollRate);
  5095. }
  5096. setListData("autoScroll", location.host + location.pathname, autoScroll);
  5097. startAutoScroll();
  5098. }, true);
  5099. addOtherProp.addEventListener("click", e => {
  5100. let propName = prompt(i18n("propName"), "author");
  5101. if (!propName) return;
  5102. let propValue = prompt(i18n("propValue"));
  5103. if (!propValue) return;
  5104. if (propValue === "true") propValue = true;
  5105. else if (propValue === "false") propValue = false;
  5106. else if (/^\d+$/.test(propValue)) propValue = parseInt(propValue);
  5107. if (propName === "author" && propValue) {
  5108. author = propValue;
  5109. storage.setItem("author", propValue);
  5110. }
  5111. let editTemp = self.getTempRule();
  5112. if (!editTemp) return;
  5113. editTemp[propName] = propValue;
  5114. self.tempRule.value = JSON.stringify(editTemp, null, 4);
  5115. }, true);
  5116. addNextSelector.addEventListener("click", e => {
  5117. let editTemp = self.getTempRule();
  5118. if (!editTemp) return;
  5119. let selector = self.selectorInput.value;
  5120. if (selector) {
  5121. editTemp.nextLink = selector;
  5122. }
  5123. self.tempRule.value = JSON.stringify(editTemp, null, 4);
  5124. }, true);
  5125. addPageSelector.addEventListener("click", e => {
  5126. let editTemp = self.getTempRule();
  5127. if (!editTemp) return;
  5128. let selector = self.selectorInput.value;
  5129. if (selector) {
  5130. editTemp.pageElement = selector;
  5131. }
  5132. self.tempRule.value = JSON.stringify(editTemp, null, 4);
  5133. }, true);
  5134. showDetailBtn.addEventListener("click", e => {
  5135. frame.classList.toggle("showDetail");
  5136. }, true);
  5137. saveDetailBtn.addEventListener("click", e => {
  5138. let editTemp = self.getTempRule(true);
  5139. if (tempRule.value && !editTemp) {
  5140. return;
  5141. }
  5142. if(!ruleParser.customRules) {
  5143. ruleParser.customRules = [];
  5144. }
  5145. ruleParser.customRules = ruleParser.customRules.filter(item => {return item.url != editTemp.url || item.name != editTemp.name});
  5146. if (tempRule.value) {
  5147. ruleParser.customRules.unshift(editTemp);
  5148. ruleParser.curSiteRule = editTemp;
  5149. } else {
  5150. ruleParser.curSiteRule = {};
  5151. isPause = true;
  5152. }
  5153. storage.setItem("customRules", ruleParser.customRules);
  5154. if (ruleParser.hpRules && ruleParser.curSiteRule && !ruleParser.curSiteRule.smart) {
  5155. ruleParser.addToHpRules(true);
  5156. }
  5157. if (window.confirm(i18n("reloadPage"))) {
  5158. setTimeout(() => {location.reload()}, 100);
  5159. }
  5160. }, true);
  5161. nextSwitchBtn.addEventListener("click", e => {
  5162. self.close();
  5163. nextSwitch.start();
  5164. }, true);
  5165. loadNow.addEventListener("click", e => {
  5166. self.close();
  5167. let loadNum = window.prompt(i18n("loadConfirm"), "1");
  5168. if (loadNum === "" || loadNum === null) return;
  5169. autoLoadNum = Math.abs(parseInt(loadNum));
  5170. nextPage();
  5171. }, true);
  5172. closeBtn.addEventListener("click", e => {
  5173. self.close();
  5174. }, true);
  5175. this.showSign = true;
  5176. logoBtn.addEventListener("click", e => {
  5177. logoBtn.classList.toggle("showSign");
  5178. self.showSign = !self.showSign;
  5179. getBody(document).classList.toggle("pagetual-picker");
  5180. }, true);
  5181. let moving = false;
  5182. let initX = 0, initY = 0, initPos = {x: 0, y: 0};
  5183. let moveHanlder = e => {
  5184. if (moving) {
  5185. frame.style.left = e.clientX - initX + "px";
  5186. frame.style.top = e.clientY - initY + "px";
  5187. e.stopPropagation();
  5188. e.preventDefault();
  5189. } else if(Math.abs(e.clientX - initPos.x) + Math.abs(e.clientY - initPos.y) > 20) {
  5190. moving = true;
  5191. }
  5192. };
  5193. let upHanlder = e => {
  5194. if (moving) {
  5195. moving = false;
  5196. } else {
  5197. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  5198. }
  5199. document.removeEventListener("mousemove", moveHanlder, true);
  5200. title.removeEventListener("mouseup", upHanlder, true);
  5201. e.stopPropagation();
  5202. e.preventDefault();
  5203. };
  5204. title.addEventListener("mousedown", e => {
  5205. initPos = {x: e.clientX, y: e.clientY};
  5206. initX = e.clientX - parseInt(getComputedStyle(frame).left);
  5207. initY = e.clientY - parseInt(getComputedStyle(frame).top);
  5208. document.addEventListener("mousemove", moveHanlder, true);
  5209. title.addEventListener("mouseup", upHanlder, true);
  5210. });
  5211. frame.addEventListener("mouseenter", e => {
  5212. if (!self.showSign || moving) return;
  5213. if (self.mainSignDiv.parentNode) self.mainSignDiv.parentNode.removeChild(self.mainSignDiv);
  5214. self.checkInputSelector(false);
  5215. });
  5216. frame.addEventListener("mouseleave", e => {
  5217. if (!self.showSign) {
  5218. if (self.mainSignDiv.parentNode) self.mainSignDiv.parentNode.removeChild(self.mainSignDiv);
  5219. self.clearSigns();
  5220. return;
  5221. }
  5222. if (moving) return;
  5223. document.documentElement.appendChild(self.mainSignDiv);
  5224. self.clearSigns();
  5225. });
  5226. checkBtn.addEventListener("click", e => {
  5227. self.checkInputSelector();
  5228. if (this.selectorInput.value && self.foundEle) {
  5229. debug(self.foundEle);
  5230. self.foundEle[0].scrollIntoView({ behavior: "smooth" });
  5231. _GM_setClipboard(this.selectorInput.value);
  5232. showTips(i18n("copied"));
  5233. } else showTips("Null");
  5234. });
  5235. xpath.addEventListener("click", e => {
  5236. if (!selectorInput.value) {
  5237. self.setSelectorDiv("");
  5238. return;
  5239. }
  5240. let element = getElement(selectorInput.value, document);
  5241. let selector = self.getSelectorFromEle(element);
  5242. selectorInput.value = selector;
  5243. self.setSelectorDiv(selector);
  5244. });
  5245. editBtn.addEventListener("click", e => {
  5246. rulesData.editTemp = self.getTempRule();
  5247. storage.setItem("rulesData", rulesData);
  5248. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  5249. });
  5250. editBtn.oncontextmenu = e => {
  5251. e.preventDefault();
  5252. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  5253. };
  5254. this.frame = frame;
  5255. this.xpath = xpath;
  5256. this.allpath = allpath;
  5257. this.selectorInput = selectorInput;
  5258. this.nextSwitchBtn = nextSwitchBtn;
  5259. this.autoScrollBtn = autoScrollBtn;
  5260. this.loadNow = loadNow;
  5261. this.tempRule = tempRule;
  5262. this.logoBtn = logoBtn;
  5263. let setTitleTimer;
  5264. this.moveHandler = e => {
  5265. if (!self.showSign || e.target === document) return;
  5266. let target = self.getTarget(e.target);
  5267. self.adjustSignDiv(self.mainSignDiv, target);
  5268. clearTimeout(setTitleTimer);
  5269. setTitleTimer = setTimeout(() => {
  5270. if (self.inPicker && target.hasAttributes()) {
  5271. let title = target.nodeName.toLowerCase() + "\n";
  5272. for (const attr of target.attributes) {
  5273. title += `【${attr.name}】${attr.value ? " ➡️ " + attr.value : ""}\n`;
  5274. }
  5275. getBody(document).title = title;
  5276. }
  5277. }, 100);
  5278. };
  5279. this.clickHandler = e => {
  5280. if (!self.showSign || !e.isTrusted) return;
  5281. if (self.inPicker) {
  5282. e.stopPropagation();
  5283. e.preventDefault();
  5284. }
  5285. let target = self.getTarget(e.target);
  5286. let selector = self.getSelectorFromEle(target);
  5287. selectorInput.value = selector;
  5288. self.setSelectorDiv(selector);
  5289. };
  5290. }
  5291.  
  5292. getTempRule(detail) {
  5293. if (this.tempRule.value) {
  5294. try {
  5295. this.editTemp = JSON.parse(this.tempRule.value);
  5296. } catch (e) {
  5297. this.editTemp = null;
  5298. if (detail) {
  5299. let pos = e && e.message && e.message.match(/position (\d+)/);
  5300. if (pos) {
  5301. pos = parseInt(pos[1]);
  5302. this.tempRule.value = this.tempRule.value.slice(0, pos) + "➡️" + this.tempRule.value.slice(pos);
  5303. }
  5304. showTips(i18n("errorJson"));
  5305. return null;
  5306. }
  5307. }
  5308. }
  5309. if (!this.editTemp) {
  5310. if (ruleParser.curSiteRule.url && !ruleParser.curSiteRule.smart) {
  5311. this.editTemp = ruleParser.curSiteRule;
  5312. } else {
  5313. this.editTemp = {
  5314. name: document.title,
  5315. url: "^" + (location.origin + location.pathname).replace(/[^\/]*$/, "").replace(/^https?/, "https?").replace(/\./g, "\\."),
  5316. example: location.href
  5317. };
  5318. if (author) this.editTemp.author = author;
  5319. }
  5320. delete this.editTemp.from;
  5321. delete this.editTemp.type;
  5322. delete this.editTemp.updatedAt;
  5323. }
  5324. if (this.selectorInput.value && (!this.frame.classList.contains("showDetail") || !this.editTemp || !this.editTemp.pageElement)) {
  5325. if (this.foundEle && this.foundEle.length === 1) {
  5326. let foundEleRect = this.foundEle[0].getBoundingClientRect();
  5327. if (foundEleRect.height < 100) {
  5328. showTips("Next Link", "", 500);
  5329. this.editTemp.nextLink = this.selectorInput.value;
  5330. return this.editTemp;
  5331. }
  5332. }
  5333. showTips("Page Element", "", 500);
  5334. this.editTemp.pageElement = this.selectorInput.value;
  5335. }
  5336. return this.editTemp;
  5337. }
  5338.  
  5339. getTarget(ele) {
  5340. while (ele.parentNode && (ele.offsetWidth === 0 || ele.offsetHeight === 0)) {
  5341. ele = ele.parentNode;
  5342. }
  5343. return ele;
  5344. }
  5345.  
  5346. close() {
  5347. this.clearSigns();
  5348. if (this.frame.parentNode) this.frame.parentNode.removeChild(this.frame);
  5349. if (this.mainSignDiv.parentNode) this.mainSignDiv.parentNode.removeChild(this.mainSignDiv);
  5350. getBody(document).classList.remove("pagetual-picker");
  5351. getBody(document).removeEventListener("mousemove", this.moveHandler, true);
  5352. getBody(document).removeEventListener("click", this.clickHandler, true);
  5353. getBody(document).title = "";
  5354. this.inPicker = false;
  5355. }
  5356.  
  5357. setImportant(ele, prop, value) {
  5358. ele.style.setProperty(prop, value, "important");
  5359. }
  5360.  
  5361. createSignDiv() {
  5362. let signDiv = document.createElement("div");
  5363. this.setImportant(signDiv, "position", "absolute");
  5364. this.setImportant(signDiv, "pointer-events", "none");
  5365. this.setImportant(signDiv, "z-index", "2147483645");
  5366. this.setImportant(signDiv, "background", "rgba(120, 170, 210, 0.6)");
  5367. this.setImportant(signDiv, "transition", "all 0.15s ease-out");
  5368. this.setImportant(signDiv, "box-shadow", "rgb(0 0 0) 0px 0px 3px 0px");
  5369. return signDiv;
  5370. }
  5371.  
  5372. adjustSignDiv(div, target) {
  5373. let rect = target.getBoundingClientRect();
  5374. this.setImportant(div, "width", rect.width + "px");
  5375. this.setImportant(div, "height", rect.height + "px");
  5376. this.setImportant(div, "left", rect.left + window.scrollX + "px");
  5377. this.setImportant(div, "top", rect.top + window.scrollY + "px");
  5378. }
  5379.  
  5380. getSelectorFromEle(ele) {
  5381. return this.xpath.checked ? createXPathFromElement(ele) : geneSelector(ele, true);
  5382. }
  5383.  
  5384. fillTempRuleTextarea() {
  5385. if (!this.frame.classList.contains("showDetail") || !this.editTemp || !this.editTemp.pageElement) this.tempRule.value = JSON.stringify(this.getTempRule(), null, 4);
  5386. }
  5387.  
  5388. setSelectorDiv(selector) {
  5389. let self = this;
  5390. this.allpath.innerHTML = createHTML("");
  5391. if (selector) {
  5392. if (this.xpath.checked) {
  5393. let span = document.createElement("span");
  5394. span.innerText = selector;
  5395. span.addEventListener("click", e => {
  5396. self.selectorInput.value = selector;
  5397. self.checkInputSelector();
  5398. }, true);
  5399. this.allpath.appendChild(span);
  5400. } else {
  5401. selector.split(">").forEach((item, index) => self.geneSelectorItem(item, index));
  5402. }
  5403. }
  5404. this.checkInputSelector();
  5405. }
  5406.  
  5407. geneSelectorItem(item, index) {
  5408. let self = this;
  5409. item = item.trim();
  5410. if (!item) return;
  5411. if (index !== 0) {
  5412. let span = document.createElement("span");
  5413. span.innerText = " > ";
  5414. this.allpath.appendChild(span);
  5415. }
  5416. let span = document.createElement("span");
  5417. span.className = "path";
  5418. span.innerText = item;
  5419. span.addEventListener("click", e => {
  5420. let selector = "";
  5421. let target = e.target;
  5422. while (target) {
  5423. selector = target.innerText + selector;
  5424. target = target.previousElementSibling;
  5425. }
  5426. self.selectorInput.value = selector;
  5427. self.checkInputSelector();
  5428. if (self.checkedPath) {
  5429. self.checkedPath.classList.remove("checked");
  5430. }
  5431. span.classList.add("checked");
  5432. self.checkedPath = span;
  5433. }, true);
  5434. this.allpath.appendChild(span);
  5435. }
  5436.  
  5437. checkInputSelector(fill = true) {
  5438. let self = this;
  5439. this.clearSigns();
  5440. if (!this.selectorInput.value) return;
  5441. let eles = getAllElements(this.selectorInput.value, document);
  5442. this.foundEle = null;
  5443. if (eles && eles.length > 0) {
  5444. this.foundEle = eles;
  5445. eles.forEach(ele => {
  5446. let sign = self.createSignDiv();
  5447. document.documentElement.appendChild(sign);
  5448. self.adjustSignDiv(sign, ele);
  5449. self.signList.push(sign);
  5450. });
  5451. if (fill) this.fillTempRuleTextarea();
  5452. }
  5453. }
  5454.  
  5455. clearSigns() {
  5456. this.signList.forEach(sign => {
  5457. if (sign.parentNode) sign.parentNode.removeChild(sign);
  5458. });
  5459. this.signList = [];
  5460. }
  5461.  
  5462. start() {
  5463. this.init();
  5464. if (this.inPicker) return;
  5465. this.inPicker = true;
  5466. if (!this.styleEle || !this.styleEle.parentNode) {
  5467. this.styleEle = _GM_addStyle(this.cssText);
  5468. }
  5469. document.documentElement.appendChild(this.frame);
  5470. document.documentElement.appendChild(this.mainSignDiv);
  5471. getBody(document).classList.add("pagetual-picker");
  5472.  
  5473. this.logoBtn.classList.remove("showSign");
  5474. this.showSign = true;
  5475.  
  5476. getBody(document).addEventListener("mousemove", this.moveHandler, true);
  5477. getBody(document).addEventListener("click", this.clickHandler, true);
  5478. this.xpath.checked = isXPath(ruleParser.curSiteRule.pageElement);
  5479. this.tempRule.value = "";
  5480. this.editTemp = null;
  5481. this.frame.classList.remove("showDetail");
  5482.  
  5483. this.loadNow.style.display = ruleParser.nextLinkHref ? "block" : "none";
  5484. if (ruleParser.curSiteRule.nextLink && Array && Array.isArray && Array.isArray(ruleParser.curSiteRule.nextLink)) {
  5485. this.nextSwitchBtn.style.display = "block";
  5486. } else {
  5487. this.nextSwitchBtn.style.display = "none";
  5488. }
  5489. this.autoScrollBtn.innerText = i18n(autoScroll ? "disableAutoScroll" : "enableAutoScroll");
  5490.  
  5491. let pageElementSel = ruleParser.curSiteRule.pageElement || "";
  5492. if (Array && Array.isArray && Array.isArray(pageElementSel)) {
  5493. pageElementSel = pageElementSel[nextIndex < pageElementSel.length ? nextIndex : 0];
  5494. }
  5495. this.setSelectorDiv(pageElementSel);
  5496. this.fillTempRuleTextarea();
  5497. }
  5498. }
  5499. const picker = new Picker();
  5500.  
  5501. var editor, editorChanged = false, customRulesInput;
  5502. function createEdit() {
  5503. var options = {
  5504. mode: 'code',
  5505. modes: ['code', 'tree'],
  5506. templates: [
  5507. {
  5508. text: 'New site',
  5509. title: 'Insert a new site',
  5510. className: 'jsoneditor-type-object',
  5511. field: 'SiteTemplate',
  5512. value: {
  5513. 'name': 'Site name',
  5514. 'url': 'Site url'
  5515. }
  5516. }
  5517. ],
  5518. schema: {
  5519. "title": "Sites data",
  5520. "description": "Object containing site config",
  5521. "type": "array",
  5522. "items": {
  5523. "type": 'object',
  5524. "properties": {
  5525. "name": {
  5526. "title": "Site Name",
  5527. "description": "The site's name.",
  5528. "examples": [
  5529. "Google"
  5530. ],
  5531. "type": "string"
  5532. },
  5533. "url": {
  5534. "title": "Site Url",
  5535. "description": "The Regexp of site's url.",
  5536. "examples": [
  5537. "^https:\/\/yande\\.re\/"
  5538. ],
  5539. "type": "string"
  5540. }
  5541. },
  5542. "required": ["name", "url"]
  5543. }
  5544. },
  5545. onChange: () => {
  5546. editorChanged = true;
  5547. }
  5548. };
  5549. setTimeout(() => {
  5550. var container = document.getElementById("jsoneditor");
  5551. if (!container) {
  5552. container = document.createElement("div");
  5553. configCon.appendChild(container);
  5554. }
  5555. container.style.height = '800px';
  5556. container.innerHTML = "";
  5557. try {
  5558. editor = new _unsafeWindow.JSONEditor(container, options);
  5559. editor.set(ruleParser.customRules);
  5560. } catch (e) {
  5561. editor = null;
  5562. container.style.display = 'none';
  5563. customRulesInput.style.display = "";
  5564. }
  5565. }, 500);
  5566. }
  5567.  
  5568. function checkGuidePage(href) {
  5569. if (guidePage.test(href)) {
  5570. if (typeof _unsafeWindow.JSONEditor !== 'undefined') {
  5571. createEdit();
  5572. } else {
  5573. let timeout = 30;
  5574. let checkEditorReady = setInterval(() => {
  5575. if (typeof _unsafeWindow.JSONEditor !== 'undefined') {
  5576. createEdit();
  5577. clearInterval(checkEditorReady);
  5578. } else if (timeout-- <= 0) {
  5579. editor = null;
  5580. customRulesInput.style.display = "";
  5581. clearInterval(checkEditorReady);
  5582. }
  5583. }, 100);
  5584. }
  5585. return true;
  5586. }
  5587. return false;
  5588. }
  5589.  
  5590. function startAutoScroll() {
  5591. clearInterval(autoScrollInterval);
  5592. if (autoScroll <= 0) return;
  5593. let scrollRange_o = 1;
  5594. if (autoScroll > 1000) {
  5595. scrollRange_o = parseInt(autoScroll / 1000);
  5596. }
  5597. let devicePixelRatio = window.devicePixelRatio;
  5598. let scrollRange = Math.ceil(scrollRange_o / devicePixelRatio);
  5599.  
  5600. let scrollTarget, body = getBody(document);
  5601. let checkOverflow = ele => {
  5602. return ele.scrollHeight !== ele.clientHeight && getComputedStyle(ele).overflowY !== "hidden";
  5603. };
  5604. if (document.documentElement.scrollTop || checkOverflow(document.documentElement)) {
  5605. scrollTarget = document.documentElement;
  5606. } else if (body.scrollTop || checkOverflow(body)) {
  5607. scrollTarget = body;
  5608. } else {
  5609. let tempEle;
  5610. let img = body.querySelector('img');
  5611. if (img) {
  5612. tempEle = img;
  5613. while (tempEle && !checkOverflow(tempEle)) {
  5614. tempEle = tempEle.parentNode;
  5615. }
  5616. }
  5617. if (!tempEle && document.activeElement) {
  5618. let tempEle = document.activeElement;
  5619. while (tempEle && !checkOverflow(tempEle)) {
  5620. tempEle = tempEle.parentNode;
  5621. }
  5622. }
  5623. if (tempEle) scrollTarget = tempEle;
  5624. }
  5625. scrollTarget = scrollTarget || document.documentElement;
  5626.  
  5627. autoScrollInterval = setInterval(() => {
  5628. if (isPause && !urlChanging) return;
  5629. if (devicePixelRatio !== window.devicePixelRatio) {
  5630. devicePixelRatio = window.devicePixelRatio;
  5631. scrollRange = Math.ceil(scrollRange_o / devicePixelRatio);
  5632. }
  5633. scrollTarget.scrollTop += scrollRange;
  5634. }, parseInt(1000 / autoScroll));
  5635. }
  5636.  
  5637. var inUpdate = false;
  5638. var importHandler, configCon;
  5639. function initConfig(href) {
  5640. if (location.hostname === "github.com") {
  5641. if (location.href.indexOf("https://github.com/hoothin/UserScripts/issues/new?labels=Pagetual&template=custom-rule-request.md&title=Request%20Pagetual%20support%20for%20") === 0) {
  5642. let issue_body = document.getElementById("issue_body");
  5643. if (!issue_body) return true;
  5644. issue_body.value = issue_body.value.replace("\n", "\n" + location.hash.slice(1) + "\n");
  5645. let starButton = document.createElement("a");
  5646. starButton.href = "https://github.com/hoothin/UserScripts#star";
  5647. starButton.className = "js-toggler-target rounded-left-2 btn-with-aria-count btn-sm btn";
  5648. starButton.innerHTML = createHTML('<svg height="16" viewBox="0 0 16 16" version="1.1" width="16" class="octicon octicon-star d-inline-block mr-2"><path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span class="d-inline">Star</span>');
  5649. starButton.style.float = "right";
  5650. document.querySelector(".Layout-main>h2").appendChild(starButton);
  5651. return true;
  5652. } else if (location.href === "https://github.com/hoothin/UserScripts#star") {
  5653. let starButton = document.querySelector(".starring-container:not(.on)>.unstarred>form>button");
  5654. if (starButton) emuClick(starButton);
  5655. return true;
  5656. }
  5657. }
  5658. let isGuidePage = checkGuidePage(href);
  5659.  
  5660. var click2import, importUrlPres;
  5661.  
  5662. let inConfig = isGuidePage;
  5663. if (!inConfig) {
  5664. for (let i = 0; i < configPage.length; i++) {
  5665. if (configPage[i] == location.href) {
  5666. inConfig = true;
  5667. break;
  5668. }
  5669. }
  5670. }
  5671. if (!isGuidePage) {
  5672. if (location.hostname === "hoothin.github.io" || location.hostname === "pagetual.hoothin.com") isGuidePage = true;
  5673. }
  5674. configCon = document.getElementById("configCon");
  5675. if (configCon) {
  5676. configCon.parentNode.removeChild(configCon);
  5677. }
  5678. if (ruleImportUrlReg.test(href) || inConfig) {
  5679. let importing = false;
  5680. if (!inUpdate && rulesData.uninited) {
  5681. setTimeout(() => {
  5682. if (!inUpdate && !importing) showTips(i18n("firstAlert"));
  5683. }, 3000);
  5684. showTips(i18n("firstAlert"));
  5685. }
  5686. let defaultOption = document.querySelector('#discussion_rating_4');
  5687. if (defaultOption) defaultOption.checked = true;
  5688. let createImportBtn = (pre) => {
  5689. let importBtn = document.createElement("button");
  5690. importBtn.id = "pagetualImport";
  5691. importBtn.innerText = i18n("import");
  5692. importBtn.style.marginTop = "100px";
  5693. importBtn.style.float = "right";
  5694. importBtn.style.position = "relative";
  5695. importBtn.style.display = "block";
  5696. importBtn.style.fontSize = "20px";
  5697. importBtn.addEventListener("click", e => {
  5698. let parentNode = importBtn.parentNode;
  5699. if (!parentNode) return;
  5700. parentNode.removeChild(importBtn);
  5701. try {
  5702. let rules = parentNode.innerText.trim();
  5703. let isContent = /['"]name['"]/i.test(rules);
  5704. if (isContent) {
  5705. let ruleList = JSON.parse(`[${rules}]`);
  5706. for (let i in ruleList) {
  5707. let hasRule = false;
  5708. let r = ruleList[i];
  5709. for (let j in ruleParser.customRules) {
  5710. if (ruleParser.customRules[j].name == r.name) {
  5711. ruleParser.customRules[j] = r;
  5712. hasRule = true;
  5713. break;
  5714. }
  5715. }
  5716. if (!hasRule) ruleParser.customRules.push(r);
  5717. ruleParser.hpRules.unshift(r);
  5718. }
  5719. storage.setItem("customRules", ruleParser.customRules);
  5720. storage.setItem("hpRules", ruleParser.hpRules);
  5721. storage.setItem("smartRules", []);
  5722. showTips(i18n("importSucc"));
  5723. } else {
  5724. rules = rules.split("\n");
  5725. let diff = false;
  5726. for (let c = 0; c < rules.length; c++) {
  5727. let urlArr = rules[c].split("|"), url, type = 1;
  5728. if (urlArr.length == 1) {
  5729. url = urlArr[0].trim();
  5730. if (!/^http/.test(url)) {
  5731. showTips(i18n("errorWrongUrl"));
  5732. return;
  5733. }
  5734. } else if (urlArr.length == 2) {
  5735. type = urlArr[0].trim();
  5736. url = urlArr[1].trim();
  5737. if (!/^http/.test(url)) {
  5738. showTips(i18n("errorWrongUrl"));
  5739. return;
  5740. }
  5741. } else {
  5742. break;
  5743. }
  5744. let maxId = 1, hasUrl = false;
  5745. if (!rulesData.urls) {
  5746. rulesData.urls = [];
  5747. maxId = 1;
  5748. } else {
  5749. rulesData.urls.forEach(u => {
  5750. if (maxId < u.id) {
  5751. maxId = u.id;
  5752. }
  5753. if (u.url == url) {
  5754. hasUrl = true;
  5755. }
  5756. });
  5757. if (hasUrl) break;
  5758. }
  5759. diff = true;
  5760. if (!rulesData.sort) rulesData.sort = [1];
  5761. rulesData.urls.push({id: maxId + 1, url: url, type: type});
  5762. rulesData.sort.unshift(maxId + 1);
  5763. }
  5764. if (!diff) {
  5765. showTips(i18n("errorAlreadyExists"));
  5766. setTimeout(() => {
  5767. showTips(i18n("beginUpdate"), "", 50000);
  5768. updateRules(() => {
  5769. showTips(i18n("updateSucc"));
  5770. location.reload();
  5771. }, (rule, err) => {
  5772. showTips(`Failed to update ${rule.url} rules!`);
  5773. debug(err);
  5774. });
  5775. }, 500);
  5776. return;
  5777. }
  5778. storage.setItem("rulesData", rulesData);
  5779.  
  5780. if (rulesData.urls) ruleUrls = ruleUrls.concat(rulesData.urls);
  5781. if (rulesData.sort) {
  5782. let urls = [];
  5783. rulesData.sort.forEach(id => {
  5784. for (let s = 0; s < ruleUrls.length; s++) {
  5785. if (id == ruleUrls[s].id) {
  5786. urls.push(ruleUrls[s]);
  5787. break;
  5788. }
  5789. }
  5790. });
  5791. ruleUrls = urls;
  5792. }
  5793. showTips(i18n("beginUpdate"), "", 30000);
  5794. updateRules(() => {
  5795. showTips(i18n("updateSucc"));
  5796. location.reload();
  5797. }, (rule, err) => {
  5798. showTips(`Failed to update ${rule.url} rules!`);
  5799. debug(err);
  5800. });
  5801. importing = true;
  5802. }
  5803. } catch (e) {
  5804. _GM_notification(e.toString());
  5805. }
  5806. });
  5807. if (pre) {
  5808. let clientHeight = 35 - pre.clientHeight;
  5809. if (clientHeight > -20) clientHeight = -20;
  5810. importBtn.style.marginTop = `${clientHeight}px`;
  5811. pre.appendChild(importBtn);
  5812. }
  5813. return importBtn;
  5814. };
  5815. [].forEach.call(document.querySelectorAll('pre[name=pagetual],pre[name=user-content-pagetual]'), pre => {
  5816. let importBtn = createImportBtn(pre);
  5817. if (rulesData.uninited) {
  5818. pre.style.display = "";
  5819. }
  5820. });
  5821. click2import = document.querySelector("[name='user-content-click2import'],[name='click2import']");
  5822. if (click2import) {
  5823. click2import.innerText = i18n("click2ImportRule");
  5824. click2import.style.display = rulesData.uninited ? "block" : "none";
  5825. }
  5826. if (!importHandler) {
  5827. importHandler = e => {
  5828. if (compareNodeName(e.target, ["pre"])) {
  5829. let nameAttr = e.target.getAttribute("name");
  5830. if (nameAttr == "pagetual" || nameAttr == "user-content-pagetual") {
  5831. if (e.target.querySelector('#pagetualImport')) return;
  5832. let importBtn = createImportBtn(e.target);
  5833. }
  5834. }
  5835. };
  5836. }
  5837. document.removeEventListener("mouseover", importHandler);
  5838. document.addEventListener("mouseover", importHandler);
  5839.  
  5840. if (inConfig) {
  5841. if (!inUpdate && _GM_info.script && _GM_info.script.version && _GM_info.script.version !== '1.0.0') {
  5842. let versionEle = document.querySelector('.markdown-body>h1[id],article>h1');
  5843. let latestVer = versionEle && versionEle.innerText.match(/\d[\d\.]+/)[0];
  5844. if (latestVer && latestVer != _GM_info.script.version) {
  5845. showTips(i18n('outOfDate'), "", 3000);
  5846. }
  5847. }
  5848. _GM_addStyle(`
  5849. p>span:nth-child(1),p>span:nth-child(2),p>span:nth-child(3){
  5850. cursor: pointer;
  5851. user-select: none;
  5852. display: inline-block;
  5853. margin-right: 5px;
  5854. -moz-transition:color 0.3s ease, transform 0.3s;
  5855. -webkit-transition:color 0.3s ease, transform 0.3s;
  5856. transition:color 0.3s ease, transform 0.3s;
  5857. }
  5858. p>span:nth-child(1):hover,p>span:nth-child(2):hover,p>span:nth-child(3):hover{
  5859. color:red;
  5860. transform: scale(1.5);
  5861. -webkit-transform: scale(1.5);
  5862. }
  5863. .updateDate{
  5864. cursor: pointer;
  5865. user-select: none;
  5866. -moz-transition:color 0.3s ease, transform 0.3s;
  5867. -webkit-transition:color 0.3s ease, transform 0.3s;
  5868. transition:color 0.3s ease, transform 0.3s;
  5869. transform-origin: left;
  5870. -webkit-transform-origin: left;
  5871. }
  5872. .updateDate:hover{
  5873. color:red;
  5874. transform: scale(1.1);
  5875. -webkit-transform: scale(1.1);
  5876. }
  5877. input[type=number]::-webkit-inner-spin-button,
  5878. input[type=number]::-webkit-outer-spin-button {
  5879. -webkit-appearance: none;
  5880. margin: 0;
  5881. }
  5882. input[type=number] {
  5883. -moz-appearance:textfield;
  5884. }
  5885. table td>h3 {
  5886. margin: 16px!important;
  5887. padding: 0!important;
  5888. }
  5889. table td>h4 {
  5890. padding: 0!important;
  5891. }
  5892. #saveBtn {
  5893. width: 60vw;
  5894. position: fixed;
  5895. z-index: 999;
  5896. bottom: 0;
  5897. left: 20vw;
  5898. font-size: xx-large;
  5899. opacity: 0.6;
  5900. cursor: pointer;
  5901. -moz-transition:all 0.3s ease;
  5902. -webkit-transition:all 0.3s ease;
  5903. transition:all 0.3s ease;
  5904. }
  5905. #configCon #saveBtn:hover {
  5906. opacity: 1;
  5907. margin-bottom: 0px;
  5908. }
  5909. #configCon #saveBtn {
  5910. margin-bottom: -30px;
  5911. }
  5912. #configCon.showSave #saveBtn {
  5913. margin-bottom: 0px;
  5914. }
  5915. `);
  5916. configCon = document.querySelector(".markdown-body,.theme-default-content");
  5917. if (!configCon) {
  5918. setTimeout(() => {
  5919. location.reload();
  5920. }, 1000);
  5921. return true;
  5922. }
  5923. let insertPos = configCon.querySelector("hr,#jsoneditor");
  5924. configCon = document.createElement("div");
  5925. configCon.id = "configCon";
  5926. insertPos.parentNode.insertBefore(configCon, insertPos);
  5927.  
  5928. importUrlPres = document.querySelectorAll("pre[name='user-content-pagetual'],pre[name='pagetual']");
  5929. if (importUrlPres) {
  5930. [].forEach.call(importUrlPres, importUrlPre => {
  5931. importUrlPre.style.overflow = "hidden";
  5932. importUrlPre.style.display = rulesData.uninited ? "block" : "none";
  5933. });
  5934. }
  5935. let otherconfig = document.querySelector("a[name='user-content-otherconfig'],a[name='otherconfig']");
  5936. if (otherconfig) otherconfig.parentNode.removeChild(otherconfig);
  5937. let rulesExample = document.querySelector("#user-content-rules-example+a,#rules-example>a");
  5938. if (rulesExample) {
  5939. rulesExample.innerText = i18n("rulesExample");
  5940. if (lang == "zh-CN") {
  5941. rulesExample.href = rulesExample.href.replace("en", "cn");
  5942. } else if (lang == "zh-TW" || lang == "zh-HK") {
  5943. rulesExample.href = rulesExample.href.replace("/en", "");
  5944. }
  5945. }
  5946. document.documentElement.scrollTop = 0;
  5947.  
  5948. let newPos, lastPos = 0;
  5949. window.addEventListener('scroll', function(e) {
  5950. newPos = window.scrollY;
  5951. if (newPos > lastPos) {
  5952. configCon.classList.add("showSave");
  5953. } else {
  5954. configCon.classList.remove("showSave");
  5955. }
  5956. lastPos = newPos;
  5957. });
  5958. } else return isGuidePage;
  5959. } else return isGuidePage;
  5960. let ruleBarInsertPos = document.createTextNode(' ');
  5961. configCon.appendChild(ruleBarInsertPos);
  5962. class Rulebar {
  5963. init(ruleUrl) {
  5964. let id = ruleUrl.id;
  5965. this.ruleUrl = ruleUrl;
  5966. this.item = document.createElement("p");
  5967. this.item.dataset.id = id;
  5968. let url = document.createElement("a");
  5969. url.href = ruleUrl.url;
  5970. url.innerHTML = ruleUrl.url;
  5971. url.title = ruleUrl.url;
  5972. let up = document.createElement("span");
  5973. up.innerHTML = "↑ ";
  5974. up.title = i18n("sortTitle");
  5975. let down = document.createElement("span");
  5976. down.innerHTML = "↓ ";
  5977. down.title = i18n("sortTitle");
  5978. let del = document.createElement("span");
  5979. del.innerHTML = "× ";
  5980. up.onclick = e => {
  5981. this.moveUp();
  5982. };
  5983. down.onclick = e => {
  5984. this.moveDown();
  5985. };
  5986. del.onclick = e => {
  5987. this.del();
  5988. };
  5989. this.item.appendChild(up);
  5990. this.item.appendChild(down);
  5991. this.item.appendChild(del);
  5992. this.item.appendChild(url);
  5993. if (ruleParser.rules) {
  5994. url.style.maxWidth = "calc(100% - 150px)";
  5995. url.style.overflow = "hidden";
  5996. url.style.display = "inline-block";
  5997. url.style.textOverflow = "ellipsis";
  5998. url.style.verticalAlign = "bottom";
  5999. url.style.whiteSpace = "nowrap";
  6000. let rulesLength = ruleParser.rules.reduce((acc, cur) => acc + (cur.from == id ? 1 : 0), 0);
  6001. let idSpan = document.createElement("span");
  6002. idSpan.style.float = "right";
  6003. idSpan.innerHTML = `[rules: ${rulesLength}]`;
  6004. this.item.appendChild(idSpan);
  6005. this.idSpan = idSpan;
  6006. }
  6007. configCon.insertBefore(this.item, ruleBarInsertPos);
  6008. }
  6009. updateNum() {
  6010. if (ruleParser.rules) {
  6011. let rulesLength = ruleParser.rules.reduce((acc, cur) => acc + (cur.from == this.item.dataset.id ? 1 : 0), 0);
  6012. this.idSpan.innerHTML = `[rules: ${rulesLength}]`;
  6013. }
  6014. }
  6015. saveSort() {
  6016. let sort = [];
  6017. [].forEach.call(this.item.parentNode.querySelectorAll("p[data-id]"), i => {
  6018. sort.push(i.dataset.id);
  6019. });
  6020. rulesData.sort = sort;
  6021. let urls = [];
  6022. sort.forEach(id => {
  6023. for (let s = 0; s < ruleUrls.length; s++) {
  6024. if (id == ruleUrls[s].id) {
  6025. urls.push(ruleUrls[s]);
  6026. break;
  6027. }
  6028. }
  6029. });
  6030. ruleUrls = urls;
  6031. storage.setItem("rulesData", rulesData);
  6032. showTips(i18n("sortTitle"));
  6033. }
  6034. moveUp() {
  6035. let preE = this.item.previousElementSibling;
  6036. if (compareNodeName(preE, ["p"]) && preE.children.length > 1) {
  6037. this.item.parentNode.insertBefore(this.item, preE);
  6038. this.saveSort();
  6039. }
  6040. }
  6041. moveDown() {
  6042. let nextE = this.item.nextElementSibling;
  6043. if (compareNodeName(nextE, ["p"]) && nextE.children.length > 1) {
  6044. this.item.parentNode.insertBefore(nextE, this.item);
  6045. this.saveSort();
  6046. }
  6047. }
  6048. del() {
  6049. if (this.ruleUrl.id < 2) {
  6050. showTips(i18n("cantDel"));
  6051. } else if (window.confirm(i18n("confirmDel"))) {
  6052. for (let u = 0; u < rulesData.urls.length; u++) {
  6053. if (this.ruleUrl.id == rulesData.urls[u].id) {
  6054. rulesData.urls.splice(u, 1);
  6055. break;
  6056. }
  6057. }
  6058. for (let u = 0; u < ruleUrls.length; u++) {
  6059. if (this.ruleUrl.id == ruleUrls[u].id) {
  6060. ruleUrls.splice(u, 1);
  6061. break;
  6062. }
  6063. }
  6064. for (let u = 0; u < rulesData.sort.length; u++) {
  6065. if (this.ruleUrl.id == rulesData.sort[u]) {
  6066. rulesData.sort.splice(u, 1);
  6067. break;
  6068. }
  6069. }
  6070. rulesData.ruleVersion = 0;
  6071. storage.setItem("rulesData", rulesData);
  6072. ruleParser.rules = ruleParser.rules.filter(item => {return item.from != this.ruleUrl.id});
  6073. storage.setItem("rules", ruleParser.rules);
  6074. this.item.parentNode.removeChild(this.item);
  6075. //location.reload();
  6076. }
  6077. }
  6078. }
  6079. let langSelect = document.createElement("select");
  6080. langSelect.style.float = "right";
  6081. langSelect.style.position = "relative";
  6082. langSelect.style.zIndex = "1";
  6083. let option = document.createElement("option");
  6084. option.value = "";
  6085. option.innerText = "Language";
  6086. langSelect.appendChild(option);
  6087. for (let key in langList) {
  6088. let option = document.createElement("option");
  6089. option.value = key;
  6090. option.innerText = langList[key];
  6091. langSelect.appendChild(option);
  6092. }
  6093. langSelect.value = rulesData.lang || "";
  6094. configCon.appendChild(langSelect);
  6095.  
  6096. let updateP = document.createElement("p"), i = 0;
  6097. let now = new Date().getTime();
  6098.  
  6099.  
  6100. let pastDate = (new Date(updateDate)).toString(), passStr;
  6101. let passTime = (now - updateDate) / 1000;
  6102. if (isNaN(passTime)) {
  6103. passStr = i18n("firstUpdate");
  6104. } else {
  6105. if (passTime < 60) {
  6106. passStr = i18n("passSec", parseInt(passTime));
  6107. } else if (passTime < 60 * 60) {
  6108. passStr = i18n("passMin", parseInt(passTime / 60));
  6109. } else if (passTime < 60 * 60 * 24) {
  6110. passStr = i18n("passHour", parseInt(passTime / 3600));
  6111. } else {
  6112. passStr = i18n("passDay", parseInt(passTime / 86400));
  6113. }
  6114. passStr += " 🖱 " + i18n("click2update");
  6115. }
  6116.  
  6117. let rulebarList = [], updateFail = false;
  6118. updateP.className = "updateDate";
  6119. updateP.innerHTML = passStr;
  6120. updateP.title = i18n("update") + " - " + pastDate;
  6121. configCon.appendChild(updateP);
  6122. if (ruleUrls) {
  6123. ruleUrls.forEach(ruleUrl => {
  6124. let rulebar = new Rulebar();
  6125. rulebar.init(ruleUrl);
  6126. rulebarList.push(rulebar);
  6127. });
  6128. }
  6129. let customUrlsTitle = document.createElement("h2");
  6130. customUrlsTitle.innerHTML = i18n("customUrls");
  6131. configCon.appendChild(customUrlsTitle);
  6132. let customUrlsInput = document.createElement("textarea");
  6133. customUrlsInput.style.width = "100%";
  6134. customUrlsInput.style.position = "relative";
  6135. customUrlsInput.placeholder = "http://wedata.net/databases/AutoPagerize/items_all.json \nhttps://hoothin.github.io/UserScripts/Pagetual/pagetualRules.json";
  6136. customUrlsInput.spellcheck = false;
  6137. configCon.appendChild(customUrlsInput);
  6138.  
  6139. let btns = document.createElement("div");
  6140. btns.style.display = "flex";
  6141. configCon.appendChild(btns);
  6142. let upBtnImg = document.createElement("div");
  6143. upBtnImg.style.width = "33%";
  6144. let upBtnImgTitle = document.createElement("h2");
  6145. upBtnImgTitle.style.whiteSpace = "nowrap";
  6146. upBtnImgTitle.style.overflow = "auto";
  6147. upBtnImgTitle.innerHTML = i18n("upBtnImg");
  6148. upBtnImg.appendChild(upBtnImgTitle);
  6149. let upBtnImgInput = document.createElement("input");
  6150. upBtnImgInput.style.width = "100%";
  6151. upBtnImgInput.style.position = "relative";
  6152. upBtnImgInput.placeholder = "data:image/png;base64,UpBtn";
  6153. upBtnImgInput.value = rulesData.upBtnImg || '';
  6154. upBtnImgInput.spellcheck = false;
  6155. upBtnImg.appendChild(upBtnImgInput);
  6156. btns.appendChild(upBtnImg);
  6157.  
  6158. let downBtnImg = document.createElement("div");
  6159. downBtnImg.style.width = "33%";
  6160. let downBtnImgTitle = document.createElement("h2");
  6161. downBtnImgTitle.style.whiteSpace = "nowrap";
  6162. downBtnImgTitle.style.overflow = "auto";
  6163. downBtnImgTitle.innerHTML = i18n("downBtnImg");
  6164. downBtnImg.appendChild(downBtnImgTitle);
  6165. let downBtnImgInput = document.createElement("input");
  6166. downBtnImgInput.style.width = "100%";
  6167. downBtnImgInput.style.position = "relative";
  6168. downBtnImgInput.placeholder = "data:image/png;base64,DownBtn";
  6169. downBtnImgInput.value = rulesData.downBtnImg || '';
  6170. downBtnImgInput.spellcheck = false;
  6171. downBtnImg.appendChild(downBtnImgInput);
  6172. btns.appendChild(downBtnImg);
  6173.  
  6174. let sideControllerIconDiv = document.createElement("div");
  6175. sideControllerIconDiv.style.width = "33%";
  6176. let sideControllerIconTitle = document.createElement("h2");
  6177. sideControllerIconTitle.style.whiteSpace = "nowrap";
  6178. sideControllerIconTitle.style.overflow = "auto";
  6179. sideControllerIconTitle.innerHTML = i18n("sideControllerIcon");
  6180. sideControllerIconDiv.appendChild(sideControllerIconTitle);
  6181. let sideControllerIconInput = document.createElement("input");
  6182. sideControllerIconInput.style.width = "100%";
  6183. sideControllerIconInput.style.position = "relative";
  6184. sideControllerIconInput.placeholder = "📄";
  6185. sideControllerIconInput.value = rulesData.sideControllerIcon || '';
  6186. sideControllerIconInput.spellcheck = false;
  6187. sideControllerIconDiv.appendChild(sideControllerIconInput);
  6188. btns.appendChild(sideControllerIconDiv);
  6189.  
  6190. let otherBtns = document.createElement("div");
  6191. otherBtns.style.display = "flex";
  6192. configCon.appendChild(otherBtns);
  6193. let loadingText = document.createElement("div");
  6194. loadingText.style.width = "100%";
  6195. let loadingTextTitle = document.createElement("h2");
  6196. loadingTextTitle.style.whiteSpace = "nowrap";
  6197. loadingTextTitle.style.overflow = "auto";
  6198. loadingTextTitle.innerHTML = i18n("loadingTextTitle");
  6199. loadingText.appendChild(loadingTextTitle);
  6200. let loadingTextInput = document.createElement("input");
  6201. loadingTextInput.value = rulesData.loadingText || '';
  6202. loadingTextInput.placeholder = i18n("loadingText");
  6203. loadingTextInput.style.width = "100%";
  6204. loadingTextInput.style.position = "relative";
  6205. loadingTextInput.style.margin = "0";
  6206. loadingTextInput.spellcheck = false;
  6207. loadingText.appendChild(loadingTextInput);
  6208. otherBtns.appendChild(loadingText);
  6209.  
  6210. let opacity = document.createElement("div");
  6211. let opacityTitle = document.createElement("h2");
  6212. opacityTitle.style.whiteSpace = "nowrap";
  6213. opacityTitle.style.overflow = "visible";
  6214. opacityTitle.innerHTML = i18n("opacity");
  6215. opacity.appendChild(opacityTitle);
  6216. let opacityInput = document.createElement("input");
  6217. opacityInput.value = rulesData.opacity * 100;
  6218. opacityInput.type = "number";
  6219. opacityInput.min = 0;
  6220. opacityInput.max = 100;
  6221. opacityInput.style.width = "110px";
  6222. opacityInput.style.position = "relative";
  6223. opacityInput.style.margin = "0";
  6224. opacityInput.placeholder = i18n("opacityPlaceholder");
  6225. opacityInput.spellcheck = false;
  6226. opacityInput.oninput = e => {
  6227. if (opacityInput.value > 100) opacityInput.value = 100;
  6228. else if (opacityInput.value < 0) opacityInput.value = 0;
  6229. };
  6230. opacity.appendChild(opacityInput);
  6231. otherBtns.appendChild(opacity);
  6232.  
  6233. let pageElementCss = document.createElement("div");
  6234. pageElementCss.style.marginBottom = "30px";
  6235. let pageElementCssTitle = document.createElement("h2");
  6236. pageElementCssTitle.innerHTML = i18n("pageElementCss");
  6237. pageElementCss.appendChild(pageElementCssTitle);
  6238. let pageElementCssInput = document.createElement("input");
  6239. pageElementCssInput.value = rulesData.pageElementCss || '';
  6240. pageElementCssInput.style.width = "100%";
  6241. pageElementCssInput.style.position = "relative";
  6242. pageElementCssInput.style.margin = "0";
  6243. pageElementCssInput.placeholder = "font-size: xx-large;";
  6244. pageElementCssInput.spellcheck = false;
  6245. pageElementCss.appendChild(pageElementCssInput);
  6246. configCon.appendChild(pageElementCss);
  6247.  
  6248. let customCss = document.createElement("div");
  6249. customCss.style.marginBottom = "50px";
  6250. let customCssTitle = document.createElement("h2");
  6251. customCssTitle.innerHTML = i18n("customCss");
  6252. customCss.appendChild(customCssTitle);
  6253. let customCssInput = document.createElement("textarea");
  6254. customCssInput.value = rulesData.customCss || '';
  6255. customCssInput.style.width = "100%";
  6256. customCssInput.style.position = "relative";
  6257. customCssInput.style.margin = "0";
  6258. customCssInput.placeholder = ".pagetual {\n}";
  6259. customCssInput.spellcheck = false;
  6260. customCss.appendChild(customCssInput);
  6261. configCon.appendChild(customCss);
  6262.  
  6263. let configTable = document.createElement("table");
  6264. configTable.style.width = "100%";
  6265. let configTbody = document.createElement("tbody");
  6266. configTbody.style.width = "99%";
  6267. configTbody.style.display = "inline-table";
  6268. configTable.appendChild(configTbody);
  6269. configCon.appendChild(configTable);
  6270. function createCheckbox(innerText, val, tag, parentCheck, otherType, alwaysShow) {
  6271. if (typeof val == 'undefined') val = "";
  6272. let title = document.createElement(tag || "h3");
  6273. title.innerHTML = innerText;
  6274. title.style.overflowWrap = "normal";
  6275. let input = document.createElement("input");
  6276. if (otherType === 'key') {
  6277. input.type = 'text';
  6278. input.setAttribute('readOnly', 'readonly');
  6279. input.addEventListener("keydown", e => {
  6280. if (e.key === 'Escape' || e.key === 'Backspace') input.value = '';
  6281. else input.value = e.key;
  6282. e.stopPropagation();
  6283. e.preventDefault();
  6284. });
  6285. } else {
  6286. input.type = otherType || "checkbox";
  6287. }
  6288. input.style.width = "35px";
  6289. input.style.height = "20px";
  6290. input.style.float = "left";
  6291. input.style.margin = "0 2px";
  6292. input.value = val;
  6293. input.checked = val;
  6294. let td = document.createElement("td");
  6295. td.appendChild(input);
  6296. if (parentCheck) {
  6297. title.appendChild(input);
  6298. title.style.margin = "0";
  6299. td.appendChild(title);
  6300. let parent = parentCheck.parentNode.nextElementSibling;
  6301. let tr = parent.querySelector("tr");
  6302. if (!tr) {
  6303. tr = document.createElement("tr");
  6304. parent.appendChild(tr);
  6305. }
  6306. tr.appendChild(td);
  6307. if (!alwaysShow) {
  6308. if (!parentCheck.checked) {
  6309. td.style.display = "none";
  6310. }
  6311. parentCheck.addEventListener("click", e => {
  6312. td.style.display = parentCheck.checked ? "" : "none";
  6313. });
  6314. }
  6315. } else {
  6316. let tr = document.createElement("tr");
  6317. tr.appendChild(td);
  6318. td = document.createElement("td");
  6319. td.appendChild(title);
  6320. tr.appendChild(td);
  6321. configTable.children[0].appendChild(tr);
  6322. }
  6323. let xNodePos = innerText.indexOf('【X】');
  6324. if (xNodePos !== -1) {
  6325. input.style.float = "";
  6326. let xNode = title.firstChild.splitText(xNodePos);
  6327. xNode.splitText(3);
  6328. xNode.parentNode.replaceChild(input, xNode);
  6329. }
  6330. return input;
  6331. }
  6332.  
  6333. let setConfigPageInput = createCheckbox(i18n("setConfigPage"), false);
  6334. let enableWhiteListInput = createCheckbox(i18n("autoRun"), rulesData.enableWhiteList != true);
  6335. let sideControllerInput = createCheckbox(i18n("sideController"), rulesData.sideController);
  6336. let sideControllerAlwaysInput = createCheckbox(i18n("sideControllerAlways"), rulesData.sideControllerAlways, "h4", sideControllerInput);
  6337. let sideControllerScrollInput = createCheckbox(i18n("sideControllerScroll"), rulesData.sideControllerScroll !== false, "h4", sideControllerInput);
  6338. let sideControllerLoadNowInput = createCheckbox(i18n("loadNow"), rulesData.sideControllerLoadNow !== false, "h4", sideControllerInput);
  6339. let enableDebugInput = createCheckbox(i18n("enableDebug"), rulesData.enableDebug != false);
  6340. let enableHistoryInput = createCheckbox(i18n("enableHistory"), rulesData.enableHistory === true);
  6341. let enableHistoryAfterInsertInput = createCheckbox(i18n("enableHistoryAfterInsert"), rulesData.enableHistoryAfterInsert === true, "h4", enableHistoryInput);
  6342. let openInNewTabInput = createCheckbox(i18n("openInNewTab"), rulesData.openInNewTab != false);
  6343. let hidePageBarInput = createCheckbox(i18n("hideBarTips"), rulesData.opacity == 0);
  6344. let hidePageBarArrowInput = createCheckbox(i18n("hideBarArrow"), rulesData.hideBarArrow);
  6345. let hideLoadingIconInput = createCheckbox(i18n("hideLoadingIcon"), rulesData.hideLoadingIcon != false);
  6346. let initRunInput = createCheckbox(i18n("initRun"), rulesData.initRun != false);
  6347. let autoLoadNumInput = createCheckbox(i18n("autoLoadNum"), rulesData.autoLoadNum, "h4", initRunInput, "number");
  6348. let preloadInput = createCheckbox(i18n("preload"), rulesData.preload != false);
  6349. let rateInput = createCheckbox(i18n("turnRate"), rulesData.rate, "h4", preloadInput, "number", true);
  6350. let dbClick2StopInput = createCheckbox(i18n("dbClick2Stop"), rulesData.dbClick2Stop);
  6351. let manualModeInput = createCheckbox(i18n("manualMode"), rulesData.manualMode);
  6352. let clickModeInput = createCheckbox(i18n("clickMode"), rulesData.clickMode);
  6353. let pageBarMenuInput = createCheckbox(i18n("pageBarMenu"), rulesData.pageBarMenu != false);
  6354. let arrowToScrollInput = createCheckbox(i18n("arrowToScroll"), rulesData.arrowToScroll);
  6355. let contentVisibilityInput = createCheckbox(i18n("contentVisibility"), rulesData.contentVisibility);
  6356. let wedata2githubInput = createCheckbox(i18n("wedata2github"), rulesData.wedata2github);
  6357. let customFirstInput = createCheckbox(i18n("customFirst"), rulesData.customFirst);
  6358. let lastPageTipsInput = createCheckbox(i18n("lastPageTips"), rulesData.lastPageTips);
  6359. let updateNotificationInput = createCheckbox(i18n("updateNotification"), rulesData.updateNotification != false);
  6360.  
  6361. let hideBarInput = createCheckbox(i18n("hideBar"), rulesData.hideBar && !rulesData.hideBarButNoStop, "h4", dbClick2StopInput, 'radio');
  6362. hideBarInput.name = 'hideBar';
  6363. let hideBarButNoStopInput = createCheckbox(i18n("hideBarButNoStop"), rulesData.hideBarButNoStop, "h4", dbClick2StopInput, 'radio');
  6364. hideBarButNoStopInput.name = 'hideBar';
  6365. hideBarInput.addEventListener('mouseup', e => {
  6366. if (hideBarInput.checked) {
  6367. setTimeout(() => {hideBarInput.checked = false}, 0);
  6368. }
  6369. });
  6370. hideBarButNoStopInput.addEventListener('mouseup', e => {
  6371. if (hideBarButNoStopInput.checked) {
  6372. setTimeout(() => {hideBarButNoStopInput.checked = false}, 0);
  6373. }
  6374. });
  6375. hidePageBarInput.addEventListener('click', e => {
  6376. opacityInput.value = hidePageBarInput.checked ? 0 : 100;
  6377. });
  6378.  
  6379. let dbClick2StopCtrlInput = createCheckbox(i18n("dbClick2StopCtrl"), rulesData.dbClick2StopCtrl, "h4", dbClick2StopInput);
  6380. let dbClick2StopAltInput = createCheckbox(i18n("dbClick2StopAlt"), rulesData.dbClick2StopAlt, "h4", dbClick2StopInput);
  6381. let dbClick2StopShiftInput = createCheckbox(i18n("dbClick2StopShift"), rulesData.dbClick2StopShift, "h4", dbClick2StopInput);
  6382. let dbClick2StopMetaInput = createCheckbox(i18n("dbClick2StopMeta"), rulesData.dbClick2StopMeta, "h4", dbClick2StopInput);
  6383. let dbClick2StopKeyInput = createCheckbox(i18n("dbClick2StopKey"), rulesData.dbClick2StopKey, "h4", dbClick2StopInput, "key");
  6384.  
  6385. let otherConfigPage = (rulesData.configPage || configPage[0]) != location.href.replace(/#.*/, "");
  6386. if (!otherConfigPage) {
  6387. setConfigPageInput.parentNode.parentNode.style.display = "none";
  6388. }
  6389.  
  6390. updateP.onclick = e => {
  6391. updateFail = false;
  6392. //ruleParser.rules = [];
  6393. showTips(i18n("beginUpdate"), "", 30000);
  6394. updateRules(() => {
  6395. if (!updateFail) {
  6396. showTips(i18n("updateSucc"));
  6397. if (importUrlPres) {
  6398. [].forEach.call(importUrlPres, importUrlPre => {
  6399. importUrlPre.style.display = "none";
  6400. });
  6401. }
  6402. if (click2import) click2import.style.display = "none";
  6403. }
  6404. updateP.innerHTML = i18n("passSec", 0);
  6405. updateP.title = i18n("update");
  6406. rulebarList.forEach(rulebar => {
  6407. rulebar.updateNum();
  6408. });
  6409. }, (rule, err) => {
  6410. if (rule.id == 1) {
  6411. showTips(`Failed to update wedata rules! Try to switch to wedata mirror!`);
  6412. wedata2githubInput.scrollIntoView({ behavior: "smooth" });
  6413. } else {
  6414. showTips(`Failed to update ${rule.url} rules!`);
  6415. }
  6416. debug(err);
  6417. updateFail = true;
  6418. });
  6419. };
  6420. let customRulesTitle = document.createElement("h2");
  6421. customRulesTitle.innerHTML = i18n("customRules", /tree/.test(location.href) ? location.href.replace('tree', 'edit').replace(/\/$/, '') + '/pagetualRules.json' : 'https://github.com/hoothin/UserScripts/edit/master/Pagetual/pagetualRules.json');
  6422. configCon.appendChild(customRulesTitle);
  6423. customRulesInput = document.createElement("textarea");
  6424. customRulesInput.spellcheck = false;
  6425. configCon.appendChild(customRulesInput);
  6426. if (rulesData.editTemp) {
  6427. if (!ruleParser.customRules) {
  6428. ruleParser.customRules = [];
  6429. }
  6430. for (let i in ruleParser.customRules) {
  6431. if (ruleParser.customRules[i].url == rulesData.editTemp.url) {
  6432. ruleParser.customRules.splice(i, 1);
  6433. break;
  6434. }
  6435. }
  6436. ruleParser.customRules.unshift(rulesData.editTemp);
  6437. rulesData.editTemp = null;
  6438. storage.setItem("rulesData", rulesData);
  6439. customRulesInput.previousElementSibling.scrollIntoView();
  6440. }
  6441. customRulesInput.style.width = "100%";
  6442. customRulesInput.style.height = "800px";
  6443. 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]`;
  6444. let preCustom = getFormatJSON(ruleParser.customRules);
  6445. customRulesInput.value = preCustom;
  6446. if (isGuidePage) customRulesInput.style.display = "none";
  6447. let blacklistInput = document.createElement("textarea");
  6448. blacklistInput.style.width = "100%";
  6449. blacklistInput.style.height = "500px";
  6450. blacklistInput.style.display = "none";
  6451. blacklistInput.spellcheck = false;
  6452. blacklistInput.placeholder = "http://*.xxx.com/*/y\n/^https?://.*\\.xxx\\.com/i \t\t<= Regexp\n//http://*.aaa.com/ \t\t<= Disable\n/*http://*.bbb.com\nhttp://*.ccc.com*/ \t\t<= Block comment";
  6453. blacklistInput.value = rulesData.blacklist ? rulesData.blacklist.join("\n") : "";
  6454. let blacklistBtn = document.createElement("button");
  6455. blacklistBtn.innerText = i18n("editBlacklist");
  6456. blacklistBtn.style.width = "100%";
  6457. blacklistBtn.onclick = e => {
  6458. blacklistInput.style.display = blacklistInput.style.display == "none" ? "" : "none";
  6459. };
  6460. configCon.appendChild(blacklistBtn);
  6461. configCon.appendChild(blacklistInput);
  6462. let saveBtn = document.createElement("button");
  6463. saveBtn.innerHTML = i18n("save");
  6464. saveBtn.id = "saveBtn";
  6465. configCon.appendChild(saveBtn);
  6466. saveBtn.onclick = e => {
  6467. try {
  6468. let customRules;
  6469. if (editor) {
  6470. if (editorChanged) {
  6471. editorChanged = false;
  6472. storage.setItem("hpRules", []);
  6473. storage.setItem("smartRules", []);
  6474. }
  6475. customRules = editor.get();
  6476. if (!customRules) {
  6477. customRules = "";
  6478. } else {
  6479. if (Array && Array.isArray && !Array.isArray(customRules)) {
  6480. showTips(i18n("errorRulesMustBeArray"));
  6481. return;
  6482. }
  6483. }
  6484. } else {
  6485. if (customRulesInput.value != preCustom) {
  6486. storage.setItem("hpRules", []);
  6487. storage.setItem("smartRules", []);
  6488. }
  6489. if (customRulesInput.value == "") {
  6490. customRules = "";
  6491. } else {
  6492. customRules = JSON.parse(customRulesInput.value);
  6493. if (Array && Array.isArray && !Array.isArray(customRules)) {
  6494. showTips(i18n("errorRulesMustBeArray"));
  6495. return;
  6496. }
  6497. customRulesInput.value = JSON.stringify(customRules, null, 4);
  6498. }
  6499. }
  6500. debug(customRules);
  6501. storage.setItem("customRules", customRules);
  6502. } catch(e) {
  6503. debug(e);
  6504. let pos = e && e.message && e.message.match(/position (\d+)/);
  6505. if (pos && !editor) {
  6506. pos = parseInt(pos[1]);
  6507. customRulesInput.value = customRulesInput.value.slice(0, pos) + "➡️" + customRulesInput.value.slice(pos);
  6508. }
  6509. showTips(i18n("errorJson"));
  6510. return;
  6511. }
  6512. rulesData.lang = langSelect.value || "";
  6513. if (setConfigPageInput.checked) rulesData.configPage = location.href;
  6514. rulesData.wedata2github = wedata2githubInput.checked;
  6515. let opacity = parseInt(opacityInput.value) || 0;
  6516. if (opacity > 100) opacity = 100;
  6517. else if (opacity < 0) opacity = 0;
  6518. rulesData.opacity = opacity / 100;
  6519. rulesData.blacklist = blacklistInput.value ? blacklistInput.value.trim().split("\n") : "";
  6520. rulesData.hideBar = hideBarInput.checked;
  6521. rulesData.hideBarButNoStop = hideBarButNoStopInput.checked;
  6522. rulesData.dbClick2Stop = dbClick2StopInput.checked;
  6523. rulesData.enableWhiteList = !enableWhiteListInput.checked;
  6524. rulesData.enableDebug = enableDebugInput.checked;
  6525. rulesData.updateNotification = updateNotificationInput.checked;
  6526. rulesData.enableHistory = enableHistoryInput.checked;
  6527. rulesData.enableHistoryAfterInsert = enableHistoryAfterInsertInput.checked;
  6528. rulesData.openInNewTab = openInNewTabInput.checked;
  6529. rulesData.hideLoadingIcon = hideLoadingIconInput.checked;
  6530. rulesData.hideBarArrow = hidePageBarArrowInput.checked;
  6531. rulesData.customFirst = customFirstInput.checked;
  6532. rulesData.lastPageTips = lastPageTipsInput.checked;
  6533. rulesData.initRun = initRunInput.checked;
  6534. rulesData.autoLoadNum = autoLoadNumInput.value !== "0" ? autoLoadNumInput.value : '';
  6535. rulesData.rate = parseFloat(rateInput.value) || 0;
  6536. rulesData.preload = preloadInput.checked;
  6537. rulesData.manualMode = manualModeInput.checked;
  6538. rulesData.clickMode = clickModeInput.checked;
  6539. rulesData.pageBarMenu = pageBarMenuInput.checked;
  6540. rulesData.arrowToScroll = arrowToScrollInput.checked;
  6541. rulesData.contentVisibility = contentVisibilityInput.checked;
  6542. if (rulesData.sideController != sideControllerInput.checked) {
  6543. rulesData.sideControllerPos = false;
  6544. }
  6545. rulesData.sideController = sideControllerInput.checked;
  6546. rulesData.sideControllerScroll = sideControllerScrollInput.checked;
  6547. rulesData.sideControllerLoadNow = sideControllerLoadNowInput.checked;
  6548. rulesData.sideControllerAlways = sideControllerAlwaysInput.checked;
  6549. rulesData.pageElementCss = pageElementCssInput.value;
  6550. rulesData.customCss = customCssInput.value;
  6551. rulesData.upBtnImg = upBtnImgInput.value;
  6552. rulesData.downBtnImg = downBtnImgInput.value;
  6553. rulesData.sideControllerIcon = sideControllerIconInput.value;
  6554. rulesData.loadingText = loadingTextInput.value;
  6555. rulesData.dbClick2StopCtrl = dbClick2StopCtrlInput.checked;
  6556. rulesData.dbClick2StopAlt = dbClick2StopAltInput.checked;
  6557. rulesData.dbClick2StopShift = dbClick2StopShiftInput.checked;
  6558. rulesData.dbClick2StopMeta = dbClick2StopMetaInput.checked;
  6559. rulesData.dbClick2StopKey = dbClick2StopKeyInput.value;
  6560. storage.setItem("rulesData", rulesData);
  6561. let customUrls = customUrlsInput.value.trim(), urlImported = false;
  6562. if (customUrls) {
  6563. customUrls = customUrls.split(/\n/);
  6564. for (let c = 0; c < customUrls.length; c++) {
  6565. let url;
  6566. if (/^0\s*\|/.test(customUrls[c])) {
  6567. url = customUrls[c].replace(/^0\s*\|\s*/, "").trim();
  6568. if (!/^http/.test(url)) {
  6569. showTips(i18n("errorWrongUrl"));
  6570. return;
  6571. }
  6572. } else {
  6573. url = customUrls[c].trim();
  6574. if (!/^http/.test(url)) {
  6575. showTips(i18n("errorWrongUrl"));
  6576. return;
  6577. }
  6578. }
  6579. let maxId = 1, hasUrl = false;
  6580. if (!rulesData.urls) {
  6581. rulesData.urls = [];
  6582. }
  6583. ruleUrls.forEach(u => {
  6584. if (maxId < u.id) {
  6585. maxId = u.id;
  6586. }
  6587. if (u.url == url) {
  6588. hasUrl = true;
  6589. }
  6590. });
  6591. if (hasUrl) break;
  6592. if (!rulesData.sort) rulesData.sort = [1];
  6593. let newRule = {id: maxId + 1, url: url};
  6594. ruleUrls.push(newRule);
  6595. rulesData.urls.push(newRule);
  6596. rulesData.sort.push(maxId + 1);
  6597. storage.setItem("rulesData", rulesData);
  6598. let rulebar = new Rulebar();
  6599. rulebar.init(newRule);
  6600. rulebarList.push(rulebar);
  6601. }
  6602. }
  6603. showTips(i18n("settingsSaved"));
  6604. };
  6605. return true;
  6606. }
  6607.  
  6608. function updateRules (success, fail, keepCache) {
  6609. if (!storage.supportCrossSave()) {
  6610. fail({url:''}, "Not support cross storage");
  6611. showTips("Current platform do not support cross storage!");
  6612. return;
  6613. }
  6614. if (inUpdate) return;
  6615. inUpdate = true;
  6616. let ruleIndex = ruleUrls.length - 1;
  6617. if (!keepCache) {
  6618. storage.setItem("hpRules", []);
  6619. storage.setItem("smartRules", []);
  6620. }
  6621. let allOk = true;
  6622. let preLength = ruleParser.rules.length;
  6623. let fetchVersion = -1;
  6624. async function needUpdate(url, id) {
  6625. if (!/^https:\/\/hoothin\.github\.io\/|\/hoothin\/UserScripts\/.*\/Pagetual\/pagetualRules\.json/i.test(url)) {
  6626. return true;
  6627. }
  6628. let rulesLength = ruleParser.rules.reduce((acc, cur) => acc + (cur.from == id ? 1 : 0), 0);
  6629. if (rulesLength === 0) return true;
  6630. if (fetchVersion >= 0) {
  6631. return fetchVersion > (rulesData.ruleVersion || 0);
  6632. }
  6633. fetchVersion = await new Promise(resolve => {
  6634. _GM_xmlhttpRequest({
  6635. url: url.replace(/\/\w+\.json/i, "/version"),
  6636. method: 'GET',
  6637. timeout: 20000,
  6638. headers: {
  6639. 'accept': 'application/json,text/html'
  6640. },
  6641. onload: function(res) {
  6642. let version = parseInt(res.response || res.responseText);
  6643. resolve(version || -1);
  6644. },
  6645. onerror: function(e) {
  6646. resolve(-1);
  6647. },
  6648. ontimeout: function(e) {
  6649. resolve(-1);
  6650. }
  6651. });
  6652. });
  6653. return fetchVersion > (rulesData.ruleVersion || 0);
  6654. }
  6655. async function addNextRule() {
  6656. if (ruleIndex < 0) {
  6657. let now = new Date().getTime();
  6658. storage.setItem("ruleLastUpdate", now);
  6659. storage.setItem("rules", ruleParser.rules);
  6660. let curLength = ruleParser.rules.length;
  6661. if (curLength !== preLength && rulesData.updateNotification) {
  6662. _GM_notification({
  6663. text: `Rules has updated( ${preLength} => ${curLength} )`,
  6664. title: "Pagetual rules updated",
  6665. onclick: (event) => {
  6666. event.preventDefault();
  6667. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  6668. }
  6669. });
  6670. }
  6671. inUpdate = false;
  6672. let rulesDataChanged = false;
  6673. if (fetchVersion >= 0 && rulesData.ruleVersion !== fetchVersion) {
  6674. rulesData.ruleVersion = fetchVersion;
  6675. rulesDataChanged = true;
  6676. }
  6677. if (rulesData.uninited && allOk && ruleUrls.length > 1) {
  6678. rulesData.uninited = false;
  6679. rulesDataChanged = true;
  6680. }
  6681. if (rulesDataChanged) {
  6682. storage.setItem("rulesData", rulesData);
  6683. }
  6684. success();
  6685. } else {
  6686. let rule = ruleUrls[ruleIndex--];
  6687. if (await needUpdate(rule.url, rule.id)) {
  6688. ruleParser.addRuleByUrl(rule.url, rule.id, (json, err) => {
  6689. if (!json) {
  6690. allOk = false;
  6691. fail(rule, err);
  6692. }
  6693. addNextRule();
  6694. });
  6695. } else {
  6696. addNextRule();
  6697. }
  6698. }
  6699. }
  6700. addNextRule();
  6701. }
  6702.  
  6703. function objIsArr(obj) {
  6704. return obj &&
  6705. typeof obj === 'object' &&
  6706. typeof obj.length === 'number' &&
  6707. !(obj.propertyIsEnumerable('length'));
  6708. }
  6709.  
  6710. function isVisible(el, win) {
  6711. if(!el || !el.offsetParent)return false;
  6712. var loopable = true,
  6713. visible = el.nodeName && win.getComputedStyle(el).display != 'none' && win.getComputedStyle(el).visibility != 'hidden';
  6714. while(loopable && visible) {
  6715. el = el.parentNode;
  6716.  
  6717. if(el && el.nodeType === 1 && !compareNodeName(el, ["body"])) {
  6718. visible = win.getComputedStyle(el).display != 'none' && win.getComputedStyle(el).visibility != 'hidden';
  6719. }else {
  6720. loopable = false;
  6721. }
  6722. }
  6723. return visible;
  6724. }
  6725.  
  6726. function getElementTop(ele) {
  6727. if (!ele) return 0;
  6728. if (ele.getBoundingClientRect) {
  6729. return ele.getBoundingClientRect().top + document.documentElement.scrollTop;
  6730. }
  6731. var actualTop = ele.offsetTop;
  6732. var current = ele.offsetParent;
  6733. while (current) {
  6734. actualTop += current.offsetTop;
  6735. current = current.offsetParent;
  6736. }
  6737. return actualTop;
  6738. }
  6739.  
  6740. function getElementLeft(ele) {
  6741. if (!ele) return 0;
  6742. if (ele.getBoundingClientRect) {
  6743. return ele.getBoundingClientRect().left + document.documentElement.scrollLeft;
  6744. }
  6745. var actualLeft = ele.offsetLeft;
  6746. var current = ele.offsetParent;
  6747. while (current) {
  6748. actualLeft += current.offsetLeft;
  6749. current = current.offsetParent;
  6750. }
  6751. return actualLeft;
  6752. }
  6753.  
  6754. function getElementBottom(ele) {
  6755. return getElementTop(ele) + (ele.offsetHeight || ele.scrollHeight);
  6756. }
  6757.  
  6758. function getFormatJSON(obj){
  6759. if(!objIsArr(obj) || obj.length === 0)return "";
  6760. return JSON.stringify(obj, null, 4);
  6761. }
  6762.  
  6763. function globMatch(first, second) {
  6764. if (first === '*') {
  6765. return true;
  6766. }
  6767. if (first.length == 0 && second.length == 0){
  6768. return true;
  6769. }
  6770.  
  6771. if (first.length > 1 && first[0] == '*' &&
  6772. second.length == 0){
  6773. return false;
  6774. }
  6775.  
  6776. if ((first.length > 1 && first[0] == '?') ||
  6777. (first.length != 0 && second.length != 0 &&
  6778. first[0] == second[0])){
  6779. return globMatch(first.substring(1),
  6780. second.substring(1));
  6781. }
  6782.  
  6783. if (first.length > 0 && first[0] == '*'){
  6784. return globMatch(first.substring(1), second) ||
  6785. globMatch(first, second.substring(1));
  6786. }
  6787.  
  6788. return false;
  6789. }
  6790.  
  6791. let pageReady = false;
  6792. function initRules(callback) {
  6793. charset = (document.characterSet || document.charset || document.inputEncoding);
  6794. let equiv = document.querySelector('[http-equiv="Content-Type"]');
  6795. if (equiv && equiv.content) {
  6796. let innerCharSet = equiv.content.match(/charset\=([^;]+)/);
  6797. if (!innerCharSet) {
  6798. charsetValid = false;
  6799. } else if (innerCharSet[1].replace("-", "").toLowerCase() != charset.replace("-", "").toLowerCase()) {
  6800. charsetValid = false;
  6801. }
  6802. } else charsetValid = false;
  6803. storage.getItem("rulesData", data => {
  6804. /*0 wedata格式,1 pagetual格式*/
  6805. ruleUrls = [{
  6806. id: 1,
  6807. url: data && data.wedata2github ? 'https://hoothin.github.io/UserScripts/Pagetual/items_all.json' : 'http://wedata.net/databases/AutoPagerize/items_all.json',
  6808. type: 0,
  6809. }];
  6810. if (data) {
  6811. rulesData = data;
  6812. if (data.urls) ruleUrls = ruleUrls.concat(data.urls);
  6813. if (data.sort) {
  6814. let urls = [];
  6815. data.sort.forEach(id => {
  6816. for (let s = 0; s < ruleUrls.length; s++) {
  6817. if (id == ruleUrls[s].id) {
  6818. urls.push(ruleUrls[s]);
  6819. break;
  6820. }
  6821. }
  6822. });
  6823. ruleUrls = urls;
  6824. }
  6825. }
  6826. if (rulesData.lang) {
  6827. setLang(rulesData.lang);
  6828. }
  6829. if (rulesData.firstRun) {
  6830. rulesData.firstRun = false;
  6831. storage.setItem("rulesData", rulesData);
  6832. setTimeout(() => {
  6833. storage.getItem("rulesData", data => {
  6834. if (data.firstRun === false) {
  6835. _GM_openInTab(firstRunPage, {active: true});
  6836. }
  6837. });
  6838. }, 100);
  6839. }
  6840. _GM_registerMenuCommand(i18n("configure"), () => {
  6841. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  6842. });
  6843. if (rulesData.blacklist && rulesData.blacklist.length > 0) {
  6844. let href = location.href.slice(0, 500);
  6845. let commentStart = false;
  6846. for (let i = 0; i < rulesData.blacklist.length; i++) {
  6847. let curGlob = rulesData.blacklist[i];
  6848. if (!curGlob) continue;
  6849. if (curGlob.indexOf("//") == 0) continue;
  6850. if (commentStart) {
  6851. if (/\*\/$/.test(curGlob)) {
  6852. commentStart = false;
  6853. }
  6854. continue;
  6855. }
  6856. if (curGlob.indexOf("/*") == 0) {
  6857. commentStart = true;
  6858. continue;
  6859. }
  6860. if (curGlob.indexOf("/") == 0) {
  6861. let regMatch = curGlob.match(/^\/(.*)\/(\w*)$/);
  6862. if (regMatch && new RegExp(regMatch[1], regMatch[2]).test(href)) {
  6863. forceState == 1;
  6864. return;
  6865. }
  6866. } else if (globMatch(curGlob, href)) {
  6867. forceState == 1;
  6868. return;
  6869. }
  6870. }
  6871. }
  6872. _GM_registerMenuCommand(i18n("editCurrent"), () => {
  6873. picker.start();
  6874. });
  6875. ruleParser.initSavedRules(async () => {
  6876. let upBtnImg = rulesData.upBtnImg, downBtnImg = rulesData.downBtnImg, _sideControllerIcon = rulesData.sideControllerIcon;
  6877. if (upBtnImg && downBtnImg) {
  6878. downSvgCSS = downSvgCSS.replace("transform: rotate(180deg);", "");
  6879. } else if (upBtnImg && !downBtnImg) {
  6880. downBtnImg = upBtnImg;
  6881. } else if(downBtnImg && !upBtnImg) {
  6882. upBtnImg = downBtnImg;
  6883. }
  6884. if (upBtnImg) {
  6885. upSvg = /https?:|data/.test(upBtnImg) ? `<img class="pagetual" src="${upBtnImg}"/>` : `<span>${upBtnImg}</span>`;
  6886. }
  6887. if (downBtnImg) {
  6888. downSvg = /https?:|data/.test(downBtnImg) ? `<img class="pagetual" src="${downBtnImg}"/>` : `<span>${downBtnImg}</span>`;
  6889. }
  6890. if (_sideControllerIcon) {
  6891. sideControllerIcon = /https?:|data/.test(_sideControllerIcon) ? `<img class="pagetual" src="${_sideControllerIcon}"/>` : `<span>${_sideControllerIcon}</span>`;
  6892. }
  6893. setLoadingDiv(rulesData.loadingText || i18n("loadingText"));
  6894. if (typeof(rulesData.opacity) == "undefined") {
  6895. rulesData.opacity = 1;
  6896. }
  6897. if (typeof(rulesData.hideBar) == "undefined") {
  6898. rulesData.hideBar = false;
  6899. }
  6900. if (typeof(rulesData.dbClick2Stop) == "undefined") {
  6901. rulesData.dbClick2Stop = true;
  6902. }
  6903. if (typeof(rulesData.enableWhiteList) == "undefined") {
  6904. rulesData.enableWhiteList = false;
  6905. }
  6906. if (typeof(rulesData.enableHistory) == "undefined") {
  6907. rulesData.enableHistory = false;
  6908. }
  6909. if (typeof(rulesData.openInNewTab) == "undefined") {
  6910. rulesData.openInNewTab = false;
  6911. }
  6912. if (typeof(rulesData.enableDebug) == "undefined") {
  6913. rulesData.enableDebug = true;
  6914. }
  6915. if (typeof(rulesData.updateNotification) == "undefined") {
  6916. rulesData.updateNotification = true;
  6917. }
  6918. if (typeof(rulesData.initRun) == "undefined") {
  6919. rulesData.initRun = true;
  6920. }
  6921. if (typeof(rulesData.preload) == "undefined") {
  6922. rulesData.preload = true;
  6923. }
  6924. if (typeof(rulesData.customFirst) == "undefined") {
  6925. rulesData.customFirst = false;
  6926. }
  6927. if (typeof(rulesData.manualMode) == "undefined") {
  6928. rulesData.manualMode = false;
  6929. }
  6930. if (typeof(rulesData.clickMode) == "undefined") {
  6931. rulesData.clickMode = false;
  6932. }
  6933. if (typeof(rulesData.pageBarMenu) == "undefined") {
  6934. rulesData.pageBarMenu = true;
  6935. }
  6936. if (typeof(rulesData.arrowToScroll) == "undefined") {
  6937. rulesData.arrowToScroll = false;
  6938. }
  6939. if (typeof(rulesData.hideLoadingIcon) == "undefined") {
  6940. rulesData.hideLoadingIcon = false;
  6941. }
  6942. if (typeof(rulesData.hideBarArrow) == "undefined") {
  6943. rulesData.hideBarArrow = false;
  6944. }
  6945. if (typeof(rulesData.lastPageTips) == "undefined") {
  6946. rulesData.lastPageTips = true;
  6947. }
  6948. if (typeof(rulesData.rate) == "undefined") {
  6949. rulesData.rate = 1;
  6950. }
  6951. rate = rulesData.rate;
  6952. if (rulesData.autoLoadNum && rulesData.initRun) {
  6953. autoLoadNum = parseInt(rulesData.autoLoadNum);
  6954. }
  6955. openInNewTab = rulesData.openInNewTab ? 1 : 0;
  6956. enableDebug = rulesData.enableDebug;
  6957.  
  6958. let _nextSwitch = await getListData("nextSwitch", location.host);
  6959. if (typeof(_nextSwitch) !== "undefined") {
  6960. nextIndex = _nextSwitch || 0;
  6961. }
  6962.  
  6963. let _forceState = await getListData("forceState", location.host);
  6964. if (typeof(_forceState) == "undefined") {
  6965. _forceState = await getData("forceState_" + location.host);
  6966. }
  6967. if (typeof(_forceState) == "undefined") {
  6968. _forceState = (rulesData.enableWhiteList ? 1 : 0);
  6969. }
  6970. forceState = _forceState;
  6971.  
  6972. autoScroll = await getListData("autoScroll", location.host + location.pathname) || 0;
  6973.  
  6974. updateDate = await getData("ruleLastUpdate");
  6975.  
  6976. let _loadNowNum = await getData("loadNowNum");
  6977. if (typeof(_loadNowNum) != "undefined") {
  6978. loadNowNum = _loadNowNum;
  6979. }
  6980. let _autoScrollRate = await getData("autoScrollRate");
  6981. if (_autoScrollRate) {
  6982. autoScrollRate = _autoScrollRate;
  6983. }
  6984.  
  6985. author = await getData("author") || "";
  6986.  
  6987. manualPause = !!await getListData("pauseState", location.host);
  6988.  
  6989. let href = location.href.slice(0, 100);
  6990. try {
  6991. if (_unsafeWindow.initedPagetual) {
  6992. if (ruleImportUrlReg.test(href)) {
  6993. showTips(i18n('duplicate'));
  6994. }
  6995. return;
  6996. }
  6997. _unsafeWindow.initedPagetual = true;
  6998. } catch(e) {showTips(e)}
  6999. listenUrl();
  7000. _GM_registerMenuCommand(i18n("update"), () => {
  7001. showTips(i18n("beginUpdate"), "", 60000);
  7002. updateRules(() => {
  7003. showTips(i18n("updateSucc"));
  7004. location.reload();
  7005. },(rule, err) => {
  7006. showTips(`Failed to update ${rule.url} rules!`);
  7007. debug(err);
  7008. });
  7009. });
  7010. _GM_registerMenuCommand(i18n(forceState == 1 ? "enable" : "disableSite"), () => {
  7011. if (forceState == 1) {
  7012. forceState = 0;
  7013. showTips(i18n("enableSiteTips"));
  7014. changeStop(false, true);
  7015. } else {
  7016. forceState = 1;
  7017. showTips(i18n("disableSiteTips"));
  7018. changeStop(true, true);
  7019. sideController.remove();
  7020. }
  7021. setListData("forceState", location.host, forceState);
  7022. if (!ruleParser.curSiteRule.url) {
  7023. setTimeout(() => {
  7024. location.reload();
  7025. }, 500);
  7026. }
  7027. });
  7028. _GM_registerMenuCommand(i18n("toggleAutoScroll"), () => {
  7029. autoScroll = (autoScroll ? 0 : prompt(i18n("autoScrollRate"), autoScrollRate)) || 0;
  7030. autoScroll = parseInt(autoScroll) || 0;
  7031. if (autoScroll < 0) autoScroll = 0;
  7032. if (autoScroll && autoScroll != autoScrollRate) {
  7033. autoScrollRate = autoScroll;
  7034. storage.setItem("autoScrollRate", autoScrollRate);
  7035. }
  7036. setListData("autoScroll", location.host + location.pathname, autoScroll);
  7037. startAutoScroll();
  7038. });
  7039. startAutoScroll();
  7040.  
  7041.  
  7042. if (initConfig(href)) {
  7043. document.addEventListener("click", e => {
  7044. if (e.target && typeof e.target.dataset.pagetualPicker !== 'undefined') {
  7045. e.preventDefault();
  7046. e.stopPropagation();
  7047. picker.start();
  7048. }
  7049. });
  7050. return;
  7051. }
  7052. pageReady = true;
  7053. if (forceState == 1) return;
  7054. let now = new Date().getTime();
  7055. if (!updateDate || now - updateDate > 2 * 24 * 60 * 60 * 1000) {
  7056. updateRules(() => {
  7057. }, (rule, err) => {}, true);
  7058. storage.setItem("ruleLastUpdate", now);
  7059. }
  7060. callback();
  7061. });
  7062. });
  7063. }
  7064.  
  7065. let xhrFailed = false;
  7066. function requestDoc(url, callback) {
  7067. let postParams = url.match(/#p{(.*)}$/);
  7068. if (postParams) {
  7069. postParams = postParams[1];
  7070. url = url.replace(/#p{.*/, "");
  7071. }
  7072. let ruleHeaders = ruleParser.curSiteRule.headers;
  7073. let headers = {
  7074. 'Referer': location.href,
  7075. 'User-Agent': navigator.userAgent,
  7076. 'accept': 'text/html,application/xhtml+xml,application/xml',
  7077. "Content-Type": (postParams ? "application/x-www-form-urlencoded" : "text/html") + ";charset=" + charset,
  7078. };
  7079. if (ruleHeaders) {
  7080. if (ruleHeaders.referer) {
  7081. headers.referer = ruleHeaders.referer;
  7082. }
  7083. if (ruleHeaders.userAgent) {
  7084. headers.userAgent = ruleHeaders.userAgent;
  7085. }
  7086. if (ruleHeaders.accept) {
  7087. headers.accept = ruleHeaders.accept;
  7088. }
  7089. if (ruleHeaders.contentType) {
  7090. headers.contentType = ruleHeaders.contentType;
  7091. let ruleCharset = ruleHeaders.contentType.match(/charset\=([^;]+)/);
  7092. if (ruleCharset) charset = ruleCharset[1];
  7093. }
  7094. if (ruleHeaders.cookie) {
  7095. headers.cookie = ruleHeaders.cookie;
  7096. }
  7097. }
  7098. _GM_xmlhttpRequest({
  7099. url: url,
  7100. method: postParams ? 'POST' : 'GET',
  7101. data: postParams,
  7102. overrideMimeType: 'text/html;charset=' + charset,
  7103. headers: headers,
  7104. timeout: 50000,
  7105. onload: async function(res) {
  7106. if (isPause) return callback(false);
  7107. var doc = null, response = res.response;
  7108. try {
  7109. doc = document.implementation.createHTMLDocument('');
  7110. doc.documentElement.innerHTML = response;
  7111. } catch (e) {
  7112. debug('parse error:' + e.toString());
  7113. }
  7114. let pageElement = null;
  7115. let preCode = ruleParser.curSiteRule.pagePre;
  7116. if (preCode) {
  7117. try {
  7118. let preResult;
  7119. if (typeof preCode == 'function') {
  7120. preResult = await preCode(response, doc);
  7121. } else if (preCode.length == 2) {
  7122. preResult = response.replace(new RegExp(preCode[0], "gi"), preCode[1]);
  7123. } else {
  7124. preResult = await new AsyncFunction("response", "doc", '"use strict";' + preCode)(response, doc);
  7125. }
  7126. if (typeof preResult !== "undefined") {
  7127. if (typeof preResult === "string") {
  7128. doc.documentElement.innerHTML = preResult;
  7129. } else pageElement = preResult;
  7130. }
  7131. } catch(e) {
  7132. debug(e);
  7133. }
  7134. }
  7135. let base = doc.querySelector("base");
  7136. ruleParser.basePath = (base && base.href) || url;
  7137. if (charsetValid && !ruleHeaders) {
  7138. let equiv = doc.querySelector('[http-equiv="Content-Type"]');
  7139. if (equiv && equiv.content) {
  7140. let innerCharSet = equiv.content.match(/charset\=([^;]+)/);
  7141. if (innerCharSet && innerCharSet[1].replace("-", "").toLowerCase() != charset.replace("-", "").toLowerCase()) {
  7142. charset = innerCharSet[1];
  7143. return requestDoc(url, callback);
  7144. }
  7145. }
  7146. }
  7147. if (pageElement === null) {
  7148. pageElement = ruleParser.getPageElement(doc);
  7149. }
  7150. if ((!pageElement || pageElement.length == 0) && res.status >= 400) {
  7151. debug(res.status + " " + url, "Error status");
  7152. if (!ruleParser.curSiteRule.smart || !xhrFailed) {
  7153. xhrFailed = true;
  7154. return callback(false);
  7155. }
  7156. }
  7157. if (inCors && (!pageElement || pageElement.length == 0) && ruleParser.curSiteRule.smart) {
  7158. let article;
  7159. for (let i = 0; i < mainSel.length; i++) {
  7160. article = doc.querySelectorAll(mainSel[i]);
  7161. if (article && article.length === 1) break;
  7162. }
  7163. if (article && article.length == 1) {
  7164. article = article[0];
  7165. ruleParser.curSiteRule.pageElement = article.nodeName.toLowerCase() + (article.id ? "#" + article.id : "") + (article.className ? "." + article.className.replace(/ /g, ".") : "") + ">*";
  7166. pageElement = article.children;
  7167. } else {
  7168. ruleParser.curSiteRule.pageElement = allOfBody;
  7169. pageElement = ruleParser.getPageElement(doc);
  7170. }
  7171. ruleParser.getInsert(true);
  7172. }
  7173. //只有1的話怕不是圖片哦
  7174. if (pageElement && (pageElement.length > 1 || (pageElement.length == 1 && !compareNodeName(pageElement[0], ["img"])))) {
  7175. await ruleParser.insertPage(doc, pageElement, url, callback, false);
  7176. if (ruleParser.curSiteRule.action == 1) {
  7177. isLoading = true;
  7178. requestFromIframe(url, async (doc, eles) => {
  7179. if (eles) {
  7180. await ruleParser.insertPage(doc, eles, url, callback, true);
  7181. } else isLoading = false;
  7182. });
  7183. } else ruleParser.curSiteRule.action = 0;
  7184. } else if ((ruleParser.curSiteRule.smart || curPage == 1) && !inCors) {
  7185. ruleParser.curSiteRule.action = 1;
  7186. requestFromIframe(url, async (doc, eles) => {
  7187. if (eles) {
  7188. await ruleParser.insertPage(doc, eles, url, callback, true);
  7189. } else isLoading = false;
  7190. });
  7191. } else {
  7192. debug("Stop as no page element");
  7193. ruleParser.noValidContent(url);
  7194. changeStop(true);
  7195. callback(false);
  7196. }
  7197. },
  7198. onerror: function(e) {
  7199. debug(e, "NetError");
  7200. callback(false);
  7201. },
  7202. ontimeout: function(e) {
  7203. debug(e, "NetTimeout");
  7204. callback(false);
  7205. }
  7206. });
  7207. }
  7208.  
  7209. function initPage() {
  7210. ruleParser.initPage(() => {
  7211. if (ruleParser.curSiteRule.autoLoadNum) {
  7212. autoLoadNum = ruleParser.curSiteRule.autoLoadNum;
  7213. }
  7214. if (ruleParser.curSiteRule.nextLink && Array && Array.isArray && Array.isArray(ruleParser.curSiteRule.nextLink)) {
  7215. _GM_registerMenuCommand(i18n("nextSwitch"), () => {
  7216. nextSwitch.start();
  7217. });
  7218. }
  7219. if (ruleParser.nextLinkHref) {
  7220. let isJs = ruleParser.hrefIsJs(ruleParser.nextLinkHref);
  7221. if (!isJs) {
  7222. let inForce = (forceState == 2 || forceState == 3);
  7223. _GM_registerMenuCommand(i18n(inForce ? "cancelForceIframe" : "forceIframe"), () => {
  7224. if (inForce) {
  7225. setListData("forceState", location.host, "");
  7226. } else {
  7227. let _state = ruleParser.curSiteRule.action > 0 || confirm(i18n("forceAllBody")) ? 2 : 3;
  7228. setListData("forceState", location.host, _state);
  7229. }
  7230. setTimeout(() => {
  7231. location.reload();
  7232. }, 500);
  7233. });
  7234. }
  7235. _GM_registerMenuCommand(i18n("loadNow"), () => {
  7236. if (autoLoadNum != -1) {
  7237. autoLoadNum = -1;
  7238. return;
  7239. }
  7240. let loadNum = window.prompt(i18n("loadConfirm"), loadNowNum);
  7241. if (loadNum === "" || loadNum === null) return;
  7242. loadNum = Math.abs(parseInt(loadNum)) || 0;
  7243. if (loadNowNum != loadNum) {
  7244. loadNowNum = loadNum;
  7245. storage.setItem("loadNowNum", loadNowNum);
  7246. }
  7247. autoLoadNum = loadNum;
  7248. nextPage();
  7249. });
  7250. }
  7251. initListener();
  7252. });
  7253. }
  7254.  
  7255. var pageBarStyle, mainStyleEle, mainStyleStyle;
  7256. function initView() {
  7257. if (!mainStyleStyle) {
  7258. mainStyleStyle = `
  7259. .pagetual_pageBar{
  7260. -moz-transition:all 0.3s ease-in-out 0s;
  7261. -webkit-transition:all 0.3s ease-in-out 0s;
  7262. transition:all 0.3s ease-in-out 0s;
  7263. font-family: Arial,sans-serif !important;
  7264. text-align: center !important;
  7265. }
  7266. .pagetual_pageBar.stop {
  7267. -webkit-filter: invert(100%);
  7268. filter: invert(100%);
  7269. opacity: 1!important;
  7270. }
  7271. .pagetual_pageBar.hide {
  7272. display: none!important;
  7273. }
  7274. .pagetual-hide {
  7275. display: none!important;
  7276. }
  7277. .pagetual_pageBar:hover {
  7278. opacity: 1!important;
  7279. box-shadow: 0px 0px 10px 0px #000000aa;
  7280. border-radius: 20px;
  7281. background-color: rgb(240 240 240 / 80%);
  7282. border-color: transparent!important;
  7283. }
  7284. .pagetual_pageBar span {
  7285. vertical-align: super;
  7286. }
  7287. .pagetual_pageBar a::before,
  7288. .pagetual_pageBar a::after {
  7289. content: none;
  7290. }
  7291. .pagetual_pageBar a>span {
  7292. margin-top: 0!important;
  7293. pointer-events: none;
  7294. padding: unset;
  7295. opacity: 0;
  7296. -moz-transition:margin-top 0.3s ease-in-out 0s, opacity .3s;
  7297. -webkit-transition:margin-top 0.3s ease-in-out 0s, opacity .3s;
  7298. transition:margin-top 0.3s ease-in-out 0s, opacity .3s;
  7299. transform: none;
  7300. left: 0;
  7301. margin-left: calc(50% - 20px);
  7302. }
  7303. .pagetual_pageBar a>span:hover {
  7304. color: red;
  7305. }
  7306. .pagetual_pageBar a:hover>span {
  7307. opacity: 1!important;
  7308. }
  7309. .pagetual_pageBar span.prevScreen,
  7310. .pagetual_pageBar span.nextScreen {
  7311. display: block!important;
  7312. top: unset !important;
  7313. padding: unset !important;
  7314. opacity: 0!important;
  7315. }
  7316. .pagetual_pageBar a:hover>span.prevScreen {
  7317. margin-top: -${rulesData.opacity == 1 ? 31 : 30}px!important;
  7318. pointer-events: all;
  7319. }
  7320. .pagetual_pageBar span.refreshRing {
  7321. position: absolute;
  7322. top: 0;
  7323. opacity: 0;
  7324. height: 30px;
  7325. margin-left: calc(50% - 23px);
  7326. display: block!important;
  7327. }
  7328. .pagetual_pageBar span.refreshRing>svg {
  7329. background: white;
  7330. border-radius: 50%;
  7331. }
  7332. .pagetual_pageBar a:hover>span.refreshRing {
  7333. opacity: 0.3;
  7334. -webkit-animation: pagetual_ring 2.0s infinite linear;
  7335. animation: pagetual_ring 2.0s infinite linear;
  7336. }
  7337. @-webkit-keyframes pagetual_ring {
  7338. 0% { -webkit-transform: rotate(0deg) }
  7339. 100% {
  7340. -webkit-transform: rotate(360deg);
  7341. }
  7342. }
  7343. @keyframes pagetual_ring {
  7344. 0% {
  7345. transform: rotate(0deg);
  7346. -webkit-transform: rotate(0deg);
  7347. } 100% {
  7348. transform: rotate(360deg);
  7349. -webkit-transform: rotate(360deg);
  7350. }
  7351. }
  7352. .pagetual_pageBar a:hover>span.nextScreen {
  7353. margin-top: 30px!important;
  7354. pointer-events: all;
  7355. }
  7356. .pagetual_pageBar span>svg {
  7357. -moz-transition:transform 0.5s ease, opacity 0.3s ease;
  7358. -webkit-transition:transform 0.5s ease, opacity 0.3s ease;
  7359. transition:transform 0.5 ease, opacity 0.3s ease;
  7360. opacity: 0;
  7361. }
  7362. .pagetual_pageBar.stop span>svg{
  7363. opacity: 1;
  7364. }
  7365. .pagetual_pageBar.stop span>svg>path{
  7366. transform: scale(.8);
  7367. transform-origin: center;
  7368. -moz-transition:transform 0.3s ease;
  7369. -webkit-transition:transform 0.3s ease;
  7370. transition:transform 0.3 ease;
  7371. }
  7372. .pagetual_pageBar.stop:hover span>svg>path{
  7373. transform: unset;
  7374. }
  7375. .pagetual_pageBar:hover span>svg {
  7376. opacity: 1;
  7377. }
  7378. .pagetual_pageBar span>svg.upSvg:hover {
  7379. transform: rotate(360deg) scale3d(1.2, 1.2, 1.2);
  7380. }
  7381. .pagetual_pageBar span>svg.downSvg:hover {
  7382. transform: rotate(540deg) scale3d(1.2, 1.2, 1.2)!important;
  7383. }
  7384. .pagetual_pageBar .pagetual_pageNum{
  7385. color: #55555f;
  7386. }
  7387. .pagetual_pageBar .pagetual_pageNum:hover{
  7388. color: #ff6464;
  7389. }
  7390. .pagetual_tipsWords {
  7391. font-size: 50px;
  7392. font-weight: bold;
  7393. font-family: "黑体", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
  7394. "Oxygen", "Ubuntu", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji",
  7395. "Segoe UI Emoji", "Segoe UI Symbol";
  7396. color: #ffffff;
  7397. min-height: 70px;
  7398. max-width: 80%;
  7399. line-height: 1.5;
  7400. position: fixed;
  7401. left: 50%;
  7402. top: 10%;
  7403. margin-left: -99999px;
  7404. padding: 0 15px;
  7405. z-index: 2147483647;
  7406. background-color: #000;
  7407. border: 1px solid #303030;
  7408. border-radius: 10px;
  7409. opacity: 0;
  7410. filter: alpha(opacity=65);
  7411. box-shadow: 5px 5px 20px 0px #000;
  7412. -moz-transition:opacity 0.3s ease-in-out 0s;
  7413. -webkit-transition:opacity 0.3s ease-in-out 0s;
  7414. transition:opacity 0.3s ease-in-out 0s;
  7415. pointer-events: none;
  7416. word-break: break-all;
  7417. }
  7418. .pagetual_tipsWords>a {
  7419. color: #ffffff;
  7420. }
  7421. .pagetual_loading {
  7422. width: 50px;
  7423. height: 50px;
  7424. margin: 10px auto;
  7425. border-radius: 100%;
  7426. display: flex;
  7427. -webkit-animation: pagetual_loading_scaleout 1.0s infinite ease-in-out;
  7428. animation: pagetual_loading_scaleout 1.0s infinite ease-in-out;
  7429. }
  7430. @-webkit-keyframes pagetual_loading_scaleout {
  7431. 0% { -webkit-transform: scale(0.0) }
  7432. 100% {
  7433. -webkit-transform: scale(1.0);
  7434. opacity: 0;
  7435. }
  7436. }
  7437. @keyframes pagetual_loading_scaleout {
  7438. 0% {
  7439. transform: scale(0.0);
  7440. -webkit-transform: scale(0.0);
  7441. } 100% {
  7442. transform: scale(1.0);
  7443. -webkit-transform: scale(1.0);
  7444. opacity: 0;
  7445. }
  7446. }
  7447. .pagetual_loading_text {
  7448. white-space: nowrap;
  7449. -webkit-animation: pagetual_loading_opacity 2.6s infinite ease-in-out;
  7450. animation: pagetual_loading_opacity 2.6s infinite ease-in-out;
  7451. }
  7452. @-webkit-keyframes pagetual_loading_opacity {
  7453. 0% { opacity: 1 }
  7454. 50% { opacity: 0.2 }
  7455. 100% { opacity: 1 }
  7456. }
  7457. @keyframes pagetual_loading_opacity {
  7458. 0% { opacity: 1 }
  7459. 50% { opacity: 0.2 }
  7460. 100% { opacity: 1 }
  7461. }
  7462. `;
  7463. pageBarStyle = `overflow: visible;text-indent: initial;vertical-align: super;line-height:1;opacity:${rulesData.opacity};display:${rulesData.opacity == 0 ? "none" : "inline-flex"};padding:0;font-size: 30px;visibility: visible; position: relative; width: auto; max-width: 100vw; height: 30px; float: none; clear: both; margin: 5px auto; text-align: center;justify-content: center;box-sizing: content-box;${rulesData.opacity == 1 ? "border-top: 1px solid rgb(80, 80, 80);" : "box-shadow: 0px 0px 10px 0px #000000aa;border-radius: 20px;background-color: rgb(240 240 240 / 80%);"}`;
  7464. }
  7465. if (!mainStyleEle || !mainStyleEle.parentNode) {
  7466. mainStyleEle = _GM_addStyle(mainStyleStyle);
  7467. }
  7468. }
  7469. var loadingDiv = document.createElement("div");
  7470. if (loadingDiv.style) loadingDiv.style.cssText = "text-indent: initial;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;";
  7471.  
  7472. const loadingCSS = `font-size: initial; text-indent: unset; 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; flex: 0;`;
  7473. function setLoadingDiv(loadingText) {
  7474. loadingDiv.innerHTML = createHTML(`<p class="pagetual_loading_text" style="${loadingCSS}display: inline-block;width: 100%;">${loadingText}</p>${rulesData.hideLoadingIcon ? "" : `<div class="pagetual_loading"><svg width="50" height="50" style="position:relative;cursor: pointer;width: 50px;height: 50px;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><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" style="fill: #6e6e6e;" fill="#6e6e6e"></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" style="fill: #6e6e6e;" fill="#6e6e6e"></path></svg></div>`}`);
  7475. }
  7476.  
  7477. var upSvg = `<svg width="30" height="30" class="upSvg pagetual" style="display:initial;position:relative;cursor: pointer;margin: 0 8px;width: 30px;height: 30px;vertical-align: baseline;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><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" style="fill: #604b4a;" fill="#604b4a"></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" style="fill: #604b4a;" fill="#604b4a"></path></svg>`;
  7478. var upSvgCSS = `text-align: center;display: initial;position: relative;cursor: pointer;margin: 0 8px;width: 30px;height: 30px;vertical-align: baseline;fill: currentColor;overflow: hidden;`;
  7479. var downSvg = `<svg width="30" height="30" class="downSvg pagetual" style="display:initial;position:relative;cursor: pointer;margin: 0 8px;width: 30px;height: 30px;vertical-align: baseline;fill: currentColor;overflow: hidden;transform: rotate(180deg);" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><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" style="fill: #604b4a;" fill="#604b4a"></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" style="fill: #604b4a;" fill="#604b4a"></path></svg>`;
  7480. var downSvgCSS = `text-align: center;display: initial;position: relative;cursor: pointer;margin: 0 8px;width: 30px;height: 30px;vertical-align: baseline;fill: currentColor;overflow: hidden;transform: rotate(180deg);`;
  7481.  
  7482. const initStyle = `text-indent: initial;display: contents;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 5px;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: relative;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;`;
  7483. const pageTextStyle = `opacity: 1!important;text-indent: initial;padding: unset;border: none;background: unset!important;line-height: 30px;text-decoration: none;user-select: none;visibility: visible;position: initial;width: auto;max-width: 80%; white-space: nowrap; text-overflow: ellipsis;overflow: hidden;height: auto;float: none;clear: both;margin: 0px;text-align: center;display: inline-block;font-weight: bold;font-style: normal;font-size: 16px;letter-spacing: initial;vertical-align: top;color: rgb(85, 85, 95)!important;`;
  7484. var sideControllerIcon = '';
  7485.  
  7486. var tipsWords = document.createElement("div");
  7487. tipsWords.className = "pagetual_tipsWords";
  7488.  
  7489. function changeStop(stop, save) {
  7490. isPause = stop;
  7491. [].forEach.call(getBody(document).querySelectorAll(".pagetual_pageBar,#pagetual-sideController"), bar => {
  7492. if (isPause) {
  7493. bar.classList.add("stop");
  7494. } else {
  7495. bar.classList.remove("stop");
  7496. }
  7497. });
  7498. if (!isPause) ruleParser.showAddedElements();
  7499. manualPause = isPause;
  7500. if (save && sideController.inited) setListData("pauseState", location.host, isPause ? true : "");
  7501. }
  7502.  
  7503. function changeHideBar(hide) {
  7504. isHideBar = hide;
  7505. [].forEach.call(getBody(document).querySelectorAll(".pagetual_pageBar"), bar => {
  7506. if (isHideBar) {
  7507. bar.classList.add("hide");
  7508. } else {
  7509. bar.classList.remove("hide");
  7510. }
  7511. });
  7512. }
  7513.  
  7514. function isInViewPort(element) {
  7515. const viewWidth = window.innerWidth || document.documentElement.clientWidth;
  7516. const viewHeight = window.innerHeight || document.documentElement.clientHeight;
  7517. const {
  7518. top,
  7519. right,
  7520. bottom,
  7521. left,
  7522. } = element.getBoundingClientRect();
  7523.  
  7524. return (
  7525. top >= 0 &&
  7526. left >= 0 &&
  7527. right <= viewWidth + 1 &&
  7528. top <= viewHeight * rate &&
  7529. isVisible(element, _unsafeWindow)
  7530. );
  7531. }
  7532.  
  7533. function getPageBar() {
  7534. let preBar = null, nextBar = null;
  7535. let pageBars = [].slice.call(document.querySelectorAll(".pagetual_pageBar"));
  7536. for (let i = 0; i < pageBars.length; i++) {
  7537. let pageBar = pageBars[i];
  7538. if (!pageBar || !getBody(document).contains(pageBar)) continue;
  7539. let {
  7540. top,
  7541. right,
  7542. bottom,
  7543. left,
  7544. } = pageBar.getBoundingClientRect();
  7545. if (top > 500) {
  7546. nextBar = pageBar;
  7547. preBar = (i - 1 >= 0 ? pageBars[i - 1] : null);
  7548. if (pageBar && getBody(document).contains(pageBar)) {
  7549. let {
  7550. top,
  7551. right,
  7552. bottom,
  7553. left,
  7554. } = pageBar.getBoundingClientRect();
  7555. if (top < -500) {
  7556. preBar = pageBar;
  7557. } else preBar = (i - 2 >= 0 ? pageBars[i - 2] : null);
  7558. }
  7559. break;
  7560. }
  7561. }
  7562. if (!nextBar) preBar = pageBars[pageBars.length - 2];
  7563. return {preBar: preBar, nextBar: nextBar};
  7564. }
  7565.  
  7566. var urlChanged = false;
  7567. var urlChanging = false;
  7568. var urlchangeHandler = e => {
  7569. if (ruleParser && ruleParser.curSiteRule && ruleParser.curSiteRule.listenUrlChange == false) return;
  7570. isPause = true;
  7571. setTimeout(() => {
  7572. lastActiveUrl = location.href;
  7573. if (urlChanging) return;
  7574. urlChanging = true;
  7575. let href = location.href.slice(0, 60);
  7576. if (href == configPage[1]) {
  7577. setTimeout(() => {
  7578. initConfig(href);
  7579. urlChanging = false;
  7580. }, 1000);
  7581. } else {
  7582. setTimeout(() => {
  7583. if (guidePage.test(href)) {
  7584. setTimeout(() => {
  7585. initConfig(href);
  7586. urlChanging = false;
  7587. }, 1000);
  7588. } else {
  7589. ruleParser.urlChanged();
  7590. if (!ruleParser.nextLinkHref) {
  7591. isLoading = false;
  7592. }
  7593. urlChanging = false;
  7594. //if (!pageReady && !ruleImportUrlReg.test(href)) location.reload();
  7595. }
  7596. }, 500);
  7597. }
  7598. }, 1);
  7599. };
  7600. window.addEventListener('pagetual_pushState', urlchangeHandler);
  7601. /*var _wr = function(type) {
  7602. var orig = history[type];
  7603. return function() {
  7604. var rv = orig.apply(this, arguments);
  7605. var e = new Event('pagetual_' + type);
  7606. e.arguments = arguments;
  7607. window.dispatchEvent(e);
  7608. return rv;
  7609. };
  7610. };
  7611. history.pushState = _wr('pushState');*/
  7612.  
  7613. function listenUrl() {
  7614. var prevPathname = window.location.pathname;
  7615. var prevSearch = window.location.search;
  7616. var checkUrlTime = 100;
  7617. var checkUrlTimer;
  7618. var checkClickedEle = null;
  7619. var checkFunc = () => {
  7620. if (forceState == 1) return;
  7621. if (checkClickedEle) {
  7622. if (!clickedSth && checkClickedEle && checkClickedEle.nodeName) {
  7623. if (compareNodeName(checkClickedEle, ["a", "button"])) {
  7624. clickedSth = true;
  7625. } else {
  7626. let targetStyle = _unsafeWindow.getComputedStyle(checkClickedEle);
  7627. if (targetStyle.cursor == "pointer") clickedSth = true;
  7628. }
  7629. }
  7630. checkClickedEle = null;
  7631. }
  7632. if (checkUrlTime < 5000) {
  7633. checkUrlTime += checkUrlTime>>1;
  7634. }
  7635. clearTimeout(checkUrlTimer);
  7636. checkUrlTimer = setTimeout(checkFunc, checkUrlTime);
  7637. if (document.hidden) return;
  7638. if (!ruleParser.canListenUrlChange()) {
  7639. return;
  7640. }
  7641. if ((prevPathname !== window.location.pathname || prevSearch !== window.location.search) && window.location.href != ruleParser.historyUrl) {
  7642. checkUrlTime = 2000;
  7643. urlWillChange = true;
  7644. var e = new Event('pagetual_pushState');
  7645. e.arguments = arguments;
  7646. window.dispatchEvent(e);
  7647. clickedSth = false;
  7648. }
  7649. prevPathname = window.location.pathname;
  7650. prevSearch = window.location.search;
  7651. };
  7652. checkUrlTimer = setTimeout(checkFunc, checkUrlTime);
  7653.  
  7654. document.addEventListener("click", e => {
  7655. if (!checkClickedEle) {
  7656. checkClickedEle = e.target;
  7657. checkUrlTime = 300;
  7658. clearTimeout(checkUrlTimer);
  7659. checkUrlTimer = setTimeout(checkFunc, checkUrlTime);
  7660. }
  7661. });
  7662. }
  7663.  
  7664. let scrollContainer;
  7665. function distToBottom () {
  7666. let scrolly = window.scrollY;
  7667. let windowHeight = window.innerHeight || document.documentElement.clientHeight;
  7668. if (!scrollContainer || !document.documentElement.contains(scrollContainer)) {
  7669. if (curPage > 1 || ruleParser.nextLinkHref) {
  7670. let pageEle = ruleParser.getPageElement(document);
  7671. if (pageEle && pageEle.length) {
  7672. let parent = pageEle[0].parentNode, pageScrollY = parent.scrollTop;
  7673. while (parent && pageScrollY == 0) {
  7674. parent = parent.parentNode;
  7675. pageScrollY = parent.scrollTop;
  7676. }
  7677. if (pageScrollY) {
  7678. scrollContainer = parent;
  7679. return scrollContainer.scrollHeight - pageScrollY - windowHeight;
  7680. }
  7681. }
  7682. }
  7683. }
  7684. if (scrollContainer) {
  7685. return scrollContainer.scrollHeight - scrollContainer.scrollTop - windowHeight;
  7686. }
  7687.  
  7688. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  7689. return scrollH - scrolly - windowHeight;
  7690. }
  7691.  
  7692. let scrollHandler, clickToResetHandler, dblclickHandler, keydownHandler, hashchangeHandler, manualModeKeyHandler, pagetualNextHandler, keyupHandler, messageHandler;
  7693. function initListener () {
  7694. document.removeEventListener('scroll', scrollHandler, true);
  7695. document.removeEventListener('wheel', scrollHandler, true);
  7696. document.removeEventListener('dblclick', dblclickHandler);
  7697. document.removeEventListener('keydown', keydownHandler);
  7698. window.removeEventListener('hashchange', hashchangeHandler, false);
  7699. document.removeEventListener('keydown', manualModeKeyHandler);
  7700. document.removeEventListener('pagetual.next', pagetualNextHandler, false);
  7701. document.removeEventListener('keyup', keyupHandler);
  7702. _unsafeWindow.removeEventListener('message', messageHandler, true);
  7703. let loadmoreBtn, loadingMore = true, lastScroll = 0, checkLoadMoreTimes = 0, loadMoreInv;
  7704. if (ruleParser.curSiteRule.smart) {
  7705. loadingMore = false;
  7706. } else if (ruleParser.curSiteRule.loadMore) {
  7707. loadingMore = false;
  7708. }
  7709. clickMode = typeof ruleParser.curSiteRule.clickMode == 'undefined' ? rulesData.clickMode : ruleParser.curSiteRule.clickMode;
  7710. let clickingNext = false;
  7711. let clickNext = async () => {
  7712. if (clickingNext) return;
  7713. clickingNext = true;
  7714. setTimeout(() => {
  7715. clickingNext = false;
  7716. }, 1500);
  7717. let nextLink = ruleParser.nextLinkHref;
  7718. if (!nextLink) return;
  7719. let isJs = ruleParser.hrefIsJs(nextLink);
  7720. if (isJs) {
  7721. let nextBtn = ruleParser.nextLinkEle;
  7722. if (!nextBtn || !nextBtn.offsetParent) nextBtn = await ruleParser.getNextLink(document, true);
  7723. if (nextBtn) emuClick(nextBtn);
  7724. } else {
  7725. window.location.href = nextLink;
  7726. }
  7727. };
  7728. let checkScrollReach = () => {
  7729. let dist = distToBottom();
  7730. if (clickMode) {
  7731. if (dist < 10) {
  7732. clickNext();
  7733. }
  7734. } else if (dist < bottomGap) {
  7735. nextPage();
  7736. }
  7737. };
  7738. messageHandler = e => {
  7739. if (e.data.command === 'pagetual') {
  7740. let action = e.data.action;
  7741. let detail = e.data.detail;
  7742. switch (action) {
  7743. case "config":
  7744. if (!detail || typeof detail !== 'object') return;
  7745. rulesData = {
  7746. ...rulesData,
  7747. ...detail
  7748. }
  7749. storage.setItem("rulesData", rulesData);
  7750. break;
  7751. case "nextPage":
  7752. if (detail === "" || detail === null) return;
  7753. detail = parseInt(detail) || 0;
  7754. if (loadNowNum != detail) {
  7755. loadNowNum = detail;
  7756. }
  7757. autoLoadNum = detail;
  7758. nextPage();
  7759. break;
  7760. case "loadMore":
  7761. clearInterval(loadMoreInv);
  7762. if (detail === -1) return;
  7763. loadmoreBtn = getLoadMore(document, loadmoreBtn);
  7764. loadmoreBtn && emuClick(loadmoreBtn);
  7765. if (detail === 0) {
  7766. loadMoreInv = setInterval(() => {
  7767. loadmoreBtn = getLoadMore(document, loadmoreBtn);
  7768. loadmoreBtn && emuClick(loadmoreBtn);
  7769. }, 500);
  7770. }
  7771. break;
  7772. }
  7773. }
  7774. return true;
  7775. }
  7776. _unsafeWindow.addEventListener('message', messageHandler, true);
  7777. scrollHandler = e => {
  7778. if (urlChanged && !isLoading) {
  7779. ruleParser.initPage(() => {});
  7780. urlChanged = false;
  7781. loadingMore = false;
  7782. return;
  7783. }
  7784. if (isPause) return;
  7785. if (!loadingMore) {
  7786. loadmoreBtn = getLoadMore(document, loadmoreBtn);
  7787. if (loadmoreBtn) {
  7788. if (isInViewPort(loadmoreBtn)) {
  7789. emuClick(loadmoreBtn);
  7790. loadingMore = true;
  7791. setTimeout(() => {loadingMore = false}, 200);
  7792. }
  7793. } else {
  7794. loadingMore = true;
  7795. if (!ruleParser.curSiteRule.smart || checkLoadMoreTimes++ < 3) {
  7796. setTimeout(() => {loadingMore = false}, 200);
  7797. }
  7798. }
  7799. }
  7800. if (!isLoading && !stopScroll) {
  7801. checkScrollReach();
  7802. }
  7803. ruleParser.changeVisibility();
  7804. let curScroll = getBody(document).scrollTop || document.documentElement.scrollTop;
  7805. if (ruleParser.curSiteRule.lockScroll) {
  7806. if (isLoading && Math.abs(lastScroll - curScroll) > 350) {
  7807. getBody(document).scrollTop = lastScroll;
  7808. document.documentElement.scrollTop = lastScroll;
  7809. } else {
  7810. lastScroll = curScroll;
  7811. }
  7812. }
  7813. if (targetY >= 0) {
  7814. if (Math.abs(targetY - curScroll) < 100) {
  7815. targetY = -1;
  7816. }
  7817. }
  7818. if (curScroll <= 20 && curScroll > 0) {
  7819. if (sideController.inited) {
  7820. sideController.pagenum.innerHTML = createHTML("1");
  7821. }
  7822. }
  7823. };
  7824. dblclickHandler = e => {
  7825. if (forceState == 1 || compareNodeName(e.target, ["input", "textarea", "select", "a", "button", "svg", "use", "img", "path"])) return;
  7826. if (!rulesData.dbClick2StopKey) {
  7827. if ((rulesData.dbClick2StopCtrl && !e.ctrlKey) ||
  7828. (rulesData.dbClick2StopAlt && !e.altKey) ||
  7829. (rulesData.dbClick2StopShift && !e.shiftKey) ||
  7830. (rulesData.dbClick2StopMeta && !e.metaKey)) {
  7831. return;
  7832. }
  7833. }
  7834. if (!compareNodeName(e.target, ["body"]) && !e.target.classList.contains('pagetual_pageBar')) {
  7835. try {
  7836. let selection = window.getSelection();
  7837. let selStr = selection.toString().trim();
  7838. if (!selStr) {
  7839. selection = selection.getRangeAt(0);
  7840. selStr = selection && selection.cloneContents().children[0];
  7841. if (selStr && !compareNodeName(selStr, ["img"])) selStr = false;
  7842. }
  7843. if (selStr) {
  7844. return;
  7845. }
  7846. } catch (e) {}
  7847. }
  7848. if (rulesData.dbClick2Stop && (ruleParser.nextLinkHref || loadmoreBtn)) {
  7849. setTimeout(() => {
  7850. if (rulesData.hideBarButNoStop || rulesData.hideBar) {
  7851. changeHideBar(!isHideBar);
  7852. }
  7853. if (!rulesData.hideBarButNoStop) {
  7854. changeStop(!isPause);
  7855. showTips(i18n(isPause ? "disable" : "enable"));
  7856. }
  7857. if (!isPause) {
  7858. checkScrollReach();
  7859. }
  7860. }, 10);
  7861. }
  7862. };
  7863. document.addEventListener('dblclick', dblclickHandler);
  7864. clickToResetHandler = e => {
  7865. if (!ruleParser.nextLinkHref) isLoading = false;
  7866. };
  7867. document.addEventListener('click', clickToResetHandler);
  7868. if (rulesData.dbClick2StopKey) {
  7869. keydownHandler = e => {
  7870. if ((rulesData.dbClick2StopCtrl && !e.ctrlKey) ||
  7871. (rulesData.dbClick2StopAlt && !e.altKey) ||
  7872. (rulesData.dbClick2StopShift && !e.shiftKey) ||
  7873. (rulesData.dbClick2StopMeta && !e.metaKey)) {
  7874. return;
  7875. }
  7876. if (document.activeElement &&
  7877. (compareNodeName(document.activeElement, ["input", "textarea"]) ||
  7878. document.activeElement.contentEditable == 'true')) {
  7879. return;
  7880. }
  7881. var key = e.key.toLowerCase();
  7882. if (rulesData.dbClick2StopKey.toLowerCase() == key) {
  7883. if (forceState == 1) {
  7884. forceState = 0;
  7885. showTips(i18n("enableSiteTips"));
  7886. changeStop(false, true);
  7887. } else {
  7888. forceState = 1;
  7889. showTips(i18n("disableSiteTips"));
  7890. changeStop(true, true);
  7891. sideController.remove();
  7892. }
  7893. if (!ruleParser.curSiteRule.url) {
  7894. setListData("forceState", location.host, forceState);
  7895. setTimeout(() => {
  7896. location.reload();
  7897. }, 500);
  7898. }
  7899. }
  7900. };
  7901. document.addEventListener('keydown', keydownHandler);
  7902. }
  7903. if (ruleParser.curSiteRule.listenHashChange) {
  7904. hashchangeHandler = () => {
  7905. isPause = true;
  7906. ruleParser.urlChanged();
  7907. if (!ruleParser.nextLinkHref) isLoading = false;
  7908. };
  7909. window.addEventListener('hashchange', hashchangeHandler, false);
  7910. }
  7911. let manualMode = typeof ruleParser.curSiteRule.manualMode == 'undefined' ? rulesData.manualMode : ruleParser.curSiteRule.manualMode;
  7912. if (manualMode) {
  7913. manualModeKeyHandler = e => {
  7914. if (document.activeElement &&
  7915. (compareNodeName(document.activeElement, ["input", "textarea"]) ||
  7916. document.activeElement.contentEditable == 'true')) {
  7917. return;
  7918. }
  7919. if (e.keyCode == 39) {
  7920. clickNext();
  7921. } else if (e.keyCode == 37) {
  7922. history.back();
  7923. }
  7924. };
  7925. document.addEventListener('keydown', manualModeKeyHandler);
  7926. pagetualNextHandler = () => {
  7927. clickNext();
  7928. };
  7929. document.addEventListener('pagetual.next', pagetualNextHandler, false);
  7930. return;
  7931. }
  7932. if (rulesData.arrowToScroll) {
  7933. keyupHandler = e => {
  7934. if (document.activeElement &&
  7935. (compareNodeName(document.activeElement, ["input", "textarea"]) ||
  7936. document.activeElement.contentEditable == 'true')) {
  7937. return;
  7938. }
  7939. if (e.keyCode == 39) {
  7940. let nextPageBar=getPageBar().nextBar;
  7941. if (nextPageBar) {
  7942. scrollToPageBar(nextPageBar);
  7943. } else {
  7944. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  7945. window.scrollTo({ top: scrollTop + (window.innerHeight || document.documentElement.clientHeight), behavior: 'instant'});
  7946. }
  7947. } else if (e.keyCode == 37) {
  7948. let prePageBar = getPageBar().preBar;
  7949. if (prePageBar) {
  7950. scrollToPageBar(prePageBar);
  7951. } else {
  7952. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  7953. window.scrollTo({ top: scrollTop - (window.innerHeight || document.documentElement.clientHeight), behavior: 'instant'});
  7954. }
  7955. }
  7956. };
  7957. document.addEventListener('keyup', keyupHandler);
  7958. }
  7959. if (!ruleParser.curSiteRule.wheel) {
  7960. document.addEventListener('scroll', scrollHandler, true);
  7961. }
  7962. document.addEventListener('wheel', scrollHandler, true);
  7963. }
  7964.  
  7965. let hideTipsTimeout;
  7966. function showTips(content, href, time, wordColor, backColor) {
  7967. initView();
  7968. document.documentElement.appendChild(tipsWords);
  7969. tipsWords.style.color = wordColor || 0xFFFFFF;
  7970. tipsWords.style.backgroundColor = backColor || 0x000;
  7971. let _time = 1500;
  7972. if (href) {
  7973. _time = 3500;
  7974. tipsWords.innerHTML = createHTML(`<a href='${href}' target='_blank'>${content}</a>`);
  7975. tipsWords.style.pointerEvents = 'all';
  7976. } else {
  7977. tipsWords.innerHTML = createHTML(content);
  7978. }
  7979. tipsWords.style.marginLeft = -tipsWords.offsetWidth / 2 + "px";
  7980. setTimeout(() => {
  7981. tipsWords.style.marginLeft = -tipsWords.offsetWidth / 2 + "px";
  7982. }, 0);
  7983. setTimeout(() => {
  7984. tipsWords.style.opacity = 0.8;
  7985. clearTimeout(hideTipsTimeout);
  7986. hideTipsTimeout = setTimeout(() => {
  7987. tipsWords.style.opacity = 0;
  7988. tipsWords.style.pointerEvents = '';
  7989. }, time || _time);
  7990. }, 1);
  7991. }
  7992.  
  7993. const loadmoreReg = /^\s*((点击)?加载更多|(點擊)?加載更多|load\s*more( comments)?|もっと読み込む)[\.…▼\s]*$/i;
  7994. const defaultLoadmoreSel = ".loadMore,.LoadMore,[class*='load-more'],button.show_more,.button-show-more,button[data-testid='more-results-button'],#btn_preview_remain,.view-more-btn";
  7995. function getLoadMore(doc, loadmoreBtn) {
  7996. if (!loadmoreBtn || !getBody(doc).contains(loadmoreBtn) || /less/.test(loadmoreBtn.innerText)) loadmoreBtn = null;
  7997. if (!ruleParser.curSiteRule.smart && !ruleParser.curSiteRule.loadMore) return null;
  7998. if (loadmoreBtn) return loadmoreBtn;
  7999. let btnSel = ruleParser.curSiteRule.loadMore || defaultLoadmoreSel;
  8000. if (btnSel) {
  8001. loadmoreBtn = getElement(btnSel, doc, null, true);
  8002. }
  8003. if (!loadmoreBtn) {
  8004. let buttons = getBody(doc).querySelectorAll("input,button,a,div[onclick]");
  8005. for (let i = 0; i < buttons.length; i++) {
  8006. let button = buttons[i];
  8007. if (!button.innerText || button.innerText.length > 20) continue;
  8008. if (button && loadmoreReg.test(button.innerText)) {
  8009. loadmoreBtn = button;
  8010. break;
  8011. }
  8012. }
  8013. }
  8014. if (loadmoreBtn && !ruleParser.curSiteRule.loadMore && loadmoreBtn.dataset.ajax !== "true") {
  8015. let href = loadmoreBtn.getAttribute("href");
  8016. if (href && href != "/" && !ruleParser.hrefIsJs(href)) {
  8017. loadmoreBtn = null;
  8018. }
  8019. }
  8020. if (loadmoreBtn && /less/.test(loadmoreBtn.innerText)) loadmoreBtn = null;
  8021. if (loadmoreBtn) debug(loadmoreBtn, 'Load more button');
  8022. return loadmoreBtn;
  8023. }
  8024.  
  8025. var targetY = -1;
  8026. function scrollToPageBar(bar) {
  8027. if (window.pageYOffset == 0) {
  8028. bar.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" });
  8029. } else {
  8030. let yOffset = -20;
  8031. if (typeof ruleParser.curSiteRule.pageBarTop !== 'undefined') {
  8032. yOffset = -ruleParser.curSiteRule.pageBarTop;
  8033. }
  8034. targetY = bar.getBoundingClientRect().top + window.pageYOffset + yOffset;
  8035. window.scrollTo({ top: targetY, behavior: 'smooth'});
  8036. }
  8037. }
  8038.  
  8039. const pageNumReg=/[&\/\?](p=|page[=\/_-]?)\d+|[_-]\d+\./;
  8040. function createPageBar(url) {
  8041. curPage++;
  8042. sideController.setup();
  8043. let posEle = null;
  8044. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  8045. let insert = ruleParser.getInsert();
  8046. if (!insert || !insert.parentNode) return;
  8047. if (forceState == 2) {
  8048. posEle = getBody(document);
  8049. posEle = posEle.children[posEle.children.length - 1];
  8050. } else {
  8051. posEle = insert;
  8052. }
  8053. while (posEle && !posEle.offsetParent) {
  8054. posEle = posEle.previousElementSibling || posEle.parentNode;
  8055. }
  8056. if (posEle) {
  8057. let actualBottom = getElementBottom(posEle);
  8058. bottomGap = scrollH - actualBottom + (window.innerHeight || document.documentElement.clientHeight) * rate;
  8059. if (bottomGap < 100) bottomGap = 100;
  8060. } else {
  8061. bottomGap = 1000;
  8062. }
  8063. if (hidePageBar) return null;
  8064. url = url.replace(/#p{.*/, "");
  8065. let example = (ruleParser.curSiteRule.insertPos == 2 || ruleParser.curSiteRule.insertPos == "in") ? insert.children[0] : (insert.parentNode.children[0] || insert);
  8066. while (example && (compareNodeName(example, ["script", "style"]) || example.className == "pagetual_pageBar")) {
  8067. example = example.nextElementSibling;
  8068. }
  8069. if (!example || !example.parentNode) example = insert;
  8070. if (example.nodeType != 1) {
  8071. example = example.previousElementSibling || example.parentNode;
  8072. if (!example || example.nodeType != 1) return;
  8073. }
  8074. let exampleStyle = _unsafeWindow.getComputedStyle(example);
  8075. let inTable, inLi;
  8076. if (forceState == 2) {
  8077. inTable = inLi = false;
  8078. } else {
  8079. inTable = compareNodeName(example.parentNode, ["table", "tbody"]) ||
  8080. compareNodeName(example, ["tr", "tbody"]) ||
  8081. exampleStyle.display == "table-row" ||
  8082. (example.nextElementSibling && compareNodeName(example.nextElementSibling, ["tr", "tbody"]));
  8083. inLi = compareNodeName(example, ["li"]) || (example.nextElementSibling && compareNodeName(example.nextElementSibling, ["li"]));
  8084. }
  8085. let pageBar = document.createElement(inTable ? "tr" : (inLi ? "li" : "div"));
  8086. let upSpan = document.createElement("span");
  8087. let downSpan = document.createElement("span");
  8088. let pageText = document.createElement("a");
  8089. let pageNum;
  8090. pageBar.className = isHideBar ? "pagetual_pageBar hide" : "pagetual_pageBar";
  8091. pageBar.id = "pagetual_pageBar" + curPage;
  8092. pageBar.setAttribute("translate", "no");
  8093. if (isPause) {
  8094. pageBar.classList.add("stop");
  8095. }
  8096. pageBar.style.cssText = pageBarStyle;
  8097. pageBar.title = i18n(isPause ? "enable" : "disable");
  8098. upSpan.innerHTML = createHTML(upSvg);
  8099. upSpan.children[0].style.cssText = upSvgCSS;
  8100. upSpan.title = i18n("toTop");
  8101. downSpan.innerHTML = createHTML(downSvg);
  8102. downSpan.children[0].style.cssText = downSvgCSS;
  8103. downSpan.title = i18n("toBottom");
  8104. upSpan.style.cssText = initStyle;
  8105. downSpan.style.cssText = initStyle;
  8106. pageText.href = url;
  8107. pageText.style.cssText = pageTextStyle;
  8108. pageText.title = i18n("current");
  8109. if (openInNewTab == 1) pageText.target = "_blank";
  8110. pageBar.appendChild(upSpan);
  8111. pageBar.appendChild(pageText);
  8112. let touched = false;
  8113. let touchBodyHandler = e => {
  8114. touched = false;
  8115. getBody(document).removeEventListener('touchstart', touchBodyHandler, { passive: false, capture: false });
  8116. };
  8117. pageText.addEventListener("touchstart", e => {
  8118. if (touched) return;
  8119. touched = true;
  8120. pageText.style.pointerEvents = 'none';
  8121. setTimeout(() => {
  8122. pageText.style.pointerEvents = 'all';
  8123. }, 250);
  8124. getBody(document).addEventListener("touchstart", touchBodyHandler, { passive: false, capture: false });
  8125. }, { passive: false, capture: false });
  8126. if (ruleParser.nextTitle) {
  8127. pageText.innerHTML = createHTML(ruleParser.nextTitle + " ");
  8128. pageText.title = ruleParser.nextTitle;
  8129. }
  8130. if (ruleParser.curSiteRule.pageNum || pageNumReg.test(url)) {
  8131. pageText.innerHTML = createHTML(pageText.innerHTML + i18n("page"));
  8132. pageNum = document.createElement("span");
  8133. let num = ruleParser.getPageNumFromUrl(url, curPage);
  8134. pageNum.innerHTML = createHTML(num + "<i style='font-size: 0;'>&nbsp;</i>");
  8135. pageNum.className = "pagetual_pageNum";
  8136. pageNum.title = i18n("inputPageNum");
  8137. pageNum.style.cssText = pageTextStyle;
  8138. pageNum.style.cursor = "pointer";
  8139. pageNum.style.color = "";
  8140. pageNum.style.marginLeft = "5px";
  8141. pageNum.addEventListener("click", e => {
  8142. let pageInput = prompt(i18n("inputPageNum"), num || "1");
  8143. if (pageInput) {
  8144. let localPageBar = document.querySelector("#pagetual_pageBar" + pageInput);
  8145. if (localPageBar) {
  8146. scrollToPageBar(localPageBar);
  8147. } else {
  8148. let pageLink = ruleParser.getLinkByPage(url, pageInput);
  8149. if (pageLink) {
  8150. _GM_openInTab(pageLink, {active:true});
  8151. }
  8152. }
  8153. }
  8154. e.preventDefault();
  8155. e.stopPropagation();
  8156. });
  8157. pageBar.appendChild(pageNum);
  8158. } else {
  8159. pageText.innerHTML = createHTML(pageText.innerHTML + i18n("page") + curPage + "<i style='font-size: 0;'>&nbsp;</i>");
  8160. }
  8161. let preBtn = document.createElement("span");
  8162. preBtn.innerHTML = createHTML("∧");
  8163. preBtn.title = i18n("prevPage");
  8164. preBtn.className = "prevScreen";
  8165. preBtn.style.cssText = "display: none;text-align: center;right: unset; float: left; width: 40px; background: rgba(240, 240, 240, 0.8); position: absolute; z-index: 9999999; box-shadow: rgb(0 0 0 / 50%) 0px -5px 5px; border-radius: 20px 20px 0 0; margin-top: -30px; ";
  8166. let nextBtn = document.createElement("span");
  8167. nextBtn.innerHTML = createHTML("∨");
  8168. nextBtn.title = i18n("nextPage");
  8169. nextBtn.className = "nextScreen";
  8170. nextBtn.style.cssText = "display: none;text-align: center;right: unset; float: left; width: 40px; background: rgba(240, 240, 240, 0.8); position: absolute; z-index: 9999999; box-shadow: rgb(0 0 0 / 50%) 0px 5px 5px; border-radius: 0 0 20px 20px; margin-top: 30px; ";
  8171. let localPage = curPage;
  8172. preBtn.addEventListener("click", e => {
  8173. e.stopPropagation();
  8174. e.preventDefault();
  8175. let prePageBar = document.querySelector("#pagetual_pageBar" + (localPage - 1));
  8176. if (prePageBar) {
  8177. scrollToPageBar(prePageBar);
  8178. } else {
  8179. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  8180. targetY = scrollTop - (window.innerHeight || document.documentElement.clientHeight);
  8181. window.scrollTo({ top: targetY, behavior: 'smooth'});
  8182. }
  8183. });
  8184. nextBtn.addEventListener("click", e => {
  8185. e.stopPropagation();
  8186. e.preventDefault();
  8187. let nextPageBar = document.querySelector("#pagetual_pageBar" + (localPage + 1));
  8188. if (nextPageBar) {
  8189. scrollToPageBar(nextPageBar);
  8190. } else {
  8191. scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  8192. targetY = scrollH || 9999999;
  8193. window.scrollTo({ top: targetY, behavior: 'smooth'});
  8194. }
  8195. });
  8196. if (!rulesData.hideBarArrow) {
  8197. pageText.insertBefore(preBtn, pageText.firstChild);
  8198. pageText.insertBefore(nextBtn, pageText.firstChild);
  8199. }
  8200. if (curForceIframe) {
  8201. let bgRing = document.createElement("span");
  8202. bgRing.className = "refreshRing";
  8203. bgRing.style.display = "none";
  8204. bgRing.innerHTML = createHTML(upSvg);
  8205. pageText.title = "Refresh";
  8206. pageText.appendChild(bgRing);
  8207. pageText.addEventListener("click", e => {
  8208. e.stopPropagation();
  8209. if (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) return;
  8210. e.preventDefault();
  8211. let nextEle = pageBar && pageBar.nextElementSibling;
  8212. if (nextEle && nextEle.name == 'pagetual-iframe') {
  8213. if (curForceIframe == nextEle) {
  8214. nextEle.setAttribute("loaded", "refresh");
  8215. }
  8216. nextEle.src = nextEle.src;
  8217. }
  8218. });
  8219. } else if (rulesData.pageBarMenu) {
  8220. pageText.addEventListener("click", e => {
  8221. e.stopPropagation();
  8222. if (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) return;
  8223. e.preventDefault();
  8224. picker.start();
  8225. });
  8226. }
  8227. pageBar.appendChild(downSpan);
  8228. if (forceState == 2) {
  8229. pageBar.style.width = "99%";
  8230. } else {
  8231. let parentStyle = _unsafeWindow.getComputedStyle(example.parentNode);
  8232. let parentWidth = example.parentNode.offsetWidth || parseInt(parentStyle.width);
  8233. pageBar.style.width = parentWidth - parseInt(parentStyle.paddingLeft) - parseInt(parentStyle.paddingRight) - 10 + "px";
  8234. pageBar.style.margin = '10px 5px';
  8235. if (parentStyle.display == "grid" || parentStyle.display == "inline-grid") {
  8236. pageBar.style.gridColumn = "1/-1";
  8237. }
  8238. if (inTable) {
  8239. example = compareNodeName(example, ["tr", "tbody"]) ? example : example.nextElementSibling || example;
  8240. if (compareNodeName(example, ["tbody"])) example = example.querySelector("tr");
  8241. let nextTr = example;
  8242. while (nextTr && nextTr.children.length == 0) nextTr = nextTr.nextElementSibling;
  8243. if (nextTr) example = nextTr;
  8244. let tdNum = 0;
  8245. if (exampleStyle.display == "table-row") {
  8246. [].forEach.call(example.children, el => {
  8247. tdNum += el.colSpan || 1;
  8248. });
  8249. } else {
  8250. [].forEach.call(example.children, el => {
  8251. if (compareNodeName(el, ["td", "th"])) {
  8252. tdNum += el.colSpan || 1;
  8253. }
  8254. });
  8255. }
  8256. pageBar.style.cssText = "";
  8257. pageBar.style.display = "table-row";
  8258. pageBar.style.backgroundColor = "unset";
  8259. pageBar.style.lineHeight = "20px";
  8260. pageBar.style.boxShadow = "";
  8261. let td = document.createElement("td");
  8262. td.colSpan = tdNum || 1;
  8263. let inTd = document.createElement("div");
  8264. inTd.style.cssText = pageBarStyle;
  8265. inTd.style.display = "";
  8266. inTd.className = pageBar.className;
  8267. pageBar.className = "";
  8268. inTd.appendChild(upSpan);
  8269. inTd.appendChild(pageText);
  8270. if (pageNum) inTd.appendChild(pageNum);
  8271. inTd.appendChild(downSpan);
  8272. td.appendChild(inTd);
  8273. pageBar.appendChild(td);
  8274. } else if (inLi) {
  8275. example = compareNodeName(example, ["li"]) ? example : example.nextElementSibling || example;
  8276. pageBar.style.opacity = 1;
  8277. pageBar.style.display = getComputedStyle(example).display;
  8278. pageBar.style.backgroundColor = "unset";
  8279. pageBar.style.lineHeight = "20px";
  8280. pageBar.style.boxShadow = "";
  8281. pageBar.style.border = "";
  8282. pageBar.style.width = "";
  8283. pageBar.style.maxWidth = "unset";
  8284. pageBar.style.flex = "auto";
  8285. let inTd = document.createElement("div");
  8286. inTd.style.cssText = pageBarStyle;
  8287. inTd.style.display = "";
  8288. inTd.style.margin = "0"
  8289. inTd.style.padding = "0 0";
  8290. inTd.style.textAlign = "center";
  8291. inTd.style.minWidth = "150px";
  8292. inTd.style.width = 'calc(100% - 20px)';
  8293. inTd.className = pageBar.className;
  8294. pageBar.className = "";
  8295. inTd.appendChild(upSpan);
  8296. inTd.appendChild(pageText);
  8297. if (pageNum) inTd.appendChild(pageNum);
  8298. inTd.appendChild(downSpan);
  8299. if (pageBar.style.display === 'table-row') {
  8300. let td = document.createElement("td");
  8301. td.colSpan = example.children.length;
  8302. td.style.width = '100%';
  8303. td.appendChild(inTd);
  8304. pageBar.appendChild(td);
  8305. } else {
  8306. inTd.style.width = '100%';
  8307. pageBar.appendChild(inTd);
  8308. }
  8309. }
  8310. }
  8311.  
  8312. upSpan.addEventListener("click", e => {
  8313. getBody(document).scrollTop = 0;
  8314. document.documentElement.scrollTop = 0;
  8315. e.preventDefault();
  8316. e.stopPropagation();
  8317. });
  8318. downSpan.addEventListener("click", e => {
  8319. if (!e.altKey && !e.ctrlKey && !e.shiftKey && !e.metaKey) {
  8320. changeStop(true);
  8321. }
  8322. pageBar.title = i18n(isPause ? "enable" : "disable");
  8323. scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  8324. getBody(document).scrollTop = scrollH || 9999999;
  8325. document.documentElement.scrollTop = scrollH || 9999999;
  8326. e.preventDefault();
  8327. e.stopPropagation();
  8328. });
  8329. pageBar.addEventListener("click", e => {
  8330. changeStop(!isPause, true);
  8331. pageBar.title = i18n(isPause ? "enable" : "disable");
  8332. });
  8333. ruleParser.insertElement(pageBar);
  8334. ruleParser.runPageBar(pageBar);
  8335.  
  8336. if (sideController.inited) {
  8337. try {
  8338. let observer = new IntersectionObserver(entries => {
  8339. if (entries[0].intersectionRatio > 0) {
  8340. sideController.pagenum.innerHTML = createHTML(localPage);
  8341. }
  8342. });
  8343. observer.observe(pageBar);
  8344. } catch(e) {}
  8345. }
  8346. return pageBar;
  8347. }
  8348.  
  8349. async function waitForElement(sel, doc) {
  8350. if (!sel) return null;
  8351. return new Promise((resolve) => {
  8352. let checkInv = setInterval(() => {
  8353. let result = getElement(sel, doc, null, true);
  8354. if (result) {
  8355. clearInterval(checkInv);
  8356. resolve(result);
  8357. }
  8358. }, 100);
  8359. });
  8360. }
  8361.  
  8362. async function clickAction(sel, doc) {
  8363. let btn = await waitForElement(sel, doc);
  8364. emuClick(btn, doc);
  8365. }
  8366.  
  8367. async function enterAction(sel, doc) {
  8368. let btn = await waitForElement(sel, doc);
  8369. let eventParam = { key: "Enter", keyCode: 13, bubbles: true };
  8370. let event = new KeyboardEvent('keydown', eventParam);
  8371. btn.dispatchEvent(event);
  8372. event = new KeyboardEvent('keyup', eventParam);
  8373. btn.dispatchEvent(event);
  8374. event = new KeyboardEvent('keypress', eventParam);
  8375. btn.dispatchEvent(event);
  8376. }
  8377.  
  8378. async function inputAction(sel, v, doc) {
  8379. let input = await waitForElement(sel, doc);
  8380. let event = new Event('focus', { bubbles: true });
  8381. input.dispatchEvent(event);
  8382. let lastValue = input.value;
  8383. if (input.nodeName.toUpperCase() == "INPUT") {
  8384. var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
  8385. nativeInputValueSetter.call(input, v);
  8386. } else if (input.nodeName.toUpperCase() == "TEXTAREA") {
  8387. var nativeTextareaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set;
  8388. nativeTextareaValueSetter.call(input, v);
  8389. } else {
  8390. input.innerHTML = createHTML(v);
  8391. }
  8392. event = new Event('input', { bubbles: true });
  8393. let tracker = input._valueTracker;
  8394. if (tracker) {
  8395. tracker.setValue(lastValue);
  8396. }
  8397. input.dispatchEvent(event);
  8398. event = new Event('change', { bubbles: true });
  8399. input.dispatchEvent(event);
  8400. debug(input, `input ${sel}`);
  8401. }
  8402.  
  8403. function emuClick(btn, doc) {
  8404. if (!doc) doc = document;
  8405. let curScroll = getBody(doc).scrollTop || doc.documentElement.scrollTop;
  8406. let orgHref = btn.getAttribute('href');
  8407. if (orgHref && orgHref.replace(location.origin + location.pathname, "").indexOf("#") === 0) {
  8408. let hashAction = e => {
  8409. e.preventDefault();
  8410. getBody(doc).scrollTop = curScroll;
  8411. doc.documentElement.scrollTop = curScroll;
  8412. btn.removeEventListener('click', hashAction, false);
  8413. };
  8414. btn.addEventListener('click', hashAction, false);
  8415. }
  8416. if (!PointerEvent) return btn.click();
  8417. let eventParam = {
  8418. isTrusted: true,
  8419. altKey: false,
  8420. azimuthAngle: 0,
  8421. bubbles: true,
  8422. button: 0,
  8423. buttons: 0,
  8424. clientX: 1,
  8425. clientY: 1,
  8426. cancelBubble: false,
  8427. cancelable: true,
  8428. composed: true,
  8429. ctrlKey: false,
  8430. defaultPrevented: false,
  8431. detail: 1,
  8432. eventPhase: 2,
  8433. fromElement: null,
  8434. height: 1,
  8435. isPrimary: false,
  8436. metaKey: false,
  8437. pointerId: 1,
  8438. pointerType: "mouse",
  8439. pressure: 0,
  8440. relatedTarget: null,
  8441. returnValue: true,
  8442. shiftKey: false,
  8443. toElement: null,
  8444. twist: 0,
  8445. which: 1
  8446. };
  8447. let mouseEvent = new PointerEvent("mousedown", eventParam);
  8448. btn.dispatchEvent(mouseEvent);
  8449. mouseEvent = new PointerEvent("mouseup", eventParam);
  8450. btn.dispatchEvent(mouseEvent);
  8451. let dispatchTouchEvent = (ele, type) => {
  8452. let touchEvent;
  8453. try {
  8454. touchEvent = document.createEvent('TouchEvent')
  8455. touchEvent.initTouchEvent(type, true, true)
  8456. } catch (err) {
  8457. try {
  8458. touchEvent = document.createEvent('UIEvent')
  8459. touchEvent.initUIEvent(type, true, true)
  8460. } catch (err) {
  8461. touchEvent = document.createEvent('Event')
  8462. touchEvent.initEvent(type, true, true)
  8463. }
  8464. }
  8465. if (touchEvent) {
  8466. try {
  8467. touchEvent.targetTouches = [{
  8468. pageX: 1,
  8469. pageY: 1,
  8470. clientX: 1,
  8471. clientY: 1,
  8472. target: btn
  8473. }];
  8474. touchEvent.touches = [{
  8475. pageX: 1,
  8476. pageY: 1,
  8477. clientX: 1,
  8478. clientY: 1,
  8479. target: btn
  8480. }];
  8481. touchEvent.changedTouches = [{
  8482. pageX: 1,
  8483. pageY: 1,
  8484. clientX: 1,
  8485. clientY: 1,
  8486. target: btn
  8487. }];
  8488. } catch (err) {}
  8489. ele.dispatchEvent(touchEvent);
  8490. }
  8491. }
  8492. dispatchTouchEvent(btn, "touchstart");
  8493. dispatchTouchEvent(btn, "touchend");
  8494.  
  8495. btn.click();
  8496. }
  8497.  
  8498. function emuInput(input, v) {
  8499. let result = false;
  8500. if (!input) return true;
  8501. let event = new Event('focus', { bubbles: true });
  8502. input.dispatchEvent(event);
  8503. let lastValue = input.value;
  8504. if (input.type == 'file') {
  8505. let file = v;
  8506. let blob = new Blob([file], {
  8507. type: 'text/plain'
  8508. });
  8509. file = new File([blob], 'noname.txt', { type: blob.type });
  8510. let dataTransfer = new DataTransfer();
  8511. dataTransfer.items.add(file);
  8512. input.files = dataTransfer.files;
  8513. v = "c:/fakepath/fakefile";
  8514. } else if (/INPUT/i.test(input.nodeName)) {
  8515. var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
  8516. nativeInputValueSetter.call(input, v);
  8517. } else if (/SELECT/i.test(input.nodeName)) {
  8518. var nativeSelectValueSetter = Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, "value").set;
  8519. nativeSelectValueSetter.call(input, v);
  8520. } else if (input.nodeName.toUpperCase() == "TEXTAREA") {
  8521. var nativeTextareaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set;
  8522. nativeTextareaValueSetter.call(input, v);
  8523. } else {
  8524. input.innerHTML = createHTML(v);
  8525. }
  8526. event = new Event('input', { bubbles: true });
  8527. let tracker = input._valueTracker;
  8528. if (tracker) {
  8529. tracker.setValue(lastValue);
  8530. }
  8531. input.dispatchEvent(event);
  8532. event = new Event('change', { bubbles: true });
  8533. input.dispatchEvent(event);
  8534. return result;
  8535. }
  8536.  
  8537. var failFromIframe = 0;
  8538. var inCors = false;
  8539. var checkRemoveIntv;
  8540. function requestFromIframe(url, callback){
  8541. if (location.protocol === 'https:' && !/^https:/.test(url)) {
  8542. ruleParser.noValidContent(url);
  8543. }
  8544. url = url.indexOf('=') == -1 ? url.replace(/#[^#]*/,"") : url;
  8545. let iframe = document.createElement('iframe');
  8546. iframe.name = 'pagetual-iframe';
  8547. iframe.width = '100%';
  8548. iframe.height = '1000';
  8549. iframe.frameBorder = '0';
  8550. if (ruleParser.curSiteRule.sandbox != false) {
  8551. iframe.sandbox = "allow-same-origin allow-scripts allow-popups allow-forms";
  8552. }
  8553. iframe.style.cssText = 'margin:0!important;padding:0!important;visibility:hidden!important;flex:0;opacity:0!important;pointer-events:none!important;position:fixed;top:0px;left:0px;z-index:-2147483647;';
  8554. let waitTime = 100, checkEval;
  8555. ruleParser.runWait((_checkEval, _waitTime) => {
  8556. if (_checkEval) {
  8557. checkEval = _checkEval;
  8558. }
  8559. if (_waitTime) {
  8560. waitTime = _waitTime;
  8561. }
  8562. });
  8563. if (checkRemoveIntv) clearInterval(checkRemoveIntv);
  8564. checkRemoveIntv = setInterval(() => {
  8565. if (!iframe || !getBody(document).contains(iframe)) {
  8566. clearInterval(checkRemoveIntv);
  8567. loadPageOver();
  8568. }
  8569. }, 500);
  8570. let loadedHandler = async e => {
  8571. if (e.data != 'pagetual-iframe:DOMLoaded' && e.type != 'load') return;
  8572. clearInterval(checkRemoveIntv);
  8573. window.removeEventListener('message', loadedHandler, false);
  8574. iframe.removeEventListener('load', loadedHandler, false);
  8575. let pageEleTryTimes = 0;
  8576. async function checkIframe() {
  8577. if (urlChanged || isPause) {
  8578. return callback(false, false);
  8579. }
  8580. try {
  8581. let doc = iframe.contentDocument || iframe.contentWindow.document;
  8582. if (checkEval && !await checkEval(doc)) {
  8583. setTimeout(() => {
  8584. checkIframe();
  8585. }, waitTime);
  8586. return;
  8587. } else {
  8588. let preCode = ruleParser.curSiteRule.pagePre, eles = null;
  8589. if (preCode) {
  8590. try {
  8591. let preResult;
  8592. if (typeof preCode == 'function') {
  8593. preResult = await preCode(doc.documentElement.innerHTML, doc);
  8594. } else if (preCode.length == 2) {
  8595. preResult = doc.documentElement.innerHTML.replace(new RegExp(preCode[0], "gi"), preCode[1]);
  8596. } else {
  8597. preResult = await new AsyncFunction("response", "doc", '"use strict";' + preCode)(doc.documentElement.innerHTML, doc);
  8598. }
  8599. if (typeof preResult !== "undefined") {
  8600. if (typeof preResult === "string") {
  8601. doc.documentElement.innerHTML = preResult;
  8602. } else eles = preResult;
  8603. }
  8604. } catch(e) {
  8605. debug(e);
  8606. }
  8607. }
  8608. let base = doc.querySelector("base");
  8609. ruleParser.basePath = (base && base.href) || url;
  8610. if (eles === null) eles = ruleParser.getPageElement(doc, iframe.contentWindow, pageEleTryTimes < 25);
  8611. if (eles && eles.length > 0) {
  8612. await ruleParser.hookUrl(doc);
  8613. await callback(doc, eles);
  8614. } else if (pageEleTryTimes++ < 100) {
  8615. getBody(doc).scrollTop = 9999999;
  8616. doc.documentElement.scrollTop = 9999999;
  8617. setTimeout(() => {
  8618. checkIframe();
  8619. }, waitTime);
  8620. return;
  8621. } else {
  8622. if (failFromIframe++ > 2) {
  8623. failFromIframe = 0;
  8624. debug("Stop as failFromIframe");
  8625. changeStop(true);
  8626. callback(false, false);
  8627. } else {
  8628. ruleParser.noValidContent(url);
  8629. callback(false, false);
  8630. }
  8631. }
  8632. }
  8633. } catch(e) {
  8634. inCors = true;
  8635. if (forceState === 3) {
  8636. debug("Stop as cors");
  8637. isPause = true;
  8638. }
  8639. if (!ruleParser.curSiteRule.pageElement) {
  8640. ruleParser.curSiteRule.pageElement = allOfBody;
  8641. ruleParser.getInsert(true);
  8642. }
  8643. ruleParser.curSiteRule.action = 0;
  8644. ruleParser.nextLinkHref = url;
  8645. callback(false, false);
  8646. nextPage();
  8647. }
  8648. if (iframe && iframe.parentNode) iframe.parentNode.removeChild(iframe);
  8649. }
  8650. setTimeout(() => {
  8651. checkIframe();
  8652. }, waitTime);
  8653. };
  8654. let code = ruleParser.curSiteRule.iframeInit;
  8655. if (code) {
  8656. let checkReady = setInterval(() => {
  8657. let doc;
  8658. try {
  8659. doc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document);
  8660. } catch(e) {
  8661. clearInterval(checkReady);
  8662. return;
  8663. }
  8664. if (doc) {
  8665. clearInterval(checkReady);
  8666. try {
  8667. Function('win', 'iframe', '"use strict";' + code)(iframe.contentWindow, iframe);
  8668. } catch(e) {
  8669. debug(e);
  8670. }
  8671. }
  8672. }, 50);
  8673. }
  8674. window.addEventListener('message', loadedHandler, false);
  8675. iframe.addEventListener('load', loadedHandler, false);
  8676. iframe.src = url;
  8677. try {
  8678. getBody(document).appendChild(iframe);
  8679. } catch (e) {
  8680. return callback(false, false);
  8681. }
  8682. }
  8683.  
  8684. var emuIframe, lastActiveUrl, orgContent, meetCors = false;
  8685. function emuPage(callback) {
  8686. let orgPage = null, preContent = null, iframeDoc, checkTimes = 0, loadmoreBtn, pageEle, nextLink, loadmoreEnd = false, waitTimes = 80, changed = false;
  8687. function returnFalse(log) {
  8688. if (curPage > 1) {
  8689. ruleParser.reachedLastPage();
  8690. } else {
  8691. sideController.remove();
  8692. }
  8693. debug(log);
  8694. isPause = true;
  8695. callback(false, false);
  8696. if (emuIframe && emuIframe.parentNode) {
  8697. emuIframe.parentNode.removeChild(emuIframe);
  8698. emuIframe = null;
  8699. }
  8700. }
  8701. function cloneStatus() {
  8702. if (!iframeDoc) return;
  8703. let inputs = document.querySelectorAll("input:not([type=button],[type=image],[type=reset],[type=submit])");
  8704. let selectOptions = document.querySelectorAll("select>option");
  8705. [...inputs].forEach(input => {
  8706. let sel = geneSelector(input, true, true);
  8707. let mirrorEle = iframeDoc.querySelector(sel);
  8708. if (!mirrorEle) return;
  8709. emuInput(mirrorEle, input.value);
  8710. });
  8711. [...selectOptions].forEach(option => {
  8712. let sel = geneSelector(option, true, true);
  8713. let mirrorEle = iframeDoc.querySelector(sel);
  8714. if (!mirrorEle) return;
  8715. let selected = option.selected;
  8716. mirrorEle.selected = !!selected;
  8717. mirrorEle.parentNode.dispatchEvent(new Event('change'));
  8718. });
  8719. }
  8720. async function checkPage() {
  8721. if (isPause) return loadPageOver();
  8722. try {
  8723. iframeDoc = emuIframe.contentDocument || emuIframe.contentWindow.document;
  8724. } catch(e) {
  8725. returnFalse("Stop as cors");
  8726. return;
  8727. }
  8728.  
  8729. let waitTime = 200, checkEval;
  8730. ruleParser.runWait((_checkEval, _waitTime) => {
  8731. if (_checkEval) {
  8732. checkEval = _checkEval;
  8733. }
  8734. if (_waitTime) {
  8735. waitTime = _waitTime;
  8736. }
  8737. });
  8738.  
  8739. if (!orgPage) {
  8740. if (!loadmoreEnd) {
  8741. loadmoreBtn = getLoadMore(iframeDoc);
  8742. if (loadmoreBtn && isVisible(loadmoreBtn, emuIframe.contentWindow)) {
  8743. emuClick(loadmoreBtn, iframeDoc);
  8744. let intv = setInterval(() => {
  8745. loadmoreBtn = getLoadMore(iframeDoc);
  8746. if (!loadmoreBtn || !getBody(document).contains(loadmoreBtn) || !isVisible(loadmoreBtn, emuIframe.contentWindow)) {
  8747. clearInterval(intv);
  8748. loadmoreEnd = true;
  8749. setTimeout(() => {
  8750. checkPage();
  8751. }, 500);
  8752. } else if (isInViewPort(loadmoreBtn)) {
  8753. emuClick(loadmoreBtn, iframeDoc);
  8754. }
  8755. }, 200);
  8756. return;
  8757. } else {
  8758. loadmoreEnd = true;
  8759. }
  8760. }
  8761. if (checkEval && !await checkEval(iframeDoc)) {
  8762. waitTimes = 50;
  8763. setTimeout(() => {
  8764. checkPage();
  8765. }, waitTime);
  8766. return;
  8767. } else {
  8768. if (!nextLink || !nextLink.offsetParent) nextLink = await ruleParser.getNextLink(iframeDoc, true);
  8769. if (nextLink) pageEle = ruleParser.getPageElement(iframeDoc, emuIframe.contentWindow, true);
  8770. if (!pageEle || pageEle.length == 0 || !nextLink) {
  8771. getBody(iframeDoc).scrollTop = 9999999;
  8772. iframeDoc.documentElement.scrollTop = 9999999;
  8773. if (waitTimes-- > 0) {
  8774. setTimeout(() => {
  8775. checkPage();
  8776. }, waitTime);
  8777. return;
  8778. }
  8779. }
  8780. }
  8781. if (!pageEle || pageEle.length == 0) {
  8782. returnFalse("Stop as no page when emu");
  8783. return;
  8784. }
  8785. pageEle = [].filter.call(pageEle, ele => {return ele && !compareNodeName(ele, ["style", "script", "meta"])});
  8786. if (compareNodeName(pageEle[0], ["ul"]) || pageEle.length == 1) pageEle = pageEle[0];
  8787. else if (pageEle[0].parentNode == pageEle[1].parentNode) {
  8788. pageEle = pageEle[0].parentNode;
  8789. } else {
  8790. pageEle = pageEle[0];
  8791. }
  8792. if (ruleParser.curSiteRule.smart && orgContent != pageEle.innerHTML) {
  8793. orgContent = pageEle.innerHTML;
  8794. if (waitTimes-- > 0) {
  8795. setTimeout(() => {
  8796. checkPage();
  8797. }, 500);
  8798. return;
  8799. }
  8800. }
  8801. orgPage = pageEle;
  8802. if (nextLink) {
  8803. if (compareNodeName(orgPage, ["img"])) {
  8804. if (!ruleParser.curSiteRule.lazyImgSrc) ruleParser.curSiteRule.lazyImgSrc = "0";
  8805. if (orgPage.src) {
  8806. orgContent = orgPage.src;
  8807. } else {
  8808. setTimeout(() => {
  8809. checkPage();
  8810. }, 500);
  8811. return;
  8812. }
  8813. } else {
  8814. orgContent = orgPage.innerHTML;
  8815. }
  8816. preContent = orgContent;
  8817. if (!isVisible(nextLink, emuIframe.contentWindow)) {
  8818. returnFalse("Stop as next hide when emu");
  8819. } else {
  8820. emuClick(nextLink, iframeDoc);
  8821. setTimeout(() => {
  8822. checkPage();
  8823. }, 500);
  8824. }
  8825. } else {
  8826. returnFalse("Stop as no next when emu");
  8827. }
  8828. return;
  8829. }
  8830. if (!ruleParser.checkStopSign(nextLink, iframeDoc)) {
  8831. return returnFalse("Stop as stopSign");
  8832. }
  8833. if (checkTimes++ > 200) {
  8834. returnFalse("Stop as timeout when emu");
  8835. return;
  8836. }
  8837. if (checkEval && !await checkEval(iframeDoc)) {
  8838. checkTimes = 0;
  8839. setTimeout(() => {
  8840. checkPage();
  8841. }, waitTime);
  8842. return;
  8843. }
  8844. let eles = ruleParser.getPageElement(iframeDoc, emuIframe.contentWindow, true), checkItem;
  8845. if (eles && eles.length > 0) {
  8846. eles = [].filter.call(eles, ele => {return ele && !compareNodeName(ele, ["style", "script", "meta"])});
  8847. if (compareNodeName(eles[0], ["ul"]) || eles.length == 1) checkItem = eles[0];
  8848. else if (eles[0].parentNode == eles[1].parentNode) {
  8849. checkItem = eles[0].parentNode;
  8850. } else {
  8851. checkItem = eles[0];
  8852. }
  8853. }
  8854. if (!checkItem) {
  8855. setTimeout(() => {
  8856. checkPage();
  8857. }, waitTime);
  8858. } else {
  8859. let checkInner;
  8860. if (compareNodeName(checkItem, ["img"])) {
  8861. if (checkItem.src) {
  8862. checkInner = checkItem.src;
  8863. } else {
  8864. setTimeout(() => {
  8865. checkPage();
  8866. }, waitTime);
  8867. return;
  8868. }
  8869. } else {
  8870. checkInner = checkItem.innerHTML;
  8871. }
  8872. if (orgPage != checkItem || checkInner != preContent) {
  8873. changed = true;
  8874. orgPage = checkItem;
  8875. preContent = checkInner;
  8876. setTimeout(() => {
  8877. checkPage();
  8878. }, 500);
  8879. } else if (changed) {
  8880. checkTimes = 0;
  8881. if (orgContent == preContent && (ruleParser.curSiteRule.smart || ruleParser.curSiteRule.stopSame)) {
  8882. returnFalse("Stop as same content");
  8883. } else {
  8884. orgContent = preContent;
  8885. await ruleParser.hookUrl(iframeDoc);
  8886. callback(iframeDoc, eles);
  8887. }
  8888. } else {
  8889. if (checkTimes % 10 === 5) {
  8890. if (!nextLink || !nextLink.offsetParent) {
  8891. nextLink = await ruleParser.getNextLink(iframeDoc, true);
  8892. }
  8893. if (nextLink) {
  8894. emuClick(nextLink, iframeDoc);
  8895. }
  8896. }
  8897. setTimeout(() => {
  8898. checkPage();
  8899. }, waitTime);
  8900. }
  8901. }
  8902. }
  8903. if (!emuIframe) {
  8904. let loaded = false;
  8905. emuIframe = document.createElement('iframe');
  8906. emuIframe.name = 'pagetual-iframe';
  8907. let notSetSandbox = typeof ruleParser.curSiteRule.sandbox == 'undefined';
  8908. if (notSetSandbox || ruleParser.curSiteRule.sandbox == true) {
  8909. emuIframe.sandbox = "allow-same-origin allow-scripts allow-popups allow-forms";
  8910. } else if (ruleParser.curSiteRule.sandbox) {
  8911. emuIframe.sandbox = ruleParser.curSiteRule.sandbox;
  8912. }
  8913. emuIframe.width = '100%';
  8914. emuIframe.height = '100%';
  8915. emuIframe.frameBorder = '0';
  8916. emuIframe.style.cssText = 'margin:0!important;padding:0!important;flex:0;opacity:0!important;pointer-events:none!important;position:fixed;top:0px;left:0px;z-index:-2147483647;';
  8917. emuIframe.addEventListener("load", e => {
  8918. try {
  8919. iframeDoc = emuIframe.contentDocument || emuIframe.contentWindow.document;
  8920. } catch(e) {
  8921. if (e.message && e.message.indexOf("cross-origin") != -1 && notSetSandbox && emuIframe.hasAttribute("sandbox")) {
  8922. emuIframe.removeAttribute("sandbox");
  8923. meetCors = true;
  8924. callback(false, false);
  8925. if (ruleParser.curSiteRule.smart) {
  8926. ruleParser.findNoNext();
  8927. }
  8928. } else {
  8929. returnFalse("Stop as cors");
  8930. }
  8931. return;
  8932. }
  8933. setTimeout(async () => {
  8934. if (meetCors && ruleParser.curSiteRule.smart) {
  8935. ruleParser.smartRules = ruleParser.smartRules.filter(item => {return item && item.url !== ruleParser.curSiteRule.url;});
  8936. storage.setItem("smartRules", ruleParser.smartRules);
  8937. }
  8938. meetCors = false;
  8939. let code = ruleParser.curSiteRule.init;
  8940. if (code) {
  8941. try {
  8942. await new AsyncFunction('doc','win','iframe','click', 'enter', 'input', 'sleep', '"use strict";' + code)(iframeDoc, emuIframe.contentWindow, emuIframe, async sel => {await clickAction(sel, iframeDoc)}, async sel => {await enterAction(sel, iframeDoc)}, async (sel, v) =>{await inputAction(sel, v, iframeDoc)}, async time => {await sleep(time)});
  8943. } catch(e) {
  8944. debug(e);
  8945. }
  8946. } else {
  8947. let refreshByClickSel = ruleParser.curSiteRule.refreshByClick;
  8948. if (iframeDoc && refreshByClickSel) {
  8949. let clickBtn = await waitForElement(refreshByClickSel, iframeDoc);
  8950. await sleep(500);
  8951. cloneStatus();
  8952. emuClick(clickBtn, iframeDoc);
  8953. await sleep(500);
  8954. }
  8955. }
  8956. if (loaded) return;
  8957. loaded = true;
  8958. checkPage();
  8959. }, 500);
  8960. });
  8961. let code = ruleParser.curSiteRule.iframeInit;
  8962. if (code) {
  8963. let checkReady = setInterval(() => {
  8964. try {
  8965. iframeDoc = emuIframe.contentDocument || (emuIframe.contentWindow && emuIframe.contentWindow.document);
  8966. } catch(e) {
  8967. clearInterval(checkReady);
  8968. return;
  8969. }
  8970. if (iframeDoc) {
  8971. clearInterval(checkReady);
  8972. try {
  8973. Function('win', 'iframe', '"use strict";' + code)(emuIframe.contentWindow, emuIframe);
  8974. } catch(e) {
  8975. debug(e);
  8976. }
  8977. }
  8978. }, 50);
  8979. }
  8980. if (!lastActiveUrl) lastActiveUrl = location.href;
  8981. emuIframe.src = lastActiveUrl;
  8982. getBody(document).appendChild(emuIframe);
  8983. } else {
  8984. if (emuIframe.src != lastActiveUrl || meetCors) {
  8985. emuIframe.src = lastActiveUrl;
  8986. return;
  8987. }
  8988. checkPage();
  8989. }
  8990. }
  8991.  
  8992. var scrollToResizeInited = false;
  8993. var resizePool = [];
  8994. var scrollingToResize = false;
  8995.  
  8996. function isTouchViewPort(element) {
  8997. const viewWidth = window.innerWidth || document.documentElement.clientWidth;
  8998. const viewHeight = window.innerHeight || document.documentElement.clientHeight;
  8999. const {
  9000. top,
  9001. right,
  9002. bottom,
  9003. left,
  9004. } = element.getBoundingClientRect();
  9005.  
  9006. return (
  9007. top < viewHeight &&
  9008. left < viewWidth &&
  9009. right > 0 &&
  9010. bottom > 0
  9011. );
  9012. }
  9013.  
  9014. function resizeIframe(iframe, frameDoc, pageEle) {
  9015. if (targetY >= 0) {
  9016. window.scrollTo({ top: targetY, behavior: 'instant'});
  9017. targetY = -1;
  9018. }
  9019. let curScroll = getBody(document).scrollTop || document.documentElement.scrollTop;
  9020. if (ruleParser.curSiteRule.smart || forceState === 2) {
  9021. let height = (getBody(frameDoc).scrollHeight || getBody(frameDoc).offsetHeight || 500);
  9022. if (!iframe.style.height || parseInt(iframe.style.height) === 0 || height - parseInt(iframe.style.height) > window.innerHeight) {
  9023. iframe.style.height = height + "px";
  9024. iframe.style.minHeight = iframe.style.height;
  9025. }
  9026. iframe.style.width = "100%";
  9027. frameDoc.documentElement.scrollTop = 0;
  9028. frameDoc.documentElement.scrollLeft = 0;
  9029. } else {
  9030. if (pageEle) {
  9031. if (document.body.scrollWidth) frameDoc.documentElement.style.width = document.body.scrollWidth + "px";
  9032. let fitWidth = ruleParser.curSiteRule.fitWidth !== false;
  9033. let targetElement = pageEle[0];
  9034. if (!targetElement) return;
  9035. if (pageEle.length > 1) {
  9036. targetElement = targetElement.parentNode;
  9037. }
  9038. let scrollHeight = targetElement.scrollHeight || targetElement.offsetHeight || 500;
  9039. iframe.style.height = scrollHeight + "px";
  9040. let scrollTop = 0, scrollLeft = 0;
  9041. getBody(frameDoc).scrollTop = 0;
  9042. getBody(frameDoc).scrollLeft = 0;
  9043. while (targetElement && targetElement.offsetParent) {
  9044. targetElement.offsetParent.scrollTop = targetElement.offsetTop;
  9045. if (targetElement.offsetParent.scrollTop == 0) {
  9046. scrollTop += targetElement.offsetTop;
  9047. }
  9048. if (fitWidth) {
  9049. targetElement.offsetParent.scrollLeft = targetElement.offsetLeft;
  9050. if (targetElement.offsetParent.scrollLeft == 0) {
  9051. scrollLeft += targetElement.offsetLeft;
  9052. }
  9053. }
  9054. targetElement = targetElement.offsetParent;
  9055. }
  9056. frameDoc.documentElement.scrollTop = scrollTop;
  9057. frameDoc.documentElement.scrollLeft = scrollLeft;
  9058. if (frameDoc.documentElement.scrollTop == 0 && frameDoc.documentElement.scrollLeft == 0) {
  9059. getBody(frameDoc).scrollTop += scrollTop;
  9060. getBody(frameDoc).scrollLeft += scrollLeft;
  9061. }
  9062. if (!fitWidth && iframe.style.marginLeft == '0px') {
  9063. iframe.style.width = "100vw";
  9064. iframe.style.maxWidth = "100vw";
  9065. iframe.style.minWidth = "100vw";
  9066. var cWidth = document.body.clientWidth || document.documentElement.clientWidth;
  9067. var iWidth = window.innerWidth;
  9068. iframe.style.marginLeft = -iframe.getBoundingClientRect().left - (iWidth - cWidth) / 2 + "px";
  9069. }
  9070. }
  9071. }
  9072. let newScroll = getBody(document).scrollTop || document.documentElement.scrollTop;
  9073. if (newScroll != curScroll) {
  9074. getBody(document).scrollTop = curScroll;
  9075. document.documentElement.scrollTop = curScroll;
  9076. }
  9077. }
  9078.  
  9079. function scrollToResize(e) {
  9080. if (scrollingToResize) return;
  9081. else {
  9082. scrollingToResize = true;
  9083. let resizeHandler = () => {
  9084. let touched = 0;
  9085. for (let i = 0; i < resizePool.length; i++) {
  9086. let resizeArr = resizePool[i];
  9087. let iframe = resizeArr[1]();
  9088. if (isTouchViewPort(iframe)) {
  9089. touched++;
  9090. let pageEle = resizeArr[0]();
  9091. let frameDoc = resizeArr[2]();
  9092. resizeIframe(iframe, frameDoc, pageEle);
  9093. } else if (touched) {
  9094. if (touched == 1) {
  9095. let pageEle = resizeArr[0]();
  9096. let frameDoc = resizeArr[2]();
  9097. resizeIframe(iframe, frameDoc, pageEle);
  9098. }
  9099. break;
  9100. } else if (!iframe.parentNode) {
  9101. resizePool.splice(i, 1);
  9102. break;
  9103. }
  9104. }
  9105. };
  9106. setTimeout(() => {
  9107. scrollingToResize = false;
  9108. }, 300);
  9109. resizeHandler();
  9110. }
  9111. }
  9112.  
  9113. var curForceIframe;
  9114. function forceIframe(url, callback) {
  9115. url = url.indexOf('=') == -1 ? url.replace(/#[^#]*/,"") : url;
  9116. let curIframe = document.createElement('iframe'), iframeDoc, pageElement = null, inAction = true;
  9117. let loadedHandler = () => {
  9118. let getPageEle = () => {
  9119. if (ruleParser.curSiteRule.smart) {
  9120. return null;
  9121. } else {
  9122. if (!pageElement || pageElement.length === 0 || !pageElement[0].offsetParent) {
  9123. pageElement = ruleParser.getPageElement(iframeDoc, curIframe.contentWindow);
  9124. }
  9125. return pageElement;
  9126. }
  9127. };
  9128. resizeIframe(curIframe, iframeDoc, getPageEle());
  9129. let loaded = curIframe.getAttribute("loaded");
  9130. if (loaded == "true") {
  9131. return;
  9132. }
  9133. curIframe.setAttribute("loaded", "true");
  9134. let getIframe = () => {
  9135. return curIframe;
  9136. };
  9137. let getFrameDoc = () => {
  9138. return iframeDoc;
  9139. };
  9140. ruleParser.insertPage(iframeDoc, [], url, ele => {
  9141. callback(curIframe, loaded == "refresh");
  9142. inAction = false;
  9143. }, true);
  9144. if (!loaded) {
  9145. resizePool.push([getPageEle, getIframe, getFrameDoc]);
  9146. }
  9147. };
  9148. let checkIframeTimer = setInterval(() => {
  9149. if (!curIframe.parentNode) {
  9150. clearInterval(checkIframeTimer);
  9151. return curIframe.getAttribute("loaded") == "true" || callback(false);
  9152. }
  9153. }, 500);
  9154. let code = ruleParser.curSiteRule.iframeInit;
  9155. if (code) {
  9156. let checkReady = setInterval(() => {
  9157. try {
  9158. iframeDoc = curIframe.contentDocument || (curIframe.contentWindow && curIframe.contentWindow.document);
  9159. } catch(e) {
  9160. clearInterval(checkReady);
  9161. return;
  9162. }
  9163. if (iframeDoc) {
  9164. clearInterval(checkReady);
  9165. try {
  9166. Function('win', 'iframe', '"use strict";' + code)(curIframe.contentWindow, curIframe);
  9167. } catch(e) {
  9168. debug(e);
  9169. }
  9170. }
  9171. }, 50);
  9172. }
  9173. let waitTime = 300, checkEval;
  9174. ruleParser.runWait((_checkEval, _waitTime) => {
  9175. if (_checkEval) {
  9176. checkEval = _checkEval;
  9177. }
  9178. if (_waitTime) {
  9179. waitTime = _waitTime;
  9180. }
  9181. });
  9182. async function checkIframe() {
  9183. if (checkEval && !await checkEval(iframeDoc)) {
  9184. setTimeout(() => {
  9185. checkIframe();
  9186. }, waitTime);
  9187. return;
  9188. }
  9189. loadedHandler();
  9190. }
  9191. curIframe.name = 'pagetual-iframe';
  9192. curIframe.sandbox = "allow-same-origin allow-scripts allow-popups allow-forms";
  9193. curIframe.frameBorder = '0';
  9194. curIframe.scrolling = "no";
  9195. curIframe.style.cssText = 'display: block; visibility: visible; float: none; clear: both; width: 100%; height: 0; background: initial; border: 0px; border-radius: 0px; margin: 0px; padding: 0px; z-index: 2147483645;content-visibility: auto;contain-intrinsic-size: auto 300px;';
  9196. curIframe.addEventListener("load", async e => {
  9197. clearInterval(checkIframeTimer);
  9198. if (isPause) return callback(false);
  9199. try {
  9200. iframeDoc = curIframe.contentDocument || curIframe.contentWindow.document;
  9201. } catch(e) {
  9202. debug("Stop as cors");
  9203. isPause = true;
  9204. callback(false);
  9205. return;
  9206. }
  9207. let css = ruleParser.curSiteRule.css || rulesData.customCss;
  9208. if (css) {
  9209. let cssArr = css.split("inIframe:");
  9210. if (cssArr && cssArr.length > 1) {
  9211. let styleEle = iframeDoc.createElement("style");
  9212. styleEle.innerHTML = cssArr[1];
  9213. iframeDoc.head.appendChild(styleEle);
  9214. }
  9215. }
  9216. curIframe.style.height = "";
  9217. checkIframe();
  9218. iframeDoc.addEventListener('wheel', e => {
  9219. document.dispatchEvent(new Event('wheel'));
  9220. }, true);
  9221. });
  9222. let checkTimes = 0, findPageEle = false;
  9223. let forceRefresh = e => {
  9224. if (inAction || !iframeDoc) return;
  9225. inAction = true;
  9226. let foundNext = () => {
  9227. document.removeEventListener("scroll", forceRefresh);
  9228. }
  9229. setTimeout(async () => {
  9230. inAction = false;
  9231. if (!ruleParser.nextLinkHref && !isPause) {
  9232. checkTimes++;
  9233. await ruleParser.getNextLink(iframeDoc, true);
  9234. if (ruleParser.nextLinkHref) {
  9235. foundNext();
  9236. if (isLoading) isLoading = false;
  9237. } else if (checkTimes >= 10) {
  9238. foundNext();
  9239. } else if (checkTimes >= 3 && !findPageEle) {
  9240. if (!pageElement) pageElement = ruleParser.getPageElement(iframeDoc, curIframe.contentWindow);
  9241. if (!pageElement) {
  9242. inAction = true;
  9243. curIframe.contentWindow.location.reload();
  9244. } else {
  9245. findPageEle = true;
  9246. }
  9247. }
  9248. } else {
  9249. foundNext();
  9250. }
  9251. }, 100);
  9252. };
  9253. document.addEventListener("scroll", forceRefresh);
  9254. curIframe.src = url;
  9255. curForceIframe = curIframe;
  9256. let insert = ruleParser.getInsert();
  9257. let body = getBody(document);
  9258. let curScroll = body.scrollTop || document.documentElement.scrollTop;
  9259. if (forceState == 2) {
  9260. document.documentElement.appendChild(loadingDiv);
  9261. body.appendChild(curIframe);
  9262. let bodyStyle = getComputedStyle(body);
  9263. if (bodyStyle.display == "flex" || bodyStyle.display == "inline-flex") {
  9264. body.style.flexDirection = "column";
  9265. }
  9266. } else {
  9267. ruleParser.insertElement(curIframe);
  9268. }
  9269. body.scrollTop = curScroll;
  9270. document.documentElement.scrollTop = curScroll;
  9271.  
  9272. if (!scrollToResizeInited) {
  9273. scrollToResizeInited = true;
  9274. document.addEventListener("scroll", scrollToResize);
  9275. }
  9276. return curIframe;
  9277. }
  9278.  
  9279. function loadPageOver() {
  9280. isLoading = false;
  9281. stopScroll = true;
  9282. setTimeout(() => {stopScroll = false;}, 300);
  9283. if (loadingDiv.parentNode) {
  9284. loadingDiv.parentNode.removeChild(loadingDiv);
  9285. }
  9286. if (rate !== 1 && !clickMode) {
  9287. setTimeout(() => {
  9288. if (distToBottom() < bottomGap) {
  9289. nextPage();
  9290. }
  9291. }, 1);
  9292. }
  9293. if (sideController.inited) {
  9294. sideController.frame.classList.remove("loading");
  9295. }
  9296. }
  9297.  
  9298. function checkAutoLoadNum() {
  9299. if (autoLoadNum >= 0) {
  9300. if (autoLoadNum !== 0 && --autoLoadNum === 0) {
  9301. autoLoadNum = -1;
  9302. } else {
  9303. setTimeout(() => nextPage(), 1);
  9304. }
  9305. }
  9306. }
  9307.  
  9308. async function nextPage() {
  9309. if (isPause || isLoading || forceState === 1) return;
  9310. if (ruleParser.curSiteRule.delay) {
  9311. try {
  9312. let checkDelay = ((typeof ruleParser.curSiteRule.delay === 'function') ? ruleParser.curSiteRule.delay : Function('"use strict";' + ruleParser.curSiteRule.delay))();
  9313. if (!checkDelay) return;
  9314. } catch(e) {
  9315. debug(e);
  9316. }
  9317. }
  9318. let nextLink = ruleParser.nextLinkHref;
  9319. if (!nextLink) {
  9320. isLoading = true;
  9321. if (curPage === 1) {
  9322. await ruleParser.getNextLink(document, true);
  9323. nextLink = ruleParser.nextLinkHref;
  9324. }
  9325. if (!nextLink) {
  9326. if (curPage === 1) {
  9327. if (ruleParser.curSiteRule.pinUrl) {
  9328. setTimeout(() => {isLoading = false;}, 500);
  9329. } else if (tryTimes++ < 5) {
  9330. setTimeout(() => {isLoading = false;}, 1000);
  9331. } else {
  9332. ruleParser.findNoNext();
  9333. }
  9334. } else if (!showedLastPageTips) {
  9335. ruleParser.reachedLastPage();
  9336. showedLastPageTips = true;
  9337. }
  9338. return;
  9339. }
  9340. isLoading = false;
  9341. }
  9342. showedLastPageTips = false;
  9343. let pvGallery = document.querySelector("span.pv-gallery-container");
  9344. if (pvGallery && pvGallery.style.display !== "none") return;
  9345. let insert = ruleParser.getInsert();
  9346. if (insert) {
  9347. if (curPage === 1) initView();
  9348. /*if (curPage == 1) {
  9349. window.postMessage({
  9350. command: 'pagetual.insert'
  9351. }, '*');
  9352. }*/
  9353. let isJs = ruleParser.curSiteRule.action == 3 || ruleParser.hrefIsJs(nextLink);
  9354. if (!isJs) {
  9355. emuIframe = null;
  9356. lastActiveUrl = nextLink;
  9357. if (location.protocol === "https:" && /^http:/.test(nextLink)) {
  9358. nextLink = nextLink.replace(/^http/, "https");
  9359. }
  9360. }
  9361. isLoading = true;
  9362. if (curPage !== 1 || !isJs || !ruleParser.curSiteRule.smart) {
  9363. ruleParser.beginLoading(loadingDiv);
  9364. }
  9365. let sleep = ruleParser.curSiteRule.sleep || 0;
  9366. setTimeout(() => {
  9367. if (ruleParser.curSiteRule.pageElementByJs) {
  9368. var over = eles => {
  9369. if (urlChanged || isPause) {
  9370. loadPageOver();
  9371. return;
  9372. }
  9373. if (eles) {
  9374. ruleParser.insertPage(document, eles, nextLink, () => {
  9375. createPageBar(nextLink);
  9376. checkAutoLoadNum();
  9377. }, true);
  9378. } else {
  9379. debug("Stop as no page when get by js");
  9380. isPause = true;
  9381. loadPageOver();
  9382. }
  9383. };
  9384. try {
  9385. ((typeof ruleParser.curSiteRule.pageElementByJs === 'function') ? ruleParser.curSiteRule.pageElementByJs : Function("over", "pageNum",'"use strict";' + ruleParser.curSiteRule.pageElementByJs))(over, curPage);
  9386. } catch(e) {
  9387. debug(e);
  9388. }
  9389. } else if ((forceState === 2 || ruleParser.curSiteRule.action == 2) && !isJs) {
  9390. forceIframe(nextLink, (iframe, refresh) => {
  9391. if (urlChanged || isPause) {
  9392. loadPageOver();
  9393. return;
  9394. }
  9395. if (!refresh) {
  9396. let pageBar = createPageBar(nextLink);
  9397. if (pageBar && iframe && iframe.parentNode) iframe.parentNode.insertBefore(pageBar, iframe);
  9398. }
  9399. loadPageOver();
  9400. checkAutoLoadNum();
  9401. });
  9402. } else if ((forceState === 3 || ruleParser.curSiteRule.action == 1) && !isJs) {
  9403. requestFromIframe(nextLink, async (doc, eles) => {
  9404. if (urlChanged || isPause) {
  9405. loadPageOver();
  9406. return;
  9407. }
  9408. if (eles) {
  9409. await ruleParser.insertPage(doc, eles, nextLink, () => {
  9410. createPageBar(nextLink);
  9411. checkAutoLoadNum();
  9412. }, true);
  9413. } else {
  9414. loadPageOver();
  9415. if (autoLoadNum >= 0) {
  9416. setTimeout(() => nextPage(), 2000);
  9417. }
  9418. }
  9419. });
  9420. } else {
  9421. if (!isJs) {
  9422. requestDoc(nextLink, (eles) => {
  9423. if (urlChanged || isPause) {
  9424. loadPageOver();
  9425. return;
  9426. }
  9427. if (eles) {
  9428. createPageBar(nextLink);
  9429. checkAutoLoadNum();
  9430. } else {
  9431. loadPageOver();
  9432. if (autoLoadNum >= 0) {
  9433. setTimeout(() => nextPage(), 2000);
  9434. }
  9435. }
  9436. });
  9437. } else {
  9438. emuPage((doc, eles) => {
  9439. if (urlChanged || isPause) {
  9440. loadPageOver();
  9441. return;
  9442. }
  9443. if (eles) {
  9444. ruleParser.insertPage(doc, eles, "", () => {
  9445. createPageBar(nextLink);
  9446. checkAutoLoadNum();
  9447. }, true);
  9448. } else {
  9449. loadPageOver();
  9450. if (autoLoadNum >= 0) {
  9451. setTimeout(() => nextPage(), 2000);
  9452. }
  9453. }
  9454. });
  9455. }
  9456. }
  9457. }, sleep);
  9458. }
  9459. }
  9460.  
  9461. function init() {
  9462. if (document.readyState === 'loading' || document.readyState === 'uninitialized') {
  9463. let domReady = e => {
  9464. initRules(() => {
  9465. initPage();
  9466. });
  9467. document.removeEventListener("DOMContentLoaded", domReady, false);
  9468. };
  9469. document.addEventListener("DOMContentLoaded", domReady, false);
  9470. } else {
  9471. initRules(() => {
  9472. initPage();
  9473. });
  9474. }
  9475. }
  9476.  
  9477. function visibilitychangeHandler() {
  9478. document.removeEventListener('visibilitychange', visibilitychangeHandler);
  9479. init();
  9480. }
  9481.  
  9482. setTimeout(() => {
  9483. if (document.hidden) {
  9484. document.addEventListener('visibilitychange', visibilitychangeHandler);
  9485. } else {
  9486. init();
  9487. }
  9488. }, 300);
  9489. })();