東方永頁機

終極自動翻頁 - 加載並拼接下一分頁內容至當前頁尾,智能適配任意網頁

目前為 2024-07-25 提交的版本,檢視 最新版本

  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.86
  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-end
  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\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-s", "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, 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. if (doc.documentElement) {
  1657. doc.documentElement.scrollTop = 9999999;
  1658. }
  1659. }
  1660. return false;
  1661. }
  1662. }
  1663. if (doc === document) return true;
  1664. if (excludeSel) {
  1665. if (!this.scrollToShow(excludeSel, doc)) {
  1666. if (!loadingDiv.offsetParent && this.insert.parentNode) {
  1667. this.insertElement(loadingDiv);
  1668. }
  1669. return false;
  1670. }
  1671. }
  1672. return true;
  1673. }
  1674.  
  1675. runPageBar(pageBar) {
  1676. if (this.curSiteRule.pageBar && this.curSiteRule.pageBar !== 0) {
  1677. try {
  1678. ((typeof this.curSiteRule.pageBar === 'function') ? this.curSiteRule.pageBar : Function("pageBar",'"use strict";' + this.curSiteRule.pageBar))(pageBar);
  1679. } catch(e) {
  1680. debug(e);
  1681. }
  1682. }
  1683. }
  1684.  
  1685. runWait(cb) {
  1686. let checkEval = null, waitTime = 0;
  1687. if (this.curSiteRule.waitElement) {
  1688. checkEval = async doc => {
  1689. return await this.waitElement(doc);
  1690. };
  1691. } else if(this.curSiteRule.wait) {
  1692. if (isNaN(this.curSiteRule.wait)) {
  1693. try {
  1694. checkEval = (typeof this.curSiteRule.wait === 'function') ? this.curSiteRule.wait : new AsyncFunction("doc", '"use strict";' + this.curSiteRule.wait);
  1695. } catch(e) {
  1696. debug(e);
  1697. }
  1698. } else {
  1699. waitTime = this.curSiteRule.wait;
  1700. }
  1701. }
  1702. cb(checkEval, waitTime);
  1703. }
  1704.  
  1705. findNoNext() {
  1706. if (!this.curSiteRule || !this.curSiteRule.smart || this.curSiteRule.nextLink === 0 || this.possibleRule) return;
  1707. let self = this;
  1708. self.curSiteRule.nextLink = 0;
  1709. self.smartRules = self.smartRules.filter(item => {return item && item.url !== self.curSiteRule.url;});
  1710. self.smartRules.unshift(self.curSiteRule);
  1711. storage.setItem("smartRules", self.smartRules);
  1712. }
  1713.  
  1714. async getRule(callback) {
  1715. var href = location.href.slice(0, 500);
  1716. if (noRuleTest) {
  1717. this.curSiteRule = {};
  1718. this.curSiteRule.url = href;
  1719. this.curSiteRule.smart = true;
  1720. callback();
  1721. return;
  1722. }
  1723. if (_unsafeWindow.pagetualRule) {
  1724. this.curSiteRule = _unsafeWindow.pagetualRule;
  1725. if (!this.curSiteRule.url) this.curSiteRule.url = ".";
  1726. this.curSiteRule.isScript = true;
  1727. }
  1728. if (this.curSiteRule && this.curSiteRule.url && !this.curSiteRule.smart) {
  1729. let urlReg = new RegExp(this.curSiteRule.url, "i");
  1730. if (urlReg.test(href) && this.ruleMatch(this.curSiteRule)) {
  1731. return callback();
  1732. }
  1733. }
  1734. if (this.possibleRule) {
  1735. let urlReg = new RegExp(this.possibleRule.url, "i");
  1736. if (urlReg.test(href) && this.ruleMatch(this.possibleRule)) {
  1737. this.curSiteRule = this.possibleRule;
  1738. debug(this.curSiteRule, 'Match');
  1739. return callback();
  1740. }
  1741. }
  1742. this.curSiteRule = {};
  1743. var self = this;
  1744.  
  1745. function setRule(r) {
  1746. if (self.preSiteRule) {
  1747. href = location.href.slice(0, 500);
  1748. let urlReg = new RegExp(self.preSiteRule.url, "i");
  1749. if (urlReg.test(href) && self.ruleMatch(self.preSiteRule)) {
  1750. self.curSiteRule = self.preSiteRule;
  1751. return callback();
  1752. }
  1753. }
  1754. if (r.from === 2) {
  1755. delete r.autoLoadNum;
  1756. delete r.history;
  1757. delete r.sideController;
  1758. if (r.pageBar === 0) delete r.pageBar;
  1759. }
  1760. if (!r.smart) {
  1761. self.insert = null;
  1762. self.curSiteRule = r;
  1763. self.preSiteRule = r;
  1764. if (r.enable !== 0) debug(r, 'Match');
  1765. } else if (!self.curSiteRule || !self.curSiteRule.smart) self.curSiteRule = r;
  1766. callback();
  1767. }
  1768.  
  1769. function checkRule(r) {
  1770. if (r.from === 1 && r.url.length <= 13) return false;
  1771. let urlReg = new RegExp(r.url, "i");
  1772. if (urlReg.test(href)) {
  1773. if (!self.ruleMatchPre(r)) return false;
  1774. if (r.url.length > 15 && r.from !== 1) {
  1775. self.possibleRule = r;
  1776. }
  1777. if (r.waitElement) {
  1778. let waitTime = 500;
  1779. let checkReady = () => {
  1780. setTimeout(() => {
  1781. if (!self.waitElement(document, r.waitElement) || !self.ruleMatchReady(r)) {
  1782. checkReady();
  1783. } else {
  1784. setRule(r);
  1785. }
  1786. }, parseInt(waitTime));
  1787. };
  1788. checkReady();
  1789. debug(r, 'Wait for');
  1790. return true;
  1791. } else if (r.wait) {
  1792. let waitTime = 500, checkEval, maxCheckTimes = 50;
  1793. if (isNaN(r.wait)) {
  1794. try {
  1795. checkEval = (typeof r.wait === 'function') ? r.wait : AsyncFunction("doc",'"use strict";' + r.wait);
  1796. } catch(e) {
  1797. debug(e, 'Error when checkeval');
  1798. }
  1799. } else {
  1800. waitTime = r.wait;
  1801. }
  1802. let checkReady = () => {
  1803. if (maxCheckTimes-- <= 0) {
  1804. debug("Wait for rule ready but failed");
  1805. setRule(r);
  1806. return;
  1807. }
  1808. setTimeout(async() => {
  1809. if (!self.ruleMatchReady(r) || (checkEval && !await checkEval(document))) {
  1810. checkReady();
  1811. } else {
  1812. setRule(r);
  1813. }
  1814. }, parseInt(waitTime));
  1815. };
  1816. checkReady();
  1817. debug(r, 'Wait for');
  1818. return true;
  1819. }
  1820. if (r.pinUrl) {
  1821. setRule(r);
  1822. return true;
  1823. }
  1824. if (!self.ruleMatchReady(r)) {
  1825. return false;
  1826. }
  1827. setRule(r);
  1828. return true;
  1829. }
  1830. return false;
  1831. }
  1832.  
  1833. function checkHpRules() {
  1834. for (let i in self.hpRules) {
  1835. let rule = self.hpRules[i];
  1836. if (!rule || !rule.url || rule.smart) continue;
  1837. if (checkRule(rule)) return true;
  1838. }
  1839. return false;
  1840. }
  1841.  
  1842. function checkCustomRules() {
  1843. for (let i in self.customRules) {
  1844. let rule = self.customRules[i];
  1845. if (!rule || !rule.url) continue;
  1846. if (checkRule(rule)) return true;
  1847. }
  1848. return false;
  1849. }
  1850.  
  1851. if (rulesData.customFirst) {
  1852. if (checkCustomRules()) return;
  1853. await sleep(1);
  1854. if (checkHpRules()) return;
  1855. } else {
  1856. if (checkHpRules()) return;
  1857. await sleep(1);
  1858. if (checkCustomRules()) return;
  1859. }
  1860. await sleep(1);
  1861.  
  1862. for (let i in this.smartRules) {
  1863. let rule = this.smartRules[i];
  1864. if (!rule || !rule.url || !rule.smart) continue;
  1865. if (href === rule.url) {
  1866. setRule(rule);
  1867. return;
  1868. } else if (rule.listenUrlChange === false && href.replace(/[^\/]+$/, "") === rule.url) {
  1869. setRule(rule);
  1870. return;
  1871. }
  1872. }
  1873. let r = 0;
  1874. async function searchByTime() {
  1875. while (document.hidden) {
  1876. await sleep(1000);
  1877. }
  1878. setTimeout(() => {
  1879. let end = r + 20;
  1880. end = end > self.rules.length ? self.rules.length : end;
  1881. for (; r < end; r++) {
  1882. let rule = self.rules[r];
  1883. if (checkRule(rule)) return;
  1884. }
  1885. if (end >= self.rules.length) {
  1886. if (document.documentElement && document.documentElement.className && document.documentElement.className.indexOf && document.documentElement.className.indexOf('discourse') !== -1) {
  1887. setRule({url: href.replace(/[^\/]+$/, ""), smart: true, nextLink: 0, listenUrlChange: false});
  1888. } else {
  1889. setRule({url: href, smart: true});
  1890. }
  1891. return;
  1892. } else {
  1893. searchByTime();
  1894. }
  1895. }, 1);
  1896. }
  1897. searchByTime();
  1898. }
  1899.  
  1900. addToHpRules(instead) {
  1901. try {
  1902. if (this.curSiteRule.isScript) return;
  1903. if (!this.hpRules) this.hpRules = [];
  1904. let url = this.curSiteRule && this.curSiteRule.url, self = this;
  1905. let href = location.href.slice(0, 500);
  1906. let matchedRules = this.hpRules.filter(rule => rule != self.curSiteRule && new RegExp(rule.url, "i").test(href) && self.ruleMatch(rule));
  1907. if (url) matchedRules.unshift(this.curSiteRule);
  1908. matchedRules.sort((a, b) => {
  1909. if ((a.include || a.exclude) && (!b.include && !b.exclude)) {
  1910. return -1;
  1911. } else if ((b.include || b.exclude) && (!a.include && !a.exclude)) {
  1912. return 1;
  1913. } else {
  1914. if ((a.nextLink || a.pageElement) && (!b.nextLink && !b.pageElement)) {
  1915. return -1;
  1916. } else if ((b.nextLink || b.pageElement) && (!a.nextLink && !a.pageElement)) {
  1917. return 1;
  1918. } else {
  1919. if (a.url.length > b.url.length) {
  1920. return -1;
  1921. } else if (a.url.length < b.url.length) {
  1922. return 1;
  1923. } else {
  1924. return 0;
  1925. }
  1926. }
  1927. }
  1928. });
  1929. this.hpRules = this.hpRules.filter(item => {
  1930. return item && !matchedRules.find(rule => item.url == rule.url && JSON.stringify(item) == JSON.stringify(rule));
  1931. });
  1932. if (instead) {
  1933. if (url) {
  1934. this.hpRules.unshift(this.curSiteRule);
  1935. matchedRules = [];
  1936. }
  1937. } else {
  1938. this.hpRules = matchedRules.concat(this.hpRules);
  1939. }
  1940. if (matchedRules && matchedRules.length) this.curSiteRule = matchedRules[0];
  1941. if (this.hpRules.length > 30) {
  1942. this.hpRules.pop();
  1943. }
  1944. if (!rulesData.sort) rulesData.sort = [1];
  1945. this.hpRules.sort((a, b) => {
  1946. let aSort = -1, bSort = -1;
  1947. for (let s = 0; s < rulesData.sort.length; s++) {
  1948. if (a.from == rulesData.sort[s]) aSort = s;
  1949. if (b.from == rulesData.sort[s]) bSort = s;
  1950. if (aSort > -1 && bSort > -1) break;
  1951. }
  1952. return aSort - bSort;
  1953. });
  1954. storage.setItem("hpRules", this.hpRules);
  1955. } catch (e) {
  1956. debug(e);
  1957. }
  1958. }
  1959.  
  1960. replaceElement(doc) {
  1961. if (!doc || doc === document) return;
  1962. let replaceElementSel = this.curSiteRule.replaceElement;
  1963. if (replaceElementSel) {
  1964. if (!Array.isArray(replaceElementSel)) {
  1965. replaceElementSel = [replaceElementSel];
  1966. }
  1967. replaceElementSel.forEach(sel => {
  1968. let pageEles = getAllElements(sel, document);
  1969. let replaceEles = getAllElements(sel, doc);
  1970. for (let i = 0; i < pageEles.length; i++) {
  1971. let replaceEle = replaceEles[i];
  1972. let pageEle = pageEles[i];
  1973. if (replaceEle) {
  1974. pageEle.parentNode.replaceChild(replaceEle.cloneNode(true), pageEle);
  1975. } else break;
  1976. }
  1977. });
  1978. }
  1979. }
  1980.  
  1981. refreshByClick() {
  1982. let refreshByClickSel = this.curSiteRule.refreshByClick;
  1983. if (refreshByClickSel) {
  1984. let self = this;
  1985. if (!this.refreshByClickHandler) {
  1986. this.refreshByClickHandler = e => {
  1987. if (!self.refreshing) {
  1988. self.refreshing = true;
  1989. setTimeout(() => {
  1990. self.refreshing = false;
  1991. let checkEles = getAllElements(refreshByClickSel, document);
  1992. for (let i = 0; i < checkEles.length; i++) {
  1993. let curEle = checkEles[i];
  1994. if (curEle === e.target || curEle.contains(e.target)) {
  1995. ruleParser.urlChanged();
  1996. isPause = true;
  1997. if (!ruleParser.nextLinkHref) isLoading = false;
  1998. break;
  1999. }
  2000. }
  2001. }, 300);
  2002. }
  2003. }
  2004. }
  2005. document.removeEventListener("click", this.refreshByClickHandler);
  2006. document.addEventListener("click", this.refreshByClickHandler);
  2007. }
  2008. }
  2009.  
  2010. getValidSize(ele, win) {
  2011. if (!win) return {h: 0, w: 0};
  2012. let eleStyle = win.getComputedStyle(ele);
  2013. if (!ele.offsetParent && eleStyle.display !== "contents" && (eleStyle.position !== "fixed" || eleStyle.opacity === 0)) {
  2014. return {h: 0, w: 0};
  2015. }
  2016. if (ele.children && ele.children.length === 1 && (ele.offsetWidth === 0 || ele.offsetHeight === 0)) {
  2017. ele = ele.children[0];
  2018. }
  2019. let h = ele.scrollHeight, w;
  2020. if (eleStyle.overflow === "hidden") {
  2021. h = ele.offsetHeight;
  2022. w = ele.offsetWidth;
  2023. } else w = parseInt(ele.offsetWidth || ele.scrollWidth);
  2024. if (h === 0 && ele.parentNode && ele.parentNode.children.length === 1) {
  2025. h = ele.parentNode.scrollHeight;
  2026. }
  2027. while (h === 0 && ele.children && ele.children.length === 1) {
  2028. ele = ele.children[0];
  2029. h = ele.scrollHeight;
  2030. }
  2031. if (h === 0 && ele.children && ele.children.length) {
  2032. let maxChildSize = {h: 0}, self = this;
  2033. [].forEach.call(ele.children, el => {
  2034. let childSize = self.getValidSize(el, win);
  2035. if (childSize.h > maxChildSize.h) maxChildSize = childSize;
  2036. });
  2037. if (maxChildSize.h !== 0) return maxChildSize;
  2038. }
  2039. const maxNum = 2147483647;
  2040. let moreChild = ele.children[0], minOffsetTop = maxNum;
  2041. while (moreChild) {
  2042. if ((moreChild.offsetParent === ele || moreChild.offsetParent === ele.offsetParent)) {
  2043. let curOffsetTop = moreChild.offsetParent === ele.offsetParent ? moreChild.offsetTop - ele.offsetTop : moreChild.offsetTop;
  2044. if (curOffsetTop < minOffsetTop) {
  2045. minOffsetTop = curOffsetTop;
  2046. }
  2047. }
  2048. moreChild = moreChild.nextElementSibling;
  2049. }
  2050. if (h && minOffsetTop !== maxNum && minOffsetTop > 0) {
  2051. h -= minOffsetTop;
  2052. }
  2053. return {h: h, w: w};
  2054. }
  2055.  
  2056. checkTargetChildren(ele, curWin, articleNum, curHeight) {
  2057. let pf = false;
  2058. if (ele.parentNode) {
  2059. let paStyle = curWin.getComputedStyle(ele.parentNode);
  2060. let paDisplay = paStyle.display;
  2061. let paOverflow = paStyle.overflow;
  2062. pf = (paDisplay.indexOf('flex') !== -1 && paStyle.flexDirection.indexOf("row") === 0 && paStyle.flexWrap !== "wrap") || compareNodeName(ele.parentNode, ["ul"]) || paDisplay.indexOf('grid') !== -1 || paOverflow === "hidden";
  2063. }
  2064. let curStyle = curWin.getComputedStyle(ele);
  2065. if (ele.children.length > 1) {
  2066. if (articleNum > 1) {
  2067. return ">article";
  2068. } else {
  2069. let hasText = false;
  2070. for (let i in ele.childNodes) {
  2071. let child = ele.childNodes[i];
  2072. if (child.nodeType === 3 && child.nodeValue.trim() !== '') {
  2073. hasText = true;
  2074. break;
  2075. }
  2076. }
  2077. let gridArea = curStyle.gridArea;
  2078. if (gridArea && gridArea !== "auto" && gridArea !== "auto / auto / auto / auto") {
  2079. return ">*";
  2080. } else {
  2081. let middleChild = ele.children[parseInt(ele.children.length / 2)];
  2082. if ((curStyle.display === 'flex' && curStyle.flexDirection.indexOf("row") === 0 && curStyle.flexWrap !== "wrap") || (curStyle.float === "none" && curStyle.display !== "table-cell" && (rulesData.opacity !== 0 || hasText) && !pf)) {
  2083. return "";
  2084. } else if ((middleChild.style && middleChild.style.position === "absolute" && middleChild.style.left && middleChild.style.top) || compareNodeName(ele, ["ul"]) || curHeight === 0) {
  2085. return "";
  2086. } else {
  2087. return ">*";
  2088. }
  2089. }
  2090. }
  2091. } else if (pf || curStyle.position === "absolute") {
  2092. return ">*";
  2093. }
  2094. return "";
  2095. }
  2096.  
  2097. getPageElement(doc, curWin, dontFind) {
  2098. if (doc === document && this.docElementValid()) {
  2099. return this.docPageElement;
  2100. }
  2101. let pageElement = null;
  2102. let self = this;
  2103. let body = getBody(doc);
  2104. if (this.curSiteRule.pageElement) {
  2105. let pageElementSel = this.curSiteRule.pageElement;
  2106. if (Array && Array.isArray && Array.isArray(pageElementSel)) {
  2107. pageElementSel = pageElementSel[nextIndex < pageElementSel.length ? nextIndex : 0];
  2108. }
  2109. pageElement = getAllElements(pageElementSel, doc);
  2110. if (this.curSiteRule.smart && (!pageElement || pageElement.length === 0)) {
  2111. const childSelMatch = />\s*\*$/;
  2112. const targetChild = childSelMatch.test(pageElementSel);
  2113. if (targetChild) pageElementSel = pageElementSel.replace(childSelMatch, "");
  2114. let pageElementSelSplit = pageElementSel.split(">");
  2115. while(pageElementSelSplit && pageElementSelSplit.length > 5) {
  2116. pageElementSelSplit.shift();
  2117. let tempSel = pageElementSelSplit.join(">");
  2118. pageElement = getAllElements(tempSel, doc);
  2119. if (pageElement && pageElement.length === 1) {
  2120. if (targetChild) {
  2121. pageElement = pageElement.children;
  2122. }
  2123. this.curSiteRule.pageElement = tempSel + (targetChild ? ">*" : "");
  2124. break;
  2125. }
  2126. }
  2127. if (!pageElement || pageElement.length === 0) {
  2128. pageElementSel = pageElementSel.replace(/:nth-of-type\(\d+\)/g, "");
  2129. pageElement = getAllElements(pageElementSel, doc);
  2130. if (pageElement && pageElement.length === 1) {
  2131. if (targetChild) {
  2132. pageElement = pageElement.children;
  2133. }
  2134. this.curSiteRule.pageElement = pageElementSel + (targetChild ? ">*" : "");
  2135. }
  2136. }
  2137. }
  2138. if (this.curSiteRule.smart && pageElement && pageElement.length && curWin && curWin !== _unsafeWindow) {
  2139. if (pageElement.length === 1 && !pageElement[0].src && pageElement[0].innerHTML.trim() === "") {
  2140. pageElement = null;
  2141. } else {
  2142. let parent = pageElement[0].parentNode;
  2143. let loading = parent.querySelector('[class*=loading]');
  2144. if (loading && loading.offsetParent && loading.offsetHeight > parent.offsetHeight>>2) {
  2145. pageElement = null;
  2146. }
  2147. }
  2148. }
  2149. }
  2150. if (pageElement && pageElement.length === 1 && pageElement[0].style.display === 'none') {
  2151. pageElement = [body];
  2152. }
  2153. if (this.curSiteRule.smart && pageElement && pageElement.length > 0 && compareNodeName(pageElement[0], ["tr"])) {
  2154. let mainTr = this.insert.parentNode.querySelectorAll('tr'), mainTdNum = 0, newTdNum = 0;
  2155. mainTr = mainTr[mainTr.length - 1];
  2156. [].forEach.call(mainTr.children, el => {
  2157. if (compareNodeName(el, ["td", "th"])) {
  2158. mainTdNum += el.colSpan || 1;
  2159. }
  2160. });
  2161. [].forEach.call(pageElement[0].children, el => {
  2162. if (compareNodeName(el, ["td", "th"])) {
  2163. newTdNum += el.colSpan || 1;
  2164. }
  2165. });
  2166. if (mainTdNum !== newTdNum) {
  2167. this.curSiteRule.pageElement = this.curSiteRule.pageElement.replace(/> *table.*/, ">table");
  2168. this.getInsert(true);
  2169. return this.getPageElement(doc, curWin, dontFind);
  2170. }
  2171. }
  2172. if ((this.curSiteRule.smart || !this.curSiteRule.pageElement) && (!pageElement || pageElement.length == 0) && curWin && !dontFind) {
  2173. if (!body) return null;
  2174. let bodyHeight = parseInt(body.offsetHeight || body.scrollHeight);
  2175. let curHeight = bodyHeight, curWidth = 0;
  2176. let windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2177. let windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2178. let needCheckNext = (doc == document && this.initNext), nextLeftPos = 0;
  2179. if (needCheckNext && this.initNext.getBoundingClientRect) {
  2180. nextLeftPos = this.initNext.getBoundingClientRect().left;
  2181. }
  2182. function checkElement(ele) {
  2183. if (compareNodeName(ele, ["pre", "code"])) {
  2184. self.curSiteRule.pageElement = geneSelector(ele.parentNode);
  2185. debug(self.curSiteRule.pageElement, 'Page element');
  2186. return [ele.parentNode];
  2187. }
  2188. if (ele.children && ele.children.length === 1) {
  2189. let hasText = false;
  2190. for (let i in ele.childNodes) {
  2191. let child = ele.childNodes[i];
  2192. if (child.nodeType === 3 && child.nodeValue.trim() !== '') {
  2193. hasText = true;
  2194. break;
  2195. }
  2196. }
  2197. if (!hasText) {
  2198. ele = ele.children[0];
  2199. let validSize = self.getValidSize(ele, curWin);
  2200. curHeight = validSize.h;
  2201. curWidth = validSize.w;
  2202. }
  2203. }
  2204. if (compareNodeName(ele, ["picture"]) || !ele.innerText || ele.innerText.trim() === '') {
  2205. self.curSiteRule.pageElement = geneSelector(ele.parentNode) + ">" + ele.nodeName.toLowerCase();
  2206. debug(self.curSiteRule.pageElement, 'Page element');
  2207. let eles = [];
  2208. for (let i = 0; i < ele.parentNode.children.length; i++) {
  2209. let curNode = ele.parentNode.children[i];
  2210. if (curNode.nodeName === ele.nodeName && curNode.id === ele.id && curNode.className === ele.className) {
  2211. eles.push(curNode);
  2212. }
  2213. }
  2214. return eles;
  2215. }
  2216. if (compareNodeName(ele, ["form"]) && ele.parentNode !== getBody(document)) {
  2217. self.curSiteRule.pageElement = geneSelector(ele) + ">*";
  2218. debug(self.curSiteRule.pageElement, 'Page element');
  2219. return ele.children;
  2220. }
  2221. if (ele.children.length === 0 && !self.curSiteRule.pageElement) {
  2222. if (compareNodeName(ele.parentNode, ["p"])) ele = ele.parentNode;
  2223. self.curSiteRule.pageElement = geneSelector(ele.parentNode) + ">" + ele.nodeName.toLowerCase();
  2224. debug(self.curSiteRule.pageElement, 'Page element');
  2225. return getAllElements(self.curSiteRule.pageElement, doc);
  2226. }
  2227. let i, minHeight = curHeight * 0.52, curMaxEle = null, curMaxArea = 0, minWidth = Math.min(curWidth * 0.38, 500);
  2228. let isHori, preOffsetTop = -1;
  2229. let articleNum = 0;
  2230. for (i = 0; i < ele.children.length; i++) {
  2231. let curNode = ele.children[i];
  2232. if (ele !== body && /^H\d$/i.test(curNode.nodeName) && curNode.offsetParent) {
  2233. curMaxEle = null;
  2234. break;
  2235. }
  2236. if (compareNodeName(curNode, ["canvas", "nav"])) continue;
  2237. let curStyle = curWin.getComputedStyle(curNode);
  2238. if (!curNode.offsetParent && curStyle.display !== "contents" && (curStyle.position !== "fixed" || curStyle.opacity === 0)) {
  2239. continue;
  2240. }
  2241. if (!compareNodeName(curNode, ["img"]) && curNode.querySelector('img') === null && /^\s*$/.test(curNode.innerText)) continue;
  2242. if (needCheckNext && !curNode.contains(self.initNext) && getElementTop(curNode) > windowHeight) {
  2243. continue;
  2244. }
  2245. if (compareNodeName(curNode, ["article"])) articleNum++;
  2246. let validSize = self.getValidSize(curNode, curWin);
  2247. let h = validSize.h;
  2248. let w = validSize.w;
  2249. if (isNaN(h) || isNaN(w) || !h || !w) continue;
  2250. isHori = Math.abs(preOffsetTop - curNode.offsetTop) <= 20 ? true : (preOffsetTop === -1 && curNode.nextElementSibling && curNode.nextElementSibling.offsetTop === curNode.offsetTop);
  2251. if (isHori && h <= 50) continue;
  2252. /*if (isHori && nextLeftPos && curMaxEle && curWidth > 500 && curHeight > 500) {
  2253. let curRect = curNode.getBoundingClientRect();
  2254. if (curRect.left > windowWidth>>2 && curRect.left <= nextLeftPos && curRect.right > nextLeftPos) {
  2255. continue;
  2256. }
  2257. }*/
  2258. let a = h * w, moreChild = curNode.children[0];
  2259. while (moreChild) {
  2260. let validSize = self.getValidSize(moreChild, curWin);
  2261. let ch = validSize.h;
  2262. let cw = validSize.w;
  2263. if (h < ch) {
  2264. h = ch;
  2265. }
  2266. if (moreChild.innerText !== "" && ch && cw) {
  2267. a += ch * cw;
  2268. }
  2269. moreChild = moreChild.nextElementSibling;
  2270. }
  2271. let isMax = false;
  2272. if (isHori) {
  2273. if (curMaxEle) {
  2274. if (w > curWidth && (windowWidth>>1) > curWidth) {
  2275. isMax = true;
  2276. } else if (w + 300 > curWidth && a > curMaxArea) {
  2277. isMax = true;
  2278. }
  2279. }
  2280. } else {
  2281. if (curMaxEle && curMaxEle.offsetParent === curNode.offsetParent && curMaxEle.offsetTop === curNode.offsetTop) {
  2282. if (curMaxArea * 2 > a) continue;
  2283. }
  2284. isMax = curMaxArea < a;
  2285. }
  2286. if (curMaxEle === null || isMax) {
  2287. if (isHori) {
  2288. if (w < minWidth) {
  2289. continue;
  2290. }
  2291. }
  2292. if (h < minHeight) {
  2293. if (!needCheckNext || h < (minHeight>>1)) {
  2294. continue;
  2295. }
  2296. if (!ele.contains(self.initNext)) {
  2297. continue;
  2298. } else if (!curNode.contains(self.initNext) && h < curHeight >> 1) {
  2299. continue;
  2300. }
  2301. }
  2302. curHeight = h;
  2303. curMaxArea = a;
  2304. curWidth = w;
  2305. curMaxEle = curNode;
  2306. preOffsetTop = curNode.offsetTop;
  2307. }
  2308. }
  2309. let curHeightPercent = curHeight / bodyHeight;
  2310. if (curMaxEle && curHeightPercent <= 0.18) {
  2311. let article;
  2312. for (let i = 0; i < mainSel.length; i++) {
  2313. article = doc.querySelectorAll(mainSel[i]);
  2314. if (article && article.length === 1) break;
  2315. }
  2316. if (article && article.length === 1) {
  2317. article = article[0];
  2318. let childrenEnd = self.checkTargetChildren(article, curWin, articleNum, curHeight);
  2319. self.curSiteRule.pageElement = article.nodeName.toLowerCase() + (article.id ? "#" + article.id : "") + (article.className ? "." + article.className.replace(/ /g, ".") : "") + childrenEnd;
  2320. debug(self.curSiteRule.pageElement, 'Page element');
  2321. return childrenEnd ? article.children : [article];
  2322. }
  2323. curMaxEle = null;
  2324. }
  2325. if (curMaxEle && (!compareNodeName(curMaxEle, ["ul"]) || curHeightPercent > 0.8)) {
  2326. let sameClassNum = 0, hasDifferent = false;
  2327. if (curMaxEle.className) {
  2328. for(i = 0; i < ele.children.length; i++) {
  2329. let curNode = ele.children[i];
  2330. if (curMaxEle !== curNode && curNode.style.display !== 'none' && curMaxEle.className === curNode.className && curMaxEle.nodeName === curNode.nodeName){
  2331. sameClassNum++;
  2332. } else if (curMaxEle.className !== curNode.className) {
  2333. hasDifferent = true;
  2334. }
  2335. }
  2336. }
  2337. if (sameClassNum < 2 || (sameClassNum < 5 && hasDifferent)) {
  2338. return checkElement(curMaxEle);
  2339. }
  2340. }
  2341. if (ele.nodeName === "APP-ROOT") {
  2342. isPause = true;
  2343. debug(ele, "Angular root");
  2344. return null;
  2345. }
  2346. while (compareNodeName(ele, ["p", "br", "td"])) {
  2347. ele = ele.parentNode;
  2348. }
  2349. if (compareNodeName(ele, ["tbody"])) {
  2350. self.curSiteRule.pageElement = geneSelector(ele) + ">*";
  2351. if (ele.children.length > 0 && ele.children[0].querySelector("th")) {
  2352. self.curSiteRule.pageElement += ":not(:first-child)";
  2353. }
  2354. debug(self.curSiteRule.pageElement, 'Page element');
  2355. return ele.children;
  2356. }
  2357. let imgs = ele.querySelectorAll('img');
  2358. if (imgs.length === 1) {
  2359. let img = imgs[0];
  2360. if (img.offsetWidth > ele.offsetWidth / 3 * 2 && img.offsetHeight > ele.offsetHeight / 2) {
  2361. ele = img;
  2362. }
  2363. }
  2364. let childrenEnd = self.checkTargetChildren(ele, curWin, articleNum, curHeight);
  2365. if (childrenEnd) {
  2366. self.curSiteRule.pageElement = geneSelector(ele) + childrenEnd;
  2367. ele = ele.children;
  2368. } else {
  2369. if (ele.scrollHeight === 0 && ele.parentNode.children.length === 1) {
  2370. ele = ele.parentNode;
  2371. }
  2372. self.curSiteRule.pageElement = geneSelector(ele);
  2373. ele = [ele];
  2374. }
  2375. debug(self.curSiteRule.pageElement, 'Page element');
  2376. return ele;
  2377. }
  2378. pageElement = checkElement(body);
  2379. if (doc === document && pageElement && pageElement.length > 0 && self.initNext) {
  2380. let posEle = pageElement[pageElement.length - 1];
  2381. while (posEle && !posEle.offsetParent) {
  2382. posEle = posEle.previousElementSibling || posEle.parentNode;
  2383. }
  2384. if (posEle && posEle.lastElementChild) {
  2385. if (posEle.scrollHeight === 0) posEle = posEle.lastElementChild;
  2386. else if (posEle.lastElementChild.offsetTop > 500) {
  2387. posEle = posEle.lastElementChild;
  2388. }
  2389. }
  2390. let lastBottom = forceState !== 2 && forceState !== 3 && posEle && getElementBottom(posEle);
  2391. if (lastBottom && getElementTop(self.initNext) - lastBottom > 1000) {
  2392. debug("Stop as too long between next & page element, try to enable Force-Join mode.");
  2393. isPause = true;
  2394. pageElement = [];
  2395. sideController.remove();
  2396. } else {
  2397. if (pageElement.length === 1 && compareNodeName(pageElement[0], ["img"])) {
  2398. self.curSiteRule.pageBar = 0;
  2399. }
  2400. }
  2401. }
  2402. //if(pageElement)this.saveCurSiteRule();
  2403. }
  2404.  
  2405. if (doc !== document) {
  2406. this.setPageElementCss(pageElement);
  2407. this.lazyImgAction(pageElement, doc);
  2408. this.filterEles(doc, pageElement);
  2409. } else if (!this.docPageElement) {
  2410. this.setPageElementCss(pageElement, true);
  2411. this.docPageElement = pageElement;
  2412. this.filterEles(doc, pageElement);
  2413. if (this.nextLinkHref) {
  2414. this.openInNewTab(pageElement);
  2415. }
  2416. }
  2417. return pageElement;
  2418. }
  2419.  
  2420. showAddedElements() {
  2421. if (!this.addedElementsIsHide) return;
  2422. if (this.addedElePool && this.addedElePool.length) {
  2423. this.addedElePool.forEach(ele => {
  2424. ele.classList && ele.classList.remove("pagetual-hide");
  2425. });
  2426. }
  2427. this.addedElementsIsHide = false;
  2428. }
  2429.  
  2430. hideAddedElements() {
  2431. if (this.addedElePool && this.addedElePool.length) {
  2432. this.addedElePool.forEach(ele => {
  2433. ele.classList && ele.classList.add("pagetual-hide");
  2434. });
  2435. }
  2436. this.addedElementsIsHide = true;
  2437. }
  2438.  
  2439. toggleAddedElements() {
  2440. if (this.addedElementsIsHide) {
  2441. this.showAddedElements();
  2442. } else {
  2443. this.hideAddedElements();
  2444. }
  2445. }
  2446.  
  2447. changeVisibility() {
  2448. let contentVisibility = this.curSiteRule.contentVisibility || rulesData.contentVisibility;
  2449. if (!contentVisibility) return;
  2450. if (!this.changingVisibility) {
  2451. clearTimeout(this.changeVisibilityTimer);
  2452. this.changeVisibilityTimer = setTimeout(() => {
  2453. this.changingVisibility = true;
  2454. this.changeVisibility();
  2455. }, 300);
  2456. return;
  2457. }
  2458. this.changingVisibility = false;
  2459. if (!this.visibilityItems || !this.visibilityItems.length || this.visibleIndex < 0) return;
  2460. let tempIndex = this.visibleIndex, findVisible = false, lastVisible = 0;
  2461. let viewPortHeight = window.innerHeight || document.documentElement.clientHeight || getBody(document).clientHeight;
  2462. let checkItem = this.visibilityItems[tempIndex];
  2463. while(checkItem) {
  2464. if (checkItem.offsetParent) {
  2465. if (!checkItem.style.containIntrinsicSize) return;
  2466. let clientRect = checkItem.getBoundingClientRect();
  2467. let top = clientRect && clientRect.top;
  2468. let bottom = clientRect && clientRect.bottom;
  2469. if (bottom > 0 && top < viewPortHeight) {
  2470. if (!findVisible) {
  2471. findVisible = true;
  2472. lastVisible = tempIndex;
  2473. }
  2474. checkItem.style.contentVisibility = "visible";
  2475. } else {
  2476. if (top < viewPortHeight && checkItem.style.contentVisibility === "auto") {
  2477. break;
  2478. } else checkItem.style.contentVisibility = "auto";
  2479. }
  2480. }
  2481. if (tempIndex === 0) break;
  2482. tempIndex--;
  2483. checkItem = this.visibilityItems[tempIndex];
  2484. }
  2485. tempIndex = this.visibleIndex + 1;
  2486. if (findVisible) {
  2487. this.visibleIndex = lastVisible;
  2488. }
  2489. checkItem = this.visibilityItems[tempIndex];
  2490. while(checkItem) {
  2491. if (checkItem.offsetParent) {
  2492. if (!checkItem.style.containIntrinsicSize) return;
  2493. let clientRect = checkItem.getBoundingClientRect();
  2494. let top = clientRect && clientRect.top;
  2495. let bottom = clientRect && clientRect.bottom;
  2496. if (bottom > 0 && top < viewPortHeight) {
  2497. findVisible = true;
  2498. lastVisible = tempIndex;
  2499. checkItem.style.contentVisibility = "visible";
  2500. } else {
  2501. if (findVisible && checkItem.style.contentVisibility === "auto") {
  2502. break;
  2503. } else checkItem.style.contentVisibility = "auto";
  2504. }
  2505. }
  2506. if (tempIndex === this.visibilityItems.length - 1) break;
  2507. tempIndex++;
  2508. checkItem = this.visibilityItems[tempIndex];
  2509. }
  2510. if (findVisible) {
  2511. this.visibleIndex = lastVisible;
  2512. }
  2513. }
  2514.  
  2515. setPageElementCss(pageElement, init) {
  2516. let self = this;
  2517. if (pageElement && pageElement.length > 0) {
  2518. let pageElementCss = this.curSiteRule.pageElementCss || rulesData.pageElementCss;
  2519. if (!pageElementCss && init && !this.nextLinkHref) return;
  2520. let contentVisibility = this.curSiteRule.contentVisibility || rulesData.contentVisibility;
  2521. if (!contentVisibility && !pageElementCss) return;
  2522. [].forEach.call(pageElement, (ele, i) => {
  2523. if (!compareNodeName(ele, ["link", "meta", "style", "script"])) {
  2524. if (pageElementCss) {
  2525. if (pageElementCss !== '0' && !ele.dataset.pagetualPageElement) {
  2526. ele.style.cssText = (ele.style.cssText || '') + pageElementCss;
  2527. ele.dataset.pagetualPageElement = 1;
  2528. }
  2529. }
  2530. if (contentVisibility) {
  2531. ele.style.containIntrinsicSize = `auto ${ele.offsetHeight || self.preVisibleHeight || 100}px`;
  2532. if (ele.style.containIntrinsicSize) {
  2533. if (ele.offsetHeight) self.preVisibleHeight = ele.offsetHeight;
  2534. if (init) {
  2535. ele.style.contentVisibility = "visible";
  2536. self.visibilityItems.push(ele);
  2537. self.visibleIndex++;
  2538. } else {
  2539. ele.style.contentVisibility = emuIframe ? "visible" : "auto";
  2540. }
  2541. }
  2542. }
  2543. }
  2544. });
  2545. }
  2546. }
  2547.  
  2548. clearAddedElements() {
  2549. if (this.addedElePool && this.addedElePool.length) {
  2550. this.addedElePool.forEach(ele => {
  2551. if (ele.parentNode) ele.parentNode.removeChild(ele);
  2552. });
  2553. }
  2554. this.addedElePool = [];
  2555. sideController.remove();
  2556. }
  2557.  
  2558. linkHasHref(link) {
  2559. return link && link.href && link.href.replace && !this.hrefIsJs(link.href);
  2560. }
  2561.  
  2562. hrefIsJs(href) {
  2563. return /^(javascript|#|$)/.test(href.trim().replace("#p{", "").replace(location.href, ""));
  2564. }
  2565.  
  2566. async querySelectorList(source, list, defaultView) {
  2567. for (let i = 0; i < list.length; i++) {
  2568. await sleep(1);
  2569. let sel = list[i];
  2570. let result = getAllElements(sel, source);
  2571. if (result.length > 0) {
  2572. if (defaultView) {
  2573. for (let i = result.length - 1; i >= 0; i--) {
  2574. let ele = result[i];
  2575. if (isVisible(ele, defaultView)) return ele;
  2576. }
  2577. }
  2578. return result[result.length - 1];
  2579. }
  2580. }
  2581. return null;
  2582. }
  2583.  
  2584. verifyElement(ele) {
  2585. let verifyHandler = e => {
  2586. if (e.nodeType == 9) return true;
  2587. if (e.style.display === "none" || e.getAttribute("aria-disabled") === "true") {
  2588. return false;
  2589. }
  2590. if (e.className) {
  2591. if (/slick|slide|carousel|gallery|disabled\s*$/i.test(e.className)) {
  2592. return false;
  2593. } else if (e.classList) {
  2594. if (e.classList.contains('disabled') || e.classList.contains('active')) {
  2595. return false;
  2596. }
  2597. }
  2598. }
  2599. let ariaLabel = e.getAttribute("aria-label");
  2600. if (ariaLabel && /slick|slide|carousel|gallery/i.test(ariaLabel)) return false;
  2601. return true;
  2602. };
  2603. if (!ele) return false;
  2604. let i = 0;
  2605. while (ele && i++ < 6) {
  2606. if (!verifyHandler(ele)) return false;
  2607. ele = ele.parentNode;
  2608. }
  2609. return true;
  2610. }
  2611.  
  2612. async getPage(doc, exist) {
  2613. let body = getBody(doc);
  2614. let canSave = false;//發現頁碼選擇器在其他頁對不上,還是別保存了
  2615. let url = this.curUrl.slice(0, 250).replace("index.php?", "?");
  2616. let _url = url.replace(/\.s?html?$/i, "").toLowerCase();
  2617. let pageNum = 1, preStr = "", afterStr = "";
  2618. let pageTwoReg = /^[\/\?&]?[_-]?(p|page)?=?\/?2(\/[^\/]*$|\?|&|$)/i;
  2619. let pageMatch1 = url.match(/(.*[\?&]p(?:age)?=)(\d+)($|[#&].*)/i);
  2620. let doubtTextReg = /^\s*(»|>>)\s*$/;
  2621. if (pageMatch1) {
  2622. preStr = pageMatch1[1];
  2623. pageNum = parseInt(pageMatch1[2]);
  2624. afterStr = pageMatch1[3];
  2625. } else {
  2626. let pageMatch2 = url.match(/(.*[a-z\/\-_](?:p|page)?\/?)(\d+)(\.s?html?$|\/?$)/i);
  2627. if (pageMatch2) {
  2628. preStr = pageMatch2[1];
  2629. pageNum = parseInt(pageMatch2[2]);
  2630. afterStr = pageMatch2[3];
  2631. if (/^\/?$/.test(afterStr) && !/(p(age)?|_|\-|\/)$/.test(preStr)) {
  2632. preStr = "";
  2633. afterStr = "";
  2634. }
  2635. }
  2636. }
  2637. if (pageNum > 999) {
  2638. pageNum = 1;
  2639. preStr = "";
  2640. afterStr = "";
  2641. }
  2642. let curPage = doc, i, cur, jsNext;
  2643. let next1, next2, next3, next4, nextJs1, nextJs2;
  2644. let selectorList = [
  2645. ".page-next>a",
  2646. "a.next_page",
  2647. "#next_page",
  2648. ".curPage+a",
  2649. ".nextPage",
  2650. ".pagination-next>a",
  2651. "a[data-pagination=next]",
  2652. ".pageButtonsCurrent+a",
  2653. "a[class*=nextpage]",
  2654. "li.page-current+li>a",
  2655. "[class^=pag] a[rel=next]",
  2656. "[class^=Pag] [aria-label=next]",
  2657. "[aria-label='Next Page']",
  2658. "[aria-label='Next page']",
  2659. "[aria-label='next page']",
  2660. ".pagination-nav__item--next>a",
  2661. "a.pageright",
  2662. ".page-numbers.current+a",
  2663. "a.page-numbers.next",
  2664. "body [class*=pagination] li.active+span+li>a",
  2665. "body [class*=pagination] li.active+li>a",
  2666. "body [class^=pag] .current+a",
  2667. ".page_current+a",
  2668. "input[value='next']",
  2669. "input[value='Next page']",
  2670. "input[value='下一页']",
  2671. "input[value='下一頁']",
  2672. "a#pb_next",
  2673. "a#rightFix",
  2674. "a#btnPreGn",
  2675. "a.page-next",
  2676. "a.pages-next",
  2677. "a.page.right",
  2678. ".paging>.active+.item",
  2679. "a#next",
  2680. ".next>a",
  2681. ".next>button",
  2682. "a[alt=next]",
  2683. ".pg_area>em+a",
  2684. "button.next:not([disabled])",
  2685. ".btn_next:not([disabled])",
  2686. ".btn-next:not([disabled])",
  2687. "a#linkNext",
  2688. "body a[class*=page__next]",
  2689. "body [class*=pager]>a.next",
  2690. "body [class*=pagination-next]>a",
  2691. "body [class*=pagination-next]>button",
  2692. "body [class*=page--current]+li>a",
  2693. "body [class*=Pages]>.curr+a",
  2694. "body [class*=pagination] [class*=next]",
  2695. ".page>em+a",
  2696. "[name*=nextPage]",
  2697. '//button[contains(@class, "Page")][text()="Next"]',
  2698. '//button[contains(@class, "page")][text()="next"]'
  2699. ];
  2700. let next = await this.querySelectorList(body, selectorList, doc.defaultView);
  2701. if (!next) {
  2702. await sleep(1);
  2703. let nexts = body.querySelectorAll("a.next");
  2704. const prevReg = /^\s*([上前首尾]|previous)/i;
  2705. for (i = 0; i < nexts.length; i++) {
  2706. let n = nexts[i];
  2707. if (this.verifyElement(n) && this.linkHasHref(n) && !prevReg.test(n.innerText.trim())) {
  2708. next = n;
  2709. break;
  2710. }
  2711. }
  2712. }
  2713. if (next) {
  2714. let innerText = next.innerText;
  2715. let isJs = !this.linkHasHref(next);
  2716. if (innerText && nextTextReg2.test(innerText.trim())) {
  2717. if (isJs) {
  2718. if (this.verifyElement(next)) {
  2719. nextJs2 = next;
  2720. }
  2721. } else {
  2722. next2 = next;
  2723. }
  2724. next = null;
  2725. } else {
  2726. if (isJs) {
  2727. if (this.verifyElement(next)) {
  2728. jsNext = next;
  2729. }
  2730. next = null;
  2731. }
  2732. }
  2733. }
  2734. if (!next) {
  2735. await sleep(1);
  2736. next = body.querySelector("a.curr+a") ||
  2737. body.querySelector("div.wp-pagenavi>span.current+a,div.page-nav>span.current+a,div.article-paging>span+a") ||
  2738. body.querySelector(".number>ul>li.active+li>a,.pager a.next");
  2739. }
  2740. if (!next) {
  2741. await sleep(1);
  2742. let pageDiv = body.querySelector(".pages>ul,.page_no>ul");
  2743. if (pageDiv) {
  2744. cur = pageDiv.querySelector("li>b,li>strong");
  2745. if (cur) next = cur.parentNode.nextElementSibling;
  2746. if (next) next = next.querySelector("a");
  2747. }
  2748. }
  2749. if (!next) {
  2750. await sleep(1);
  2751. next = body.querySelector(".pages>a[href='javascript:;']+a");
  2752. if (next && (next.href === "javascript:;" || next.getAttribute("href") === "#")) next = null;
  2753. }
  2754. if (!next) {
  2755. await sleep(1);
  2756. let pageDiv = body.querySelector(".pagination");
  2757. if (pageDiv) {
  2758. cur = pageDiv.querySelector("[class*=current],.page-selected");
  2759. if (cur) next = cur.parentNode.nextElementSibling;
  2760. if (next) next = next.querySelector("a");
  2761. }
  2762. }
  2763. if (!next) {
  2764. await sleep(1);
  2765. cur = body.querySelector(".paginator td strong");
  2766. if (cur) {
  2767. while (cur && !compareNodeName(cur, ["td"])) {
  2768. cur = cur.parentNode;
  2769. }
  2770. next = cur && cur.nextElementSibling;
  2771. if (next) next = next.querySelector("a");
  2772. }
  2773. }
  2774. if (!next) {
  2775. await sleep(1);
  2776. let pageDivs = body.querySelectorAll("[class*=pagination],[class*=Pagination]");
  2777. if (pageDivs && pageDivs.length) {
  2778. for (let i = pageDivs.length - 1; i >= 0; i--) {
  2779. let p = pageDivs[i];
  2780. if (/(next\s*(»|>>|>|›|→|❯)?|&gt;|▶|>|›|→|❯)/i.test(p.title || p.value || '')) {
  2781. next = p.querySelector("a,button,[type='button']") || p;
  2782. break;
  2783. } else if (/^(next\s*(»|>>|>|›|→|❯)?|&gt;|▶|>|›|→|❯)$/i.test((p.innerText || '').trim())) {
  2784. next = p.querySelector("a,button,[type='button']") || p;
  2785. break;
  2786. }
  2787. }
  2788. if (next && !this.linkHasHref(next)) {
  2789. if (!jsNext) jsNext = next;
  2790. next = null;
  2791. }
  2792. }
  2793. }
  2794. if (!next) {
  2795. let isApp = !!body.querySelector("main#app");
  2796. let aTags = body.querySelectorAll("a,button,[type='button'],.btn-action");
  2797. for (i = aTags.length - 1; i >= 0; i--) {
  2798. if (next1) break;
  2799. if (i % 100 === 0) {
  2800. await sleep(1);
  2801. }
  2802. let aTag = aTags[i];
  2803. let title = aTag.title || "";
  2804. let value = aTag.value || "";
  2805. let innerText = aTag.innerText || "";
  2806. if (innerText === "" || (title !== "" && title.length < innerText.length)) {
  2807. innerText = title;
  2808. }
  2809. if (innerText === "" || (value !== "" && value.length < innerText.length)) {
  2810. innerText = value;
  2811. }
  2812. if (innerText !== "") {
  2813. if (innerText === "§") continue;
  2814. innerText = innerText.trim();
  2815. if (innerText.length > 80) continue;
  2816. }
  2817. if (!this.verifyElement(aTag)) continue;
  2818. if (aTag.dataset && aTag.dataset.preview) continue;
  2819. let availableHref = aTag.href && aTag.href.length < 250 && !/^(javascript:|#)/.test(aTag.href);
  2820. if (availableHref && /next\-?(page)?$|\/video\/|\/vod\/play\//i.test(aTag.href)) continue;
  2821. if (compareNodeName(aTag.parentNode, ["blockquote"])) continue;
  2822. if (aTag.previousElementSibling && /\b(play|volume)\b/.test(aTag.previousElementSibling.className)) continue;
  2823. if (aTag.nextElementSibling && /\b(play|volume)\b/.test(aTag.nextElementSibling.className)) continue;
  2824. let isJs = !this.linkHasHref(aTag);
  2825. if (exist && isJs && !aTag.offsetParent) continue;
  2826. if (innerText) {
  2827. innerText = innerText.split(/\n/)[0].replace(/ /g, '');
  2828. if (isJs && /^(»|>>|>|›|→|❯)$/.test(innerText)) continue;
  2829. if (innerText && innerText.length <= 25) {
  2830. if (!next1) {
  2831. if (nextTextReg1.test(innerText)) {
  2832. if (isJs) {
  2833. if (!nextJs1) nextJs1 = aTag;
  2834. } else {
  2835. next1 = aTag;
  2836. }
  2837. }
  2838. }
  2839. if (!next4) {
  2840. if (!next2) {
  2841. if (nextTextReg2.test(innerText) || /nextpage|pager\-older|next.chap/i.test(aTag.className) || /^(»|>>)$/.test(innerText)) {
  2842. if (isJs) {
  2843. if (!nextJs2) nextJs2 = aTag;
  2844. } else {
  2845. next2 = aTag;
  2846. }
  2847. }
  2848. }
  2849. if (!isApp && !next3 && !isJs) {
  2850. if (/^(next\s*(»|>>|>|›|→|❯)?|&gt;|▶|>|›|→|❯)$/i.test(aTag.textContent) && aTag.parentNode.hasAttribute && !aTag.parentNode.hasAttribute("jsaction")) {
  2851. next3 = aTag;
  2852. }
  2853. }
  2854. }
  2855. }
  2856. }
  2857. if (isJs) continue;
  2858. if (!next4) {
  2859. let prevEle = aTag.previousElementSibling;
  2860. if (prevEle && compareNodeName(prevEle, ["b", "span", "strong"])) {
  2861. if (/^\d+$/.test(aTag.innerText.trim()) && /^\d+$/.test(prevEle.innerText.trim()) && parseInt(aTag.innerText) === parseInt(prevEle.innerText) + 1) {
  2862. next4 = aTag;
  2863. }
  2864. }
  2865. }
  2866. if (urlWillChange) continue;
  2867. if (!next4 && availableHref) {
  2868. let aHref = aTag.href.indexOf("http") === 0 ? aTag.href : this.canonicalUri(aTag.href);
  2869. if (aHref.indexOf(location.hostname) === -1) continue;
  2870. let _aHref = aHref.replace("?&", "?").replace("index.php?", "?");
  2871. if (preStr || afterStr) {
  2872. let _aHrefTrim = _aHref;
  2873. if (preStr) _aHrefTrim = _aHrefTrim.replace(preStr, "");
  2874. if (afterStr) _aHrefTrim = _aHrefTrim.replace(afterStr, "");
  2875. if (_aHrefTrim == pageNum + 1) {
  2876. next4 = aTag;
  2877. }
  2878. } else if (this.curUrl !== aHref) {
  2879. _aHref = _aHref.replace(/\.s?html?$/i, "").toLowerCase();
  2880. if (_aHref.indexOf(_url) !== -1) {
  2881. let pageTwoMatch = _aHref.replace(_url, "").match(pageTwoReg);
  2882. if (pageTwoMatch) {
  2883. afterStr = pageTwoMatch[2];
  2884. next4 = aTag;
  2885. }
  2886. }
  2887. }
  2888. if (next4 && !/page/.test(next4.href)) {
  2889. let curHref = next4.getAttribute("href");
  2890. let curPageReg = new RegExp("(.*)" + (pageNum + 1) + afterStr.replace(/([\.\?])/g, '\\$1'));
  2891. let otherPageHref = curHref.replace(curPageReg, `$1${pageNum}${afterStr}`);
  2892. let otherPageEle = body.querySelector(`a[href='${otherPageHref}']`);
  2893. if (!otherPageEle) {
  2894. otherPageHref = curHref.replace(curPageReg, `$1${pageNum + 2}${afterStr}`);
  2895. otherPageEle = body.querySelector(`a[href='${otherPageHref}']`);
  2896. }
  2897. if (otherPageEle) {
  2898. let parent = otherPageEle.parentNode;
  2899. if (parent && parent.parentNode) {
  2900. parent = parent.parentNode;
  2901. if (parent.parentNode) {
  2902. parent = parent.parentNode;
  2903. }
  2904. }
  2905. if (parent && parent.contains(next4) && !/^\d+$/.test(next4.innerText.trim())) {
  2906. next4 = null;
  2907. }
  2908. }
  2909. }
  2910. }
  2911. }
  2912. if (next2 && doubtTextReg.test(next2.innerText)) {
  2913. next2 = this.verifyNext(next2, doc, false);
  2914. }
  2915. if (nextJs2 && doubtTextReg.test(nextJs2.innerText)) {
  2916. nextJs2 = this.verifyNext(nextJs2, doc, true);
  2917. }
  2918. if (next3) {
  2919. next3 = this.verifyNext(next3, doc, false);
  2920. }
  2921. }
  2922. if (!next) next = next1 || next4 || next3 || next2;
  2923. if (!next && location.pathname + location.search !== "/") {
  2924. next = jsNext || nextJs1 || nextJs2;
  2925. if (next && next.parentNode.className && next.parentNode.className.indexOf && next.parentNode.className.indexOf('tab') !== -1) next = null;
  2926. }
  2927. if (next && next.classList && (next.classList.contains("results-more") || next.classList.contains("no"))) next = null;
  2928. if (next && next.hasAttribute && next.hasAttribute("disabled")) next = null;
  2929. if (next && next.parentNode.href && compareNodeName(next.parentNode, ["a"])) next = next.parentNode;
  2930. return {next:next, canSave:canSave};
  2931. }
  2932.  
  2933. verifyNext(next, doc, isJs) {
  2934. if (!next) return null;
  2935. if (!isJs) {
  2936. let href = next.getAttribute("href");
  2937. if (href && !/\d/.test(next.getAttribute("href"))) {
  2938. return null;
  2939. }
  2940. }
  2941. if (next.previousElementSibling && compareNodeName(next.previousElementSibling, ["br"])) return null;
  2942. let eles = [];
  2943. if (next.innerText && next.innerText.indexOf("\n") === -1) {
  2944. eles = getAllElements(`//${next.nodeName}[text()='${next.innerText}']`, doc);
  2945. }
  2946. if (eles.length >= 2 && eles[0].href !== eles[1].href) {
  2947. next = null;
  2948. } else if (doc === document) {
  2949. let left = getElementLeft(next);
  2950. if (left < 20 || (document.documentElement.scrollWidth > 500 && left < 250)) {
  2951. next = null;
  2952. } else {
  2953. let top = getElementTop(next);
  2954. if (top < 20 || (left < window.innerWidth / 3 && top < window.innerHeight / 3)) {
  2955. next = null;
  2956. } else {
  2957. let bottom = top + next.offsetHeight || 0;
  2958. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  2959. if (scrollH - bottom < 10) next = null;
  2960. }
  2961. }
  2962. }
  2963. return next;
  2964. }
  2965.  
  2966. canonicalUri(src) {
  2967. if (!src) {
  2968. return "";
  2969. }
  2970. if (src.charAt(0) === "#") return this.curUrl + src;
  2971. if (src.charAt(0) === "?") return this.curUrl.replace(/^([^\?#]+).*/, "$1" + src);
  2972. let origin = location.protocol + '//' + location.host;
  2973. let url = this.basePath || origin;
  2974. url = url.replace(/(\?|#).*/, "");
  2975. if (/https?:\/\/[^\/]+$/.test(url)) url = url + '/';
  2976. if (url.indexOf("http") !== 0) url = origin + url;
  2977. var root_page = /^[^\?#]*\//.exec(url)[0],
  2978. root_domain = /^\w+\:\/\/\/?[^\/]+/.exec(root_page)[0],
  2979. absolute_regex = /^\w+\:\/\//;
  2980. this.updateUrl = false;
  2981. while (src.indexOf("../") === 0) {
  2982. src = src.substr(3);
  2983. root_page = root_page.replace(/\/[^\/]+\/$/, "/");
  2984. this.updateUrl = true;
  2985. }
  2986. src = src.replace(/\.\//, "");
  2987. if (/^\/\/\/?/.test(src)) {
  2988. src = location.protocol + src;
  2989. }
  2990. return (absolute_regex.test(src) ? src : ((src.charAt(0) === "/" ? root_domain : root_page) + src));
  2991. }
  2992.  
  2993. getLinkByPage(url, pageNum) {
  2994. if (!url) return null;
  2995. if (this.curSiteRule.pageNum) {
  2996. let result = this.curSiteRule.pageNum;
  2997. let strMatch = result.match(/\{.*?}/);
  2998. if (!strMatch) return null;
  2999. let urlReg = new RegExp("(" + result.replace(strMatch[0], ")\\d+(") + ")", "i");
  3000. let code = strMatch[0].replace(/^{/, "").replace(/}$/, "").replace(/\$p/g, pageNum);
  3001. if (code === pageNum) {
  3002. result = url.replace(urlReg, "$1" + code + "$2");
  3003. } else {
  3004. try {
  3005. code = Function('"use strict";return ' + code)();
  3006. if (code && code % 1 == 0) {
  3007. result = url.replace(urlReg, "$1" + code + "$2");
  3008. } else return null;
  3009. } catch(e) {
  3010. debug(e);
  3011. }
  3012. }
  3013. if (result != url) {
  3014. return result;
  3015. }
  3016. }
  3017. return url.replace(/([&\/\?](p=|page[=\/_-]?))\d+/i, "$1" + pageNum).replace(/([_-])\d+\./i, "$1" + pageNum + ".");
  3018. }
  3019.  
  3020. getPageNumFromUrl(url, defaultPage) {
  3021. if (!url) return defaultPage;
  3022. if (this.curSiteRule.pageNum) {
  3023. let result = this.curSiteRule.pageNum;
  3024. let strMatch = result.match(/\{.*?}/);
  3025. if (!strMatch) return defaultPage;
  3026. let urlReg = new RegExp(".*" + result.replace(strMatch[0], "(\\d+)") + ".*", "i");
  3027. let curShowNum = url.replace(urlReg, "$1");
  3028. if (curShowNum !== url) {
  3029. let code = strMatch[0].replace(/^{/, "").replace(/}$/, "");
  3030. if (code === "$p") {
  3031. return curShowNum;
  3032. } else {
  3033. try {
  3034. let page1 = parseInt(Function('"use strict";return ' + code.replace("$p", "0"))());
  3035. let page2 = parseInt(Function('"use strict";return ' + code.replace("$p", "1"))());
  3036. let numGap = page2 - page1;
  3037. let _page = (parseInt(curShowNum) - page1) / numGap;
  3038. if (_page && _page % 1 === 0) return _page;
  3039. else {
  3040. this.curSiteRule.pageNum = null;
  3041. return defaultPage;
  3042. }
  3043. } catch(e) {
  3044. debug(e);
  3045. }
  3046. }
  3047. } else {
  3048. return defaultPage;
  3049. }
  3050. }
  3051. let pageNum = url.replace(/.*[&\/\?](p=|page[=\/_-]?)(\d+).*/i, "$2");
  3052. return pageNum === url ? defaultPage : (pageNum.length > 4 ? defaultPage : pageNum);
  3053. }
  3054.  
  3055. reachedLastPage() {
  3056. if (rulesData.lastPageTips) {
  3057. showTips(i18n("lastPage"), "", 800);
  3058. }
  3059. _unsafeWindow.postMessage({
  3060. action: "lastPage",
  3061. command: 'pagetual'
  3062. }, '*');
  3063. if (sideController.inited) {
  3064. sideController.frame.classList.add("end");
  3065. }
  3066. }
  3067.  
  3068. async getNextLink(doc, exist) {
  3069. let nextLink = null, page, href;
  3070. let getNextLinkByForm = (form, submitBtn, n) => {
  3071. let params = [];
  3072. let formData = new FormData(form);
  3073. if (submitBtn && submitBtn.getAttribute) {
  3074. let btnValue, btnName;
  3075. btnName = submitBtn.getAttribute("name");
  3076. btnValue = submitBtn.getAttribute("value");
  3077. if (btnName && btnValue) params = [btnName + "=" + encodeURIComponent(btnValue)];
  3078. }
  3079. for (let [key, value] of formData) {
  3080. if (n && /^(p|page)$/i.test(key)) {
  3081. params.push(key + '=' + n);
  3082. } else {
  3083. params.push(key + '=' + encodeURIComponent(value));
  3084. }
  3085. }
  3086. params = params.join('&');
  3087. return form.action + (form.action.indexOf('?') === -1 ? '?' : '&') + params + (form.method === 'post' ? '#p{' + params + '}' : '');
  3088. };
  3089. if (this.curSiteRule.pageElementByJs) {
  3090. this.nextLinkHref = "#";
  3091. return true;
  3092. } else if (this.curSiteRule.nextLinkByJs) {
  3093. try {
  3094. let over = _url => {};
  3095. let targetUrl = await ((typeof this.curSiteRule.nextLinkByJs === 'function') ? this.curSiteRule.nextLinkByJs : new AsyncFunction("doc", '"use strict";' + this.curSiteRule.nextLinkByJs))(doc);
  3096. if (targetUrl) nextLink = {href: targetUrl};
  3097. } catch(e) {
  3098. debug(e);
  3099. }
  3100. } else if (this.curSiteRule.nextLinkByUrl) {
  3101. let targetUrl = this.curUrl.replace(new RegExp(this.curSiteRule.nextLinkByUrl[0], "i"), this.curSiteRule.nextLinkByUrl[1]);
  3102. if (targetUrl !== this.curUrl) {
  3103. let includeSel = this.curSiteRule.nextLinkByUrl[2];
  3104. let excludeSel = this.curSiteRule.nextLinkByUrl[3];
  3105. if (includeSel) {
  3106. includeSel = includeSel.trim();
  3107. if (!getElement(includeSel, doc)) {
  3108. this.nextLinkHref=false;
  3109. return null;
  3110. }
  3111. }
  3112. if (excludeSel) {
  3113. excludeSel = excludeSel.trim();
  3114. if (getElement(excludeSel, doc)) {
  3115. this.nextLinkHref=false;
  3116. return null;
  3117. }
  3118. }
  3119. let reps = targetUrl.match(/{.*?}/g);
  3120. if (reps) {
  3121. reps.forEach(rep => {
  3122. let code = rep.replace("{", "").replace("}", "").replace(/\(\)/g, "0");
  3123. let result = code.match(/^(\d*)\+1$/);
  3124. if (result) {
  3125. result = parseInt(result[1] || 1) + 1;
  3126. } else {
  3127. try {
  3128. result = Function('"use strict";return ' + code)();
  3129. } catch(e) {
  3130. debug(e);
  3131. }
  3132. }
  3133. targetUrl = targetUrl.replace(rep, result);
  3134. });
  3135. }
  3136. }
  3137. nextLink = {href: targetUrl};
  3138. } else if (typeof this.curSiteRule.nextLink !== 'undefined') {
  3139. let nextLinkSel = this.curSiteRule.nextLink;
  3140. if (nextLinkSel != 0) {
  3141. if (Array && Array.isArray && Array.isArray(nextLinkSel)) {
  3142. nextLink = getElement(nextLinkSel[nextIndex], doc, null, true);
  3143. if (!nextLink && curPage === 1 && nextIndex !== 0) {
  3144. nextIndex = 0;
  3145. nextLink = getElement(nextLinkSel[nextIndex], doc, null, true);
  3146. }
  3147. } else nextLink = getElement(nextLinkSel, doc, null, true);
  3148. }
  3149. if (nextLink && (this.curSiteRule.action == 0 || this.curSiteRule.action == 1 || this.curSiteRule.action == 2)) {
  3150. let form = doc.querySelector('#search-form');
  3151. if (!nextLink.href && nextLink.hasAttribute && nextLink.hasAttribute("onclick") && form) {
  3152. if (/^\d+$/.test(nextLink.innerText)) {
  3153. nextLink.href = getNextLinkByForm(form, nextLink, nextLink.innerText);
  3154. }
  3155. } else if (compareNodeName(nextLink, ["input"]) || nextLink.type === "submit") {
  3156. form = nextLink.parentNode;
  3157. while (form) {
  3158. if (compareNodeName(form, ["form"])) break;
  3159. else form = form.parentNode;
  3160. }
  3161. if (form) {
  3162. nextLink.href = getNextLinkByForm(form, nextLink);
  3163. }
  3164. }
  3165. if (nextLink.href && this.curSiteRule.action != 0) {
  3166. nextLink.href = nextLink.href.replace(/#p{.*/, "");
  3167. }
  3168. }
  3169. } else {
  3170. page = await this.getPage(doc, exist);
  3171. nextLink = page.next;
  3172. if (nextLink) {
  3173. if (compareNodeName(nextLink, ["input"]) || nextLink.type === "submit") {
  3174. if (!/next/i.test(nextLink.getAttribute("onclick"))) {
  3175. let form = nextLink.parentNode;
  3176. while (form) {
  3177. if (compareNodeName(form, ["form"])) break;
  3178. else form = form.parentNode;
  3179. }
  3180. if (form) {
  3181. nextLink.href = getNextLinkByForm(form, nextLink);
  3182. }
  3183. }
  3184. }
  3185. let parent = nextLink;
  3186. while (parent && !compareNodeName(parent, ["body"])) {
  3187. if (parent.hasAttribute && parent.hasAttribute("disabled")) {
  3188. this.nextLinkHref = false;
  3189. return null;
  3190. }
  3191. if (parent.className && parent.classList) {
  3192. if (parent.classList.contains("noClick") || parent.classList.contains("no-pages") || parent.classList.contains("disabled")) {
  3193. this.nextLinkHref = false;
  3194. return null;
  3195. }
  3196. }
  3197. if (parent.style && parent.style.display === "none") {
  3198. this.nextLinkHref = false;
  3199. return null;
  3200. }
  3201. parent = parent.parentNode;
  3202. }
  3203. if (doc === document) {
  3204. if (!this.linkHasHref(nextLink)) {
  3205. if (!isVisible(nextLink, _unsafeWindow)) {
  3206. this.nextLinkHref = false;
  3207. return null;
  3208. }
  3209. let video = document.querySelector("video,iframe[id*=play],[id*=play]>iframe,iframe[src*=player],iframe[src*=m3u8]");
  3210. if (video) {
  3211. if (video.offsetParent && video.name !== 'pagetual-iframe') {
  3212. let scrollWidth = video.scrollWidth || video.offsetWidth;
  3213. let scrollHeight = video.scrollHeight || video.offsetHeight;
  3214. if (compareNodeName(video, ["iframe"])) {
  3215. } else if (scrollWidth > 100 && scrollHeight > 100) {
  3216. let winWidth = window.innerWidth || document.documentElement.clientWidth;
  3217. let winHeight = window.innerHeight || document.documentElement.clientHeight;
  3218. if (scrollWidth > winWidth>>1 && scrollHeight > winHeight>>1) {
  3219. debug("Disable when large media found");
  3220. } else {
  3221. video = null;
  3222. }
  3223. } else {
  3224. video = null;
  3225. }
  3226. } else {
  3227. video = null;
  3228. }
  3229. }
  3230. if (video) {
  3231. isPause = true;
  3232. this.clearAddedElements();
  3233. this.nextLinkHref = false;
  3234. return null;
  3235. }
  3236. }
  3237.  
  3238. let nextLinkCs = _unsafeWindow.getComputedStyle(nextLink);
  3239. if (nextLinkCs.cursor === "not-allowed") {
  3240. this.nextLinkHref = false;
  3241. return null;
  3242. }
  3243. this.initNext = nextLink;
  3244. }
  3245. let form = doc.querySelector('#search-form');
  3246. if (!nextLink.href && nextLink.hasAttribute("onclick") && form) {
  3247. if (form && /^\d+$/.test(nextLink.innerText)) {
  3248. href = getNextLinkByForm(form, nextLink, nextLink.innerText);
  3249. }
  3250. }
  3251. }
  3252. }
  3253. if (nextLink) {
  3254. if (doc === document && nextLink.offsetParent) {
  3255. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  3256. let actualBottom = getElementBottom(nextLink);
  3257. bottomGap = scrollH - actualBottom + (window.innerHeight || document.documentElement.clientHeight) * rate;
  3258. if (bottomGap < 100) bottomGap = 100;
  3259. }
  3260. if (!this.checkStopSign(nextLink, doc)) {
  3261. if (curPage > 1) {
  3262. this.reachedLastPage();
  3263. }
  3264. return null;
  3265. }
  3266. if (this.curSiteRule.action == 3) {
  3267. if (doc == document) debug(nextLink, 'Next link');
  3268. this.nextLinkHref = '#';
  3269. } else {
  3270. let needUrl = (this.curSiteRule.action == 0 || this.curSiteRule.action == 1 || this.curSiteRule.action == 2);
  3271. if (!href) href = nextLink.href;
  3272. if (href && nextLink.getAttribute) {
  3273. let _href = nextLink.getAttribute("href");
  3274. if (_href) {
  3275. let realHref = _href.replace(location.href, "");
  3276. if (realHref.charAt(0) === "#" || realHref === "?"){
  3277. href = "#";
  3278. } else {
  3279. href = _href;
  3280. }
  3281. } else if (_href === "") {
  3282. href = _href;
  3283. }
  3284. }
  3285.  
  3286. if (needUrl && (href === "" || href === null)) {
  3287. this.nextLinkHref = false;
  3288. } else if (needUrl && /^(javascript:|#)/.test(href)) {
  3289. this.nextLinkHref = false;
  3290. } else {
  3291. this.nextLinkHref = (href && !/^(javascript:|#)/.test(href)) ? this.canonicalUri(href) : "#";
  3292. let tempUrl = this.nextLinkHref;
  3293. 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 + "#"))) {
  3294. this.nextLinkHref = false;
  3295. } else if (doc === document) {
  3296. debug(nextLink, 'Next link');
  3297. }
  3298. }
  3299. }
  3300. } else {
  3301. this.nextLinkHref = false;
  3302. }
  3303. this.nextLinkEle = nextLink;
  3304. this.preload();
  3305. return nextLink;
  3306. }
  3307.  
  3308. compareUrl(url1, url2) {
  3309. if (url1 === url2) return true;
  3310. if (!url1 || !url2) return false;
  3311. let url1Arr = url1.split("?");
  3312. let url2Arr = url2.split("?");
  3313. if (url1Arr[0] != url2Arr[0]) return false;
  3314. if (!url1Arr[1] || !url2Arr[1]) return false;
  3315. url1Arr = url1Arr[1].split("&").sort().join("&");
  3316. url2Arr = url2Arr[1].split("&").sort().join("&");
  3317. return url1Arr === url2Arr;
  3318. }
  3319.  
  3320. filterEles(doc, eles) {
  3321. let filter = this.curSiteRule.filter;
  3322. if (!filter || !eles || eles.length === 0) return;
  3323. if (eles.length === 1) {
  3324. eles = eles[0].children;
  3325. if (eles.length === 1) {
  3326. eles = eles[0].children;
  3327. }
  3328. }
  3329. if (typeof filter === "string") {
  3330. if (/^\d+$/.test(filter)) {
  3331. filter = {count: parseInt(filter)};
  3332. } else filter = {words: filter};
  3333. }
  3334. [].forEach.call(eles, ele => {
  3335. if (!ele.parentNode) return;
  3336. let canKeep = (() => {
  3337. let innerText = (ele.innerText && ele.innerText.trim()) || "";
  3338. if (filter.count) {
  3339. if (innerText.length < filter.count) return false;
  3340. }
  3341. if (filter.words) {
  3342. let wordsRegExp = new RegExp(filter.words, "i");
  3343. if (innerText && wordsRegExp.test(innerText)) return false;
  3344. }
  3345. if (filter.link) {
  3346. let linkRegExp = new RegExp(filter.link, "i");
  3347. if (compareNodeName(ele, ["a"]) && linkRegExp.test(ele.href)) return false;
  3348. let aChildren = ele.querySelectorAll("a");
  3349. for (let i = 0; i < aChildren.length; i++) {
  3350. let child = aChildren[i];
  3351. if (linkRegExp.test(child.href)) return false;
  3352. }
  3353. }
  3354. if (filter.selector) {
  3355. if (getElement(filter.selector, doc, ele)) return false;
  3356. }
  3357. return true;
  3358. })();
  3359. if (!canKeep) {
  3360. ele.parentNode.removeChild(ele);
  3361. }
  3362. });
  3363. }
  3364.  
  3365. checkStopSign(nextLink, doc) {
  3366. if (this.curSiteRule.stopSign) {
  3367. let typeArray = Array && Array.isArray && Array.isArray(this.curSiteRule.stopSign);
  3368. let typeObject = !typeArray && (this.curSiteRule.stopSign.include || this.curSiteRule.stopSign.exclude || this.curSiteRule.stopSign.pageNum);
  3369. if (typeArray || typeObject) {
  3370. let includeSel, excludeSel, curSign, maxSign;
  3371. if (typeArray) {
  3372. includeSel = this.curSiteRule.stopSign[0];
  3373. excludeSel = this.curSiteRule.stopSign[1];
  3374. curSign = this.curSiteRule.stopSign[2];
  3375. maxSign = this.curSiteRule.stopSign[3];
  3376. if (Array && Array.isArray && Array.isArray(includeSel) && !curSign) {
  3377. curSign = includeSel;
  3378. includeSel = false;
  3379. }
  3380. if (excludeSel && Array && Array.isArray && Array.isArray(excludeSel) && !maxSign) {
  3381. maxSign = excludeSel;
  3382. excludeSel = false;
  3383. }
  3384. } else {
  3385. includeSel = this.curSiteRule.stopSign.include;
  3386. excludeSel = this.curSiteRule.stopSign.exclude;
  3387. curSign = this.curSiteRule.stopSign.pageNum;
  3388. }
  3389. if (includeSel) {
  3390. includeSel = includeSel.trim();
  3391. if (!getElement(includeSel, doc)) {
  3392. isPause = true;
  3393. this.nextLinkHref = false;
  3394. return false;
  3395. }
  3396. }
  3397. if (excludeSel) {
  3398. excludeSel = excludeSel.trim();
  3399. if (getElement(excludeSel, doc)) {
  3400. isPause = true;
  3401. this.nextLinkHref = false;
  3402. return false;
  3403. }
  3404. }
  3405. if (curSign) {
  3406. if (!maxSign) maxSign = curSign.slice(2);
  3407. let currentEle = getElement(curSign[0], doc);
  3408. let maxEle = getElement(maxSign[0], doc);
  3409. if (currentEle && maxEle) {
  3410. let currentSignNum, maxSignNum;
  3411. if (/\(.*\)/.test(curSign[1])) {
  3412. currentSignNum = currentEle.innerText.match(new RegExp(curSign[1]));
  3413. if (currentSignNum) currentSignNum = currentSignNum[1];
  3414. } else if (currentEle.getAttribute) {
  3415. currentSignNum = currentEle.getAttribute(curSign[1]);
  3416. }
  3417. if (/\(.*\)/.test(maxSign[1])) {
  3418. maxSignNum = maxEle.innerText.match(new RegExp(maxSign[1]));
  3419. if (maxSignNum) maxSignNum = maxSignNum[1];
  3420. } else if (maxEle.getAttribute) {
  3421. maxSignNum = maxEle.getAttribute(maxSign[1]);
  3422. }
  3423. if (currentSignNum && maxSignNum && currentSignNum == maxSignNum) {
  3424. isPause = true;
  3425. this.nextLinkHref = false;
  3426. return false;
  3427. }
  3428. }
  3429. }
  3430. } else {
  3431. try {
  3432. let stopSign = ((typeof this.curSiteRule.stopSign === 'function') ? this.curSiteRule.stopSign : Function("doc", "nextLink", '"use strict";' + this.curSiteRule.stopSign))(doc, nextLink);
  3433. if (stopSign) {
  3434. isPause = true;
  3435. this.nextLinkHref = false;
  3436. return false;
  3437. }
  3438. } catch(e) {
  3439. debug(e);
  3440. }
  3441. }
  3442. }
  3443. return true;
  3444. }
  3445.  
  3446. preloadImageHandler() {
  3447. if (this.preloadingImage || !this.unCheckedImgs.length) return;
  3448. this.preloadingImage = true;
  3449. setTimeout(() => {
  3450. this.preloadingImage = false;
  3451. this.preloadImageHandler();
  3452. }, 10);
  3453. let iSrc = this.unCheckedImgs.shift();
  3454. let img = document.createElement('img');
  3455. img.src = iSrc;
  3456. this.preloadDiv.appendChild(img);
  3457. }
  3458.  
  3459. preload() {
  3460. if (!rulesData.preload) return;
  3461. if (this.curSiteRule.preload === 0) return;
  3462. if (!this.nextLinkHref || this.nextLinkHref == "#") return;
  3463. if (this.readyStateUnComplete) return;
  3464. if (document.readyState !== 'complete') {
  3465. this.readyStateUnComplete = true;
  3466. let self = this;
  3467. window.addEventListener("load", e => {
  3468. self.readyStateUnComplete = false;
  3469. self.preload();
  3470. });
  3471. return;
  3472. }
  3473. let self = this, url = this.nextLinkHref;
  3474. let postParams = url.match(/#p{(.*)}$/);
  3475. if (postParams) {
  3476. postParams = postParams[1];
  3477. url = url.replace(/#p{.*/, "");
  3478. }
  3479. _GM_xmlhttpRequest({
  3480. url: url,
  3481. method: postParams ? 'POST' : 'GET',
  3482. data: postParams,
  3483. overrideMimeType: 'text/html;charset=' + charset,
  3484. headers: {
  3485. 'Referer': location.href,
  3486. 'User-Agent': navigator.userAgent,
  3487. "Content-Type": (postParams ? "application/x-www-form-urlencoded" : "text/html") + ";charset=" + charset,
  3488. },
  3489. timeout: 10000,
  3490. onload: function(res) {
  3491. var doc = null;
  3492. try {
  3493. doc = document.implementation.createHTMLDocument('');
  3494. doc.documentElement.innerHTML = createHTML(res.response);
  3495. var body = getBody(doc);
  3496. if (!self.preloadDiv) {
  3497. self.preloadDiv = document.createElement('div');
  3498. self.preloadDiv.id = "pagetual-preload";
  3499. self.preloadDiv.style.cssText = 'display:none!important;';
  3500. getBody(document).appendChild(self.preloadDiv);
  3501. self.checkedImgs = {};
  3502. self.unCheckedImgs = [];
  3503. }
  3504. let code = self.curSiteRule.preloadImages;
  3505. if (code) {
  3506. let imgSrcArr = new Function("doc", '"use strict";' + code)(doc);
  3507. if (imgSrcArr && imgSrcArr.length) {
  3508. imgSrcArr.forEach(imgSrc => {
  3509. if (imgSrc && !self.checkedImgs[imgSrc]) {
  3510. self.checkedImgs[imgSrc] = true;
  3511. self.unCheckedImgs.push(imgSrc);
  3512. }
  3513. });
  3514. }
  3515. self.preloadImageHandler();
  3516. } else if (code !== 0 && code !== false) {
  3517. if (body && body.firstChild) {
  3518. self.lazyImgAction(body.children, doc);
  3519. }
  3520. [].forEach.call(doc.images, i => {
  3521. let iSrc = i.src;
  3522. if (iSrc && !self.checkedImgs[iSrc]) {
  3523. self.checkedImgs[iSrc] = true;
  3524. self.unCheckedImgs.push(iSrc);
  3525. }
  3526. });
  3527. self.preloadImageHandler();
  3528. }
  3529. }
  3530. catch(e) {
  3531. debug(e);
  3532. return;
  3533. }
  3534. }
  3535. });
  3536. }
  3537.  
  3538. getInsert(refresh) {
  3539. if (refresh) {
  3540. this.insert = null;
  3541. }
  3542. if (this.insert && this.insert.parentNode && document.documentElement.contains(this.insert)) {
  3543. return this.insert;
  3544. }
  3545. if (this.curSiteRule.insert) {
  3546. let insertSel = this.curSiteRule.insert;
  3547. if (Array && Array.isArray && Array.isArray(insertSel)) {
  3548. insertSel = insertSel[nextIndex < insertSel.length ? nextIndex : 0];
  3549. }
  3550. this.insert = getElement(insertSel, document, null, true);
  3551. } else {
  3552. this.docPageElement = null;
  3553. let pageElement = this.getPageElement(document, _unsafeWindow);
  3554. if (this.curSiteRule.smart && this.nextLinkHref == "#" && this.curSiteRule.pageElement === 'body') {
  3555. debug("Stop as jsNext & whole body");
  3556. isPause = true;
  3557. return null;
  3558. }
  3559. if (pageElement && pageElement.length > 0) {
  3560. let pEIndex = pageElement.length - 1;
  3561. let pELast = pageElement[pEIndex];
  3562. while(pELast && compareNodeName(pELast, ["link", "meta", "style", "script"])) {
  3563. pEIndex--;
  3564. pELast = pageElement[pEIndex];
  3565. }
  3566. this.insert = pELast.nextSibling ? pELast.nextSibling : pELast.parentNode.appendChild(document.createTextNode(' '));
  3567. }
  3568. }
  3569. return this.insert;
  3570. }
  3571.  
  3572. pageInit(doc, eles) {
  3573. let code = this.curSiteRule.pageInit;
  3574. if (code) {
  3575. let initFunc = ((typeof code == 'function') ? code : Function("doc", "eles", '"use strict";' + code));
  3576. let checkInit = (resolve) => {
  3577. try {
  3578. if (initFunc(doc, eles) === false) {
  3579. setTimeout(() => {
  3580. checkInit(resolve);
  3581. }, 100);
  3582. } else {
  3583. resolve(true);
  3584. }
  3585. } catch(e) {
  3586. resolve(false);
  3587. debug(e);
  3588. }
  3589. };
  3590. return new Promise((resolve) => {
  3591. checkInit(function(e) {
  3592. resolve(e)
  3593. });
  3594. })
  3595. }
  3596. }
  3597.  
  3598. pageAction(doc, eles) {
  3599. let code = this.curSiteRule.pageAction;
  3600. if (code) {
  3601. try {
  3602. ((typeof code == 'function') ? code : Function("doc", "eles", '"use strict";' + code))(doc, eles);
  3603. } catch(e) {
  3604. debug(e);
  3605. }
  3606. }
  3607. this.openInNewTab(eles);
  3608. this.replaceElement(doc);
  3609. }
  3610.  
  3611. openInNewTab(eles) {
  3612. if (openInNewTab) {
  3613. [].forEach.call(eles, ele => {
  3614. if (compareNodeName(ele, ["a"]) && ele.href && !/^(mailto:|javascript:)|#/.test(ele.href)) {
  3615. ele.setAttribute('target', openInNewTab == 1 ? '_blank' : '_self');
  3616. } else {
  3617. [].forEach.call(ele.querySelectorAll('a[href]:not([href^="mailto:"]):not([href^="javascript:"]):not([href^="#"])'), a => {
  3618. if (openInNewTab == 1) {
  3619. a.setAttribute('target', '_blank');
  3620. if (a.getAttribute('onclick') == 'atarget(this)') {
  3621. a.removeAttribute('onclick');
  3622. }
  3623. } else a.setAttribute('target', '_self');
  3624. });
  3625. }
  3626. });
  3627. }
  3628. }
  3629.  
  3630. lazyImgAction(eles, doc) {
  3631. if (!eles || eles.length == 0) return;
  3632. let lazyImgSrc = this.curSiteRule.lazyImgSrc;
  3633. if (lazyImgSrc === 0 || lazyImgSrc === '0') return;
  3634. let imgLazyAttrs = [];
  3635. 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"];
  3636. let removeProps = [];
  3637. let setLazyImg = img => {
  3638. let realSrc;
  3639. imgLazyAttrs.forEach(attr => {
  3640. realSrc = img.getAttribute(lazyImgSrc[0]);
  3641. if (realSrc) {
  3642. removeProps.forEach(prop => {
  3643. img.removeAttribute(prop.trim());
  3644. });
  3645. img.src = realSrc;
  3646. return;
  3647. }
  3648. })
  3649. if (!realSrc) {
  3650. let lazyAttr = "";
  3651. if (img.getAttribute("_src") && !img.src) {
  3652. lazyAttr = "_src";
  3653. realSrc = img.getAttribute(lazyAttr);
  3654. } else {
  3655. for (let i in lazyImgAttr) {
  3656. lazyAttr = lazyImgAttr[i];
  3657. let attrValue = img.getAttribute(lazyAttr);
  3658. if (attrValue) {
  3659. realSrc = attrValue;
  3660. break;
  3661. }
  3662. }
  3663. }
  3664. if (!realSrc && img._lazyrias && img._lazyrias.srcset) {
  3665. realSrc = img._lazyrias.srcset[img._lazyrias.srcset.length - 1];
  3666. lazyAttr = "_lazyrias";
  3667. }
  3668. if (!realSrc && img.srcset) {
  3669. lazyAttr = "srcset";
  3670. var srcs = img.srcset.split(/[xw],/i), largeSize = 0;
  3671. srcs.forEach(srci => {
  3672. let srcInfo = srci.trim().split(" "), curSize = parseInt(srcInfo[1]);
  3673. if (srcInfo[1] && curSize > largeSize) {
  3674. largeSize = curSize;
  3675. realSrc = srcInfo[0];
  3676. }
  3677. });
  3678. }
  3679. if (realSrc) {
  3680. img.src = realSrc;
  3681. img.removeAttribute("srcset");
  3682. img.removeAttribute(lazyAttr);
  3683. if (img.classList && img.classList.contains && img.classList.contains("lazy")) {
  3684. img.classList.remove("lazy");
  3685. }
  3686. if (img.style.display == "none") {
  3687. img.style.display = "";
  3688. }
  3689. if (img.style.visibility == "hidden") {
  3690. img.style.visibility = "";
  3691. }
  3692. if (img.style.opacity == 0) {
  3693. img.style.opacity = "";
  3694. }
  3695. }
  3696. }
  3697. };
  3698. if (lazyImgSrc) {
  3699. if (!Array.isArray(lazyImgSrc)) {
  3700. lazyAttrs = lazyImgSrc.split(",");
  3701. } else {
  3702. lazyAttrs = lazyImgSrc[0].split(",");
  3703. removeProps = lazyImgSrc[1].split(",");
  3704. }
  3705. }
  3706. lazyAttrs.forEach(attr => {
  3707. let attrArr = attr.split("|");
  3708. if (attrArr.length !== 2) {
  3709. imgLazyAttrs.push(attr.trim());
  3710. } else {
  3711. let selector = attrArr[0].trim();
  3712. let lazyAttr = attrArr[1].trim();
  3713. if (selector == "img") {
  3714. imgLazyAttrs.push(lazyAttr);
  3715. } else {
  3716. selector += "[" + lazyAttr + "]";
  3717. [].forEach.call(doc.querySelectorAll(selector), ele => {
  3718. ele.style.setProperty("background-image", "url(" + ele.getAttribute(lazyAttr) + ")", "important");
  3719. removeProps.forEach(prop => {
  3720. ele.removeAttribute(prop.trim());
  3721. });
  3722. });
  3723. }
  3724. }
  3725. });
  3726. [].forEach.call(doc.querySelectorAll("img,picture>source"), img => {
  3727. setLazyImg(img);
  3728. });
  3729. }
  3730.  
  3731. canListenUrlChange() {
  3732. if (this.curSiteRule) {
  3733. if (this.curSiteRule.listenUrlChange === true) return true;
  3734. if (this.curSiteRule.listenUrlChange === false) return false;
  3735. if (this.docElementValid()) {
  3736. return false;
  3737. }
  3738. }
  3739. return true;
  3740. }
  3741.  
  3742. checkClickHref() {
  3743. if (this.curSiteRule.smart && this.nextLinkEle && !this.linkHasHref(this.nextLinkEle)) {
  3744. this.urlChanged();
  3745. isPause = true;
  3746. if (!this.nextLinkHref) isLoading = false;
  3747. }
  3748. }
  3749.  
  3750. docElementValid() {
  3751. if (!this.docPageElement || this.docPageElement.length == 0) return false;
  3752. if (!this.checkPageEle) {
  3753. let ele;
  3754. if (this.docPageElement.length == 1) {
  3755. ele = this.docPageElement[0];
  3756. } else {
  3757. ele = this.docPageElement[Math.floor(this.docPageElement.length / 2)];
  3758. }
  3759. if (ele.children.length) {
  3760. ele = ele.children[Math.floor(ele.children.length / 2)];
  3761. }
  3762. this.checkPageEle = ele;
  3763. }
  3764. return document.documentElement.contains(this.checkPageEle);
  3765. }
  3766.  
  3767. urlChanged() {
  3768. urlChanged = true;
  3769. this.clearAddedElements();
  3770. }
  3771.  
  3772. initPage(callback) {
  3773. let self = this;
  3774. if (self.initing) return;
  3775. self.initing = true;
  3776. setTimeout(() => {
  3777. self.initing = false;
  3778. }, 100);
  3779. curPage = 1;
  3780. urlChanged = false;
  3781. tryTimes = 0;
  3782. this.clearAddedElements();
  3783. this.insert = null;
  3784. this.visibilityItems = [];
  3785. this.visibleIndex = -1;
  3786. this.pageDoc = document;
  3787. this.nextLinkHref = null;
  3788. this.curUrl = location.href;
  3789. this.oldUrl = "";
  3790. this.initUrl = location.href;
  3791. this.historyUrl = "";
  3792. this.possibleCheck = 0;
  3793. let base = document.querySelector("base");
  3794. this.basePath = (base && base.href) || location.href;
  3795. this.getRule(async () => {
  3796. if (self.curSiteRule.sideController === true || (self.curSiteRule.sideController !== false && rulesData.sideController)) {
  3797. isPause = manualPause;
  3798. }
  3799. hidePageBar = rulesData.opacity == 0 || self.curSiteRule.pageBar === 0;
  3800. if (typeof(self.curSiteRule.rate) !== "undefined") {
  3801. rate = self.curSiteRule.rate;
  3802. }
  3803. if (self.curSiteRule.enable == 0) {
  3804. debug("Stop as rule disable");
  3805. isPause = true;
  3806. _GM_registerMenuCommand(i18n("enable"), () => {
  3807. showTips(i18n("enableSiteTips"));
  3808. if(!self.customRules) {
  3809. self.customRules = [];
  3810. }
  3811. for (let i in self.customRules) {
  3812. if (self.customRules[i].url == self.curSiteRule.url) {
  3813. self.customRules.splice(i, 1);
  3814. break;
  3815. }
  3816. }
  3817. self.curSiteRule.enable = 1;
  3818. self.customRules.unshift(self.curSiteRule);
  3819. storage.setItem("customRules", self.customRules);
  3820. location.reload();
  3821. });
  3822. return;
  3823. }
  3824. if (rulesData.sideControllerAlways) {
  3825. sideController.setup();
  3826. }
  3827. //若是再亂匹配就不緩存wedata,或者只在找完本地規則之後再考慮wedata的緩存
  3828. if (self.curSiteRule.smart) {
  3829. delete self.curSiteRule.pageElement;
  3830. if (!self.possibleRule) {
  3831. self.smartRules = self.smartRules.filter(item => {return item && item.url != self.curSiteRule.url});
  3832. self.smartRules.unshift(self.curSiteRule);
  3833. if (self.smartRules.length > 100) {
  3834. self.smartRules.pop();
  3835. }
  3836. storage.setItem("smartRules", self.smartRules);
  3837. }
  3838. } else if (self.curSiteRule && self.curSiteRule.url.length > 13) {
  3839. self.addToHpRules();
  3840. }
  3841. let css;
  3842. if (rulesData.customCss && self.curSiteRule.css) {
  3843. let globalCssArr = rulesData.customCss.split("inIframe:");
  3844. let ruleCssArr = self.curSiteRule.css.split("inIframe:");
  3845. let mainCss = globalCssArr[0] + ruleCssArr[0], inCss = (globalCssArr[1] || "") + (ruleCssArr[1] || "");
  3846. css = mainCss + (inCss ? ("inIframe:" + inCss) : "");
  3847. } else {
  3848. css = self.curSiteRule.css || rulesData.customCss;
  3849. }
  3850. if (css) {
  3851. let cssArr = css.split("inIframe:");
  3852. if (cssArr && cssArr.length) {
  3853. _GM_addStyle(cssArr[0]);
  3854. }
  3855. }
  3856. if (/sidesearch=(1|true)$/.test(self.curUrl)) {
  3857. openInNewTab = 0;
  3858. } else if (typeof self.curSiteRule.openInNewTab !== 'undefined') {
  3859. openInNewTab = self.curSiteRule.openInNewTab ? 1 : 2;
  3860. }
  3861. let autoClick = self.curSiteRule.autoClick;
  3862. if (autoClick) {
  3863. let autoClickBtn;
  3864. autoClickBtn = getElement(autoClick, document, null, true);
  3865. if (autoClickBtn) {
  3866. emuClick(autoClickBtn);
  3867. }
  3868. }
  3869. let code = self.curSiteRule.init;
  3870. if (code) {
  3871. try {
  3872. 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)});
  3873. } catch(e) {
  3874. debug(e);
  3875. }
  3876. }
  3877. await self.getNextLink(document, true);
  3878. if (self.curSiteRule.pageNum && self.nextLinkHref && self.nextLinkHref != "#") {
  3879. let num1st = self.getPageNumFromUrl(location.href, 1);
  3880. let num2nd = self.getPageNumFromUrl(self.nextLinkHref, 1);
  3881. if (parseInt(num2nd) != parseInt(num1st) + 1) {
  3882. self.curSiteRule.pageNum = null;
  3883. }
  3884. }
  3885. if (self.curSiteRule.smart && self.nextLinkHref == false && self.possibleRule) {
  3886. let urlReg = new RegExp(self.possibleRule.url, "i");
  3887. function checkPossible () {
  3888. if (self.possibleCheck++ < 3) {
  3889. setTimeout(() => {
  3890. if (self.curSiteRule.smart) {
  3891. var href = location.href.slice(0, 500);
  3892. if (urlReg.test(href) && self.ruleMatch(self.possibleRule)) {
  3893. self.initPage(() => {});
  3894. } else checkPossible();
  3895. }
  3896. }, 3000);
  3897. }
  3898. }
  3899. checkPossible();
  3900. }
  3901. self.refreshByClick();
  3902. if (emuIframe && emuIframe.parentNode) {
  3903. emuIframe.parentNode.removeChild(emuIframe);
  3904. emuIframe = null;
  3905. }
  3906.  
  3907. let pageElementCss = self.curSiteRule.pageElementCss || rulesData.pageElementCss;
  3908. if (pageElementCss && pageElementCss !== '0') {
  3909. self.getPageElement(document, _unsafeWindow);
  3910. }
  3911. callback();
  3912. let initRun = typeof self.curSiteRule.initRun == 'undefined' ? rulesData.initRun : self.curSiteRule.initRun;
  3913. if (self.nextLinkHref) {
  3914. sideController.setup();
  3915. if (initRun && initRun != false) {
  3916. setTimeout(() => {
  3917. nextPage();
  3918. }, 300);
  3919. }
  3920. }
  3921. });
  3922. }
  3923.  
  3924. async hookUrlSetEle(ele, doc) {
  3925. let self = this;
  3926. return new Promise((resolve) => {
  3927. let catchUrl = e => {
  3928. ele.dataset.url = self.catchedUrl;
  3929. ele.setAttribute('onclick', 'window.open(this.dataset.url)');
  3930. window.removeEventListener('pagetual_openUrl', catchUrl);
  3931. resolve();
  3932. };
  3933. window.addEventListener('pagetual_openUrl', catchUrl);
  3934. emuClick(ele, doc);
  3935. });
  3936. }
  3937.  
  3938. async hookUrl(doc) {
  3939. let sel = this.curSiteRule.hookUrl;
  3940. if (!sel) return;
  3941. let self = this;
  3942. if (!this.initHook) {
  3943. this.initHook = true;
  3944. Object.defineProperty(doc.defaultView, 'open', {
  3945. get: function () {
  3946. return (s) => {
  3947. self.catchedUrl = s;
  3948. var e = new CustomEvent('pagetual_openUrl');
  3949. window.dispatchEvent(e);
  3950. }
  3951. }
  3952. });
  3953. }
  3954. let eles = getAllElements(sel, doc);
  3955. for (let i = 0; i < eles.length; i++) {
  3956. await sleep(1);
  3957. let ele = eles[i];
  3958. if (!ele.dataset.url) {
  3959. await this.hookUrlSetEle(ele, doc);
  3960. }
  3961. }
  3962. }
  3963.  
  3964. beginLoading() {
  3965. isLoading = true;
  3966. if (targetY >= 0) {
  3967. window.scrollTo({ top: targetY, behavior: 'instant'});
  3968. targetY = -1;
  3969. }
  3970. let lastScrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  3971. ruleParser.insertElement(loadingDiv);
  3972. if (forceState == 2) {
  3973. getBody(document).appendChild(loadingDiv);
  3974. } else {
  3975. let parent = loadingDiv.parentNode;
  3976. if (compareNodeName(parent, ["tbody"])) {
  3977. parent = parent.parentNode;
  3978. }
  3979. if (compareNodeName(parent, ["table"])) {
  3980. parent.parentNode.appendChild(loadingDiv);
  3981. }
  3982. }
  3983. getBody(document).scrollTop = lastScrollTop;
  3984. document.documentElement.scrollTop = lastScrollTop;
  3985. if (sideController.inited) {
  3986. sideController.frame.classList.add("loading");
  3987. }
  3988. }
  3989.  
  3990. insertElement(ele) {
  3991. if (!this.insert || !this.insert.parentNode) {
  3992. this.getInsert();
  3993. }
  3994. if (this.insert && this.insert.parentNode) {
  3995. let self = this;
  3996. if (ele.nodeName == "#document-fragment") {
  3997. [].forEach.call(ele.children, el => {
  3998. self.addedElePool.push(el);
  3999. });
  4000. } else {
  4001. this.addedElePool.push(ele);
  4002. }
  4003. if (this.curSiteRule.insertPos == 2 || this.curSiteRule.insertPos == "in") {
  4004. this.insert.appendChild(ele);
  4005. } else {
  4006. this.insert.parentNode.insertBefore(ele, this.insert);
  4007. }
  4008. }
  4009. }
  4010.  
  4011. noValidContent(url) {
  4012. if (!this.curSiteRule.nextLinkByUrl) showTips(i18n("noValidContent"), url);
  4013. }
  4014.  
  4015. async insertPage(doc, eles, url, callback, tried) {
  4016. this.oldUrl = this.curUrl;
  4017. let oldTitle = document.title;
  4018. try {
  4019. let oldTitle = this.pageDoc.title;
  4020. } catch (e) {}
  4021. this.pageDoc = doc;
  4022. this.curUrl = url;
  4023. isLoading = true;
  4024. let nextLink = await this.getNextLink(doc);
  4025. this.nextTitle = "";
  4026. if (this.curSiteRule.pageBarText) {
  4027. if (this.curSiteRule.pageBarText == 1 || this.curSiteRule.pageBarText == true) {
  4028. this.nextTitle = doc.title;
  4029. } else {
  4030. try {
  4031. this.nextTitle = ((typeof this.curSiteRule.pageBarText == 'function') ? this.curSiteRule.pageBarText : Function("doc",'"use strict";' + this.curSiteRule.pageBarText))(doc);
  4032. } catch(e) {
  4033. debug(e);
  4034. }
  4035. }
  4036. }
  4037. if (curPage == 1 && !tried && !nextLink && this.curSiteRule.smart && this.curSiteRule.pageElement && this.curSiteRule.action != 0) {
  4038. this.curSiteRule.action = 1;
  4039. this.curUrl = location.href;
  4040. isLoading = false;
  4041. return false;
  4042. }
  4043.  
  4044. if (targetY >= 0) {
  4045. window.scrollTo({ top: targetY, behavior: 'instant'});
  4046. targetY = -1;
  4047. }
  4048. let lastScrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  4049. this.getInsert();
  4050. await this.pageInit(doc, eles);
  4051. var self = this, newEles = [];
  4052. if (!eles || eles.length == 0 || !self.insert || !self.insert.parentNode) {
  4053. if (callback) callback(eles);
  4054. loadPageOver();
  4055. } else {
  4056. if (callback) callback(eles);
  4057. loadPageOver();
  4058. const collection = document.createDocumentFragment();
  4059. [].forEach.call(eles, ele => {
  4060. let newEle = ele.cloneNode(true);
  4061. let oldCanvass = ele.querySelectorAll("canvas");
  4062. let newCanvass = newEle.querySelectorAll("canvas");
  4063. if (self.updateUrl) {
  4064. [].forEach.call(newEle.querySelectorAll("img"), img => {
  4065. if (img.getAttribute("src")) img.src = self.canonicalUri(img.getAttribute("src"));
  4066. });
  4067. [].forEach.call(newEle.querySelectorAll("a"), a => {
  4068. if (a.getAttribute("href")) a.href = self.canonicalUri(a.getAttribute("href"));
  4069. });
  4070. }
  4071. for (let i = 0; i < oldCanvass.length; i++) {
  4072. let oldCanvas = oldCanvass[i];
  4073. let newCanvas = newCanvass[i];
  4074. newCanvas.getContext('2d').drawImage(oldCanvas, 0, 0);
  4075. }
  4076. if (!compareNodeName(newEle, ["style", "script"])) self.visibilityItems.push(newEle);
  4077. collection.appendChild(newEle)
  4078. newEles.push(newEle);
  4079. });
  4080. let css = this.curSiteRule.css;
  4081. let addCss = (parent) => {
  4082. if (css) {
  4083. let cssArr = css.split("inIframe:");
  4084. if (cssArr && cssArr.length == 2) {
  4085. let styleEle = document.createElement("style");
  4086. styleEle.innerHTML = cssArr[1];
  4087. parent.appendChild(styleEle);
  4088. }
  4089. }
  4090. };
  4091. if (this.curSiteRule.surround === "iframe") {
  4092. let ele = document.createElement("iframe");
  4093. ele.style.border = "unset";
  4094. ele.style.maxWidth = "100%";
  4095. ele.style.width = "100vw";
  4096. self.insertElement(ele);
  4097. try {
  4098. let doc = ele.contentDocument || ele.contentWindow.document;
  4099. doc.body.appendChild(collection);
  4100. ele.style.width = doc.body.scrollWidth + "px";
  4101. ele.style.height = doc.body.scrollHeight + "px";
  4102. doc.documentElement.style.overflow = "hidden";
  4103. doc.body.style.overflow = "hidden";
  4104. addCss(doc.body);
  4105. } catch(e) {
  4106. console.log(e);
  4107. }
  4108. } else if (this.curSiteRule.surround === "shadowDom") {
  4109. let ele = document.createElement("div");
  4110. self.insertElement(ele);
  4111. let shadowRoot = ele.attachShadow({ mode: "open" });
  4112. shadowRoot.appendChild(collection);
  4113. addCss(shadowRoot);
  4114. } else {
  4115. self.insertElement(collection);
  4116. }
  4117. }
  4118. getBody(document).scrollTop = lastScrollTop;
  4119. document.documentElement.scrollTop = lastScrollTop;
  4120. this.pageAction(doc, newEles);
  4121. let enableHistory = this.curSiteRule.history;
  4122. let enableHistoryAfterInsert = false;
  4123. if (enableHistory == 1) {
  4124. enableHistory = true;
  4125. } else if (enableHistory == 2) {
  4126. enableHistory = true;
  4127. enableHistoryAfterInsert = true;
  4128. } else if (enableHistory == 0) {
  4129. enableHistory = false;
  4130. } else {
  4131. enableHistory = rulesData.enableHistory;
  4132. enableHistoryAfterInsert = rulesData.enableHistoryAfterInsert;
  4133. }
  4134. if (enableHistory) {
  4135. this.historyUrl = enableHistoryAfterInsert ? this.curUrl : this.oldUrl;
  4136. if(this.historyUrl != location.href) {
  4137. let isJs = this.hrefIsJs(this.historyUrl);
  4138. if (!isJs) {
  4139. let historyTitle = enableHistoryAfterInsert ? doc.title : oldTitle;
  4140. _unsafeWindow.history.replaceState(undefined, historyTitle, this.historyUrl);
  4141. document.title = historyTitle;
  4142. }
  4143. }
  4144. }
  4145. isLoading = false;
  4146. _unsafeWindow.postMessage({
  4147. action: "insert",
  4148. command: 'pagetual'
  4149. }, '*');
  4150. return true;
  4151. }
  4152. }
  4153. var ruleParser = new RuleParser();
  4154.  
  4155. class SideController {
  4156. //static controller;
  4157. constructor() {
  4158. this.inited = false;
  4159. }
  4160.  
  4161. /*static getInstance() {
  4162. if (!SideController.controller) {
  4163. SideController.controller = new SideController();
  4164. }
  4165. return SideController.controller;
  4166. }*/
  4167.  
  4168. setup() {
  4169. if (ruleParser.curSiteRule.sideController === false) return;
  4170. if (!rulesData.sideController && !ruleParser.curSiteRule.sideController) return;
  4171. this.addToStage();
  4172. }
  4173.  
  4174. init() {
  4175. if (this.inited) return;
  4176. this.inited = true;
  4177. let self = this;
  4178. this.cssText = `
  4179. #pagetual-sideController {
  4180. position: fixed;
  4181. top: calc(50% - 83px);
  4182. left: calc(99% - 40px);
  4183. width: 40px;
  4184. border-radius: 20px;
  4185. box-shadow: rgb(0 0 0) 0px 0px 10px;
  4186. text-align: center;
  4187. background: #ffffffd0!important;
  4188. user-select: none;
  4189. z-index: 2147483646!important;
  4190. padding: 0!important;
  4191. opacity: 0.5;
  4192. transition: opacity .5s ease, background .5s, box-shadow .5s;
  4193. }
  4194. #pagetual-sideController.end {
  4195. opacity: 0.3;
  4196. }
  4197. #pagetual-sideController * {
  4198. font-weight: bold;
  4199. font-family: arial;
  4200. font-style: normal;
  4201. font-size: 20px!important;
  4202. color: black!important;
  4203. line-height: normal;
  4204. float: none;
  4205. text-align: center;
  4206. }
  4207. #pagetual-sideController.stop {
  4208. -webkit-filter: invert(100%);
  4209. filter: invert(100%);
  4210. }
  4211. .pagetual-sideController-btn {
  4212. padding: 5px 0;
  4213. cursor: pointer;
  4214. transition: transform .15s ease-in-out, opacity .3s ease;
  4215. }
  4216. #pagetual-sideController .pagetual-sideController-btn:hover {
  4217. transform: scale(1.5);
  4218. color: red!important;
  4219. }
  4220. #pagetual-sideController #pagetual-sideController-move > svg {
  4221. transition: transform .3s ease;
  4222. }
  4223. #pagetual-sideController #pagetual-sideController-move > svg:hover {
  4224. transform: scale(1.2);
  4225. }
  4226. ${rulesData.hideLoadingIcon ? '' : `
  4227. #pagetual-sideController.minSize #pagetual-sideController-move::before {
  4228. content: '';
  4229. position: absolute;
  4230. width: 34px;
  4231. height: 34px;
  4232. background-color: #1a232a;
  4233. background-repeat: no-repeat;
  4234. background-position: 0 0;
  4235. z-index: -1;
  4236. margin: -2px;
  4237. border-radius: 50%;
  4238. }
  4239. #pagetual-sideController.minSize.loading #pagetual-sideController-move::before {
  4240. background-image: conic-gradient(transparent, #a8efff, transparent 30%);
  4241. -webkit-animation: siderotate 1s linear infinite;
  4242. animation: siderotate 1s linear infinite;
  4243. }
  4244. @keyframes siderotate {
  4245. 100% {
  4246. transform: rotate(1turn);
  4247. }
  4248. }`}
  4249. #pagetual-sideController.minSize #pagetual-sideController-move > svg {
  4250. background: white;
  4251. opacity: 0;
  4252. }
  4253. #pagetual-sideController #pagetual-sideController-move > img,
  4254. #pagetual-sideController #pagetual-sideController-move > span {
  4255. width: 35px;
  4256. height: 35px;
  4257. cursor: pointer;
  4258. }
  4259. #pagetual-sideController.minSize #pagetual-sideController-move > img,
  4260. #pagetual-sideController.minSize #pagetual-sideController-move > span {
  4261. border-radius: 50px;
  4262. text-shadow: rgb(255 255 255) 0px 0px 10px;
  4263. }
  4264. #pagetual-sideController #pagetual-sideController-pagenum {
  4265. font-size: 15px!important;
  4266. line-height: 30px;
  4267. text-align: center;
  4268. position: absolute;
  4269. right: calc(50% - 15px);
  4270. top: calc(50% - 15px);
  4271. border: 1px solid #00000099;
  4272. display: inline-block;
  4273. width: 30px;
  4274. height: 30px;
  4275. box-sizing: border-box;
  4276. border-radius: 50%;
  4277. background: white;
  4278. opacity: 0;
  4279. transition: opacity .5s ease;
  4280. pointer-events: none;
  4281. }
  4282. #pagetual-sideController.minSize #pagetual-sideController-pagenum {
  4283. opacity: 1;
  4284. }
  4285. #pagetual-sideController:hover {
  4286. opacity: 1;
  4287. }
  4288. #pagetual-sideController>.extra {
  4289. bottom: 170px;
  4290. left: 0px;
  4291. width: 40px;
  4292. position: absolute;
  4293. }
  4294. #pagetual-sideController>.extra>svg {
  4295. width: 40px;
  4296. height: 30px;
  4297. opacity: 0.1;
  4298. cursor: pointer;
  4299. margin: 0 0 5px 0;
  4300. transition: opacity .3s ease;
  4301. }
  4302. #pagetual-sideController.minSize>.extra>svg {
  4303. opacity: 0;
  4304. }
  4305. #pagetual-sideController>.extra>svg:hover {
  4306. opacity: 1;
  4307. }
  4308. #pagetual-sideController.minSize {
  4309. box-shadow: rgb(0 0 0 / 0%) 0px 0px 0px;
  4310. background: #00000000!important;
  4311. pointer-events: none;
  4312. }
  4313. #pagetual-sideController.minSize #pagetual-sideController-move {
  4314. pointer-events: all;
  4315. }
  4316. #pagetual-sideController.minSize .pagetual-sideController-btn {
  4317. opacity: 0;
  4318. }
  4319. `;
  4320. let frame = document.createElement("div");
  4321. frame.id = "pagetual-sideController";
  4322. frame.innerHTML = createHTML(`
  4323. <div class="extra">
  4324. <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>
  4325. <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>
  4326. </div>
  4327. <div id="pagetual-sideController-top" class="pagetual-sideController-btn">⊼</div>
  4328. <div>
  4329. <div id="pagetual-sideController-pre" class="pagetual-sideController-btn">∧</div>
  4330. <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>
  4331. <div id="pagetual-sideController-next" class="pagetual-sideController-btn">∨</div>
  4332. </div>
  4333. <div id="pagetual-sideController-bottom" class="pagetual-sideController-btn">⊻</div>
  4334. `);
  4335. frame.classList.add("stop");
  4336. let top = frame.querySelector("#pagetual-sideController-top");
  4337. let pre = frame.querySelector("#pagetual-sideController-pre");
  4338. let move = frame.querySelector("#pagetual-sideController-move");
  4339. let next = frame.querySelector("#pagetual-sideController-next");
  4340. let bottom = frame.querySelector("#pagetual-sideController-bottom");
  4341. let pagenum = frame.querySelector("#pagetual-sideController-pagenum");
  4342. let scroll = frame.querySelector("#scroll");
  4343. let loadNow = frame.querySelector("#loadNow");
  4344. if (rulesData.sideControllerScroll === false) {
  4345. scroll.style.display = "none";
  4346. }
  4347. if (rulesData.sideControllerLoadNow === false) {
  4348. loadNow.style.display = "none";
  4349. }
  4350. if (sideControllerIcon) move.innerHTML = sideControllerIcon;
  4351.  
  4352. frame.addEventListener("dblclick", e => {
  4353. e.preventDefault();
  4354. e.stopPropagation();
  4355. });
  4356.  
  4357. frame.addEventListener("mouseenter", e => {
  4358. clearTimeout(self.hideTimer);
  4359. frame.classList.remove("minSize");
  4360. });
  4361.  
  4362. frame.addEventListener("mouseleave", e => {
  4363. clearTimeout(self.hideTimer);
  4364. self.hideTimer = setTimeout(() => {
  4365. frame.classList.add("minSize");
  4366. }, 800);
  4367. });
  4368.  
  4369. document.body.addEventListener('touchstart', e => {
  4370. if (e.target === frame || frame.contains(e.target)) {
  4371. frame.classList.remove("minSize");
  4372. } else {
  4373. frame.classList.add("minSize");
  4374. }
  4375. });
  4376.  
  4377. scroll.addEventListener("click", e => {
  4378. autoScroll = (autoScroll ? 0 : prompt(i18n("autoScrollRate"), autoScrollRate)) || 0;
  4379. autoScroll = parseInt(autoScroll) || 0;
  4380. if (autoScroll < 0) autoScroll = 0;
  4381. if (autoScroll && autoScroll != autoScrollRate) {
  4382. autoScrollRate = autoScroll;
  4383. storage.setItem("autoScrollRate", autoScrollRate);
  4384. }
  4385. setListData("autoScroll", location.host + location.pathname, autoScroll);
  4386. startAutoScroll();
  4387. }, true);
  4388.  
  4389. loadNow.addEventListener("click", e => {
  4390. if (autoLoadNum != -1) {
  4391. autoLoadNum = -1;
  4392. return;
  4393. }
  4394. let loadNum = window.prompt(i18n("loadConfirm"), loadNowNum);
  4395. if (loadNum === "" || loadNum === null) return;
  4396. loadNum = Math.abs(parseInt(loadNum)) || 0;
  4397. if (loadNowNum != loadNum) {
  4398. loadNowNum = loadNum;
  4399. storage.setItem("loadNowNum", loadNowNum);
  4400. }
  4401. autoLoadNum = loadNum;
  4402. nextPage();
  4403. }, true);
  4404.  
  4405. pre.addEventListener("click", e => {
  4406. let prePageBar = getPageBar().preBar;
  4407. if (prePageBar) {
  4408. scrollToPageBar(prePageBar);
  4409. } else {
  4410. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  4411. targetY = scrollTop - (window.innerHeight || document.documentElement.clientHeight);
  4412. window.scrollTo({ top: targetY, behavior: 'smooth'});
  4413. }
  4414. }, true);
  4415.  
  4416. next.addEventListener("click", e => {
  4417. let pageBarObj = getPageBar();
  4418. let nextPageBar = pageBarObj.nextBar;
  4419. if (nextPageBar) {
  4420. scrollToPageBar(nextPageBar);
  4421. } else {
  4422. if (pageBarObj.preBar) {
  4423. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  4424. targetY = scrollH || 9999999;
  4425. window.scrollTo({ top: targetY, behavior: 'smooth'});
  4426. } else {
  4427. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  4428. targetY = scrollTop + (window.innerHeight || document.documentElement.clientHeight);
  4429. window.scrollTo({ top: targetY, behavior: 'smooth'});
  4430. }
  4431. }
  4432. }, true);
  4433.  
  4434. top.addEventListener("click", e => {
  4435. getBody(document).scrollTop=0;
  4436. document.documentElement.scrollTop=0;
  4437. e.preventDefault();
  4438. e.stopPropagation();
  4439. }, true);
  4440.  
  4441. bottom.addEventListener("click", e => {
  4442. if (!e.altKey && !e.ctrlKey && !e.shiftKey && !e.metaKey) {
  4443. changeStop(true);
  4444. }
  4445. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  4446. getBody(document).scrollTop = scrollH || 9999999;
  4447. document.documentElement.scrollTop = scrollH || 9999999;
  4448. e.preventDefault();
  4449. e.stopPropagation();
  4450. }, true);
  4451.  
  4452. let initX, initY, moving = false;
  4453. let removeTimer;
  4454. move.addEventListener("click", e => {
  4455. if (!moving) {
  4456. changeStop(!isPause, true);
  4457. }
  4458. }, true);
  4459. move.addEventListener("dblclick", e => {
  4460. clearTimeout(removeTimer);
  4461. document.removeEventListener("mousemove", mouseMoveHandler, true);
  4462. document.removeEventListener("mouseup", mouseUpHandler, true);
  4463. changeStop(!isPause, true);
  4464. if (isPause) {
  4465. ruleParser.hideAddedElements();
  4466. } else {
  4467. ruleParser.showAddedElements();
  4468. }
  4469. }, true);
  4470.  
  4471. move.oncontextmenu = e => {
  4472. e.preventDefault();
  4473. picker.start();
  4474. };
  4475.  
  4476. let clientX = e => {
  4477. if (e.type.indexOf('mouse') === 0) {
  4478. return e.clientX;
  4479. } else {
  4480. return e.changedTouches[0].clientX;
  4481. }
  4482. };
  4483.  
  4484. let clientY = e => {
  4485. if (e.type.indexOf('mouse') === 0) {
  4486. return e.clientY;
  4487. } else {
  4488. return e.changedTouches[0].clientY;
  4489. }
  4490. };
  4491.  
  4492. let mouseMoveHandler = e => {
  4493. if (moving) {
  4494. let windowHeight = window.innerHeight || document.documentElement.clientHeight;
  4495. let windowWidth = window.innerWidth || document.documentElement.clientWidth;
  4496. initX = (clientX(e) - 10 + 40) / windowWidth * 100;
  4497. initY = (clientY(e) - 83 + 83) / windowHeight * 100;
  4498. this.frame.style.top = `calc(${initY}% - 83px)`;
  4499. this.frame.style.left = `calc(${initX}% - 40px)`;
  4500. } else if (Math.abs(clientX(e) - initX) + Math.abs(clientY(e) - initY) > 5) {
  4501. moving = true;
  4502. clearTimeout(removeTimer);
  4503. }
  4504. };
  4505. let mouseUpHandler = e => {
  4506. clearTimeout(removeTimer);
  4507. document.removeEventListener("mousemove", mouseMoveHandler, true);
  4508. document.removeEventListener("mouseup", mouseUpHandler, true);
  4509. document.removeEventListener("touchmove", mouseMoveHandler, true);
  4510. document.removeEventListener("touchend", mouseUpHandler, true);
  4511. if (moving) {
  4512. rulesData.sideControllerPos = {x: parseInt(initX), y: parseInt(initY)};
  4513. storage.setItem("rulesData", rulesData);
  4514. }
  4515. };
  4516. let mouseDownHandler = e => {
  4517. initX = clientX(e);
  4518. initY = clientY(e);
  4519. moving = false;
  4520. clearTimeout(removeTimer);
  4521. removeTimer = setTimeout(() => {
  4522. if (e.type === "touchstart") {
  4523. picker.start();
  4524. } else {
  4525. self.remove();
  4526. }
  4527. }, 1500);
  4528. document.addEventListener("mousemove", mouseMoveHandler, true);
  4529. document.addEventListener("mouseup", mouseUpHandler, true);
  4530. document.addEventListener("touchmove", mouseMoveHandler, true);
  4531. document.addEventListener("touchend", mouseUpHandler, true);
  4532. e.stopPropagation();
  4533. e.preventDefault();
  4534. };
  4535.  
  4536. move.addEventListener("mousedown", mouseDownHandler, true);
  4537. move.addEventListener("touchstart", mouseDownHandler, { passive: false, capture: true });
  4538.  
  4539. this.frame = frame;
  4540. this.pagenum = pagenum;
  4541. if (rulesData.sideControllerPos) {
  4542. this.frame.style.top = `calc(${rulesData.sideControllerPos.y}% - 83px)`;
  4543. this.frame.style.left = `calc(${rulesData.sideControllerPos.x}% - 40px)`;
  4544. }
  4545. }
  4546.  
  4547. addToStage() {
  4548. this.init();
  4549. if (!this.styleEle || !this.styleEle.parentNode) {
  4550. this.styleEle = _GM_addStyle(this.cssText);
  4551. }
  4552. if (!isPause) {
  4553. this.frame.classList.remove("stop");
  4554. }
  4555. this.pagenum.innerHTML = createHTML(curPage);
  4556. this.frame.title = i18n("page") + curPage;
  4557. if (this.frame.parentNode) return;
  4558. getBody(document).appendChild(this.frame);
  4559. clearTimeout(this.hideTimer);
  4560. this.frame.classList.add("minSize");
  4561. }
  4562.  
  4563. remove() {
  4564. if (this.frame && this.frame.parentNode) this.frame.parentNode.removeChild(this.frame);
  4565. }
  4566. }
  4567. const sideController = new SideController();
  4568.  
  4569. class NextSwitch {
  4570. //static nextSwitch;
  4571. constructor() {
  4572. this.inited = false;
  4573. }
  4574.  
  4575. /*static getInstance() {
  4576. if (!NextSwitch.nextSwitch) {
  4577. NextSwitch.nextSwitch = new NextSwitch();
  4578. }
  4579. return NextSwitch.nextSwitch;
  4580. }*/
  4581.  
  4582. init() {
  4583. if (this.inited) return;
  4584. this.inited = true;
  4585. let self = this;
  4586. this.cssText = `
  4587. #pagetual-nextSwitch {
  4588. position: fixed;
  4589. top: 10px;
  4590. left: calc(50% - 160px);
  4591. background: aliceblue;
  4592. padding: 10px;
  4593. border-radius: 5px;
  4594. text-align: center;
  4595. opacity: 0.95;
  4596. color: #161616;
  4597. z-index: 2147483647;
  4598. font-size: 16px;
  4599. box-shadow: rgb(0 0 0) 0px 0px 10px;
  4600. }
  4601. #pagetual-nextSwitch>.title {
  4602. margin: -5px 45px 10px 45px;
  4603. font-size: 20px;
  4604. font-weight: bold;
  4605. border-bottom: 1px solid black;
  4606. user-select: none;
  4607. color: orangered;
  4608. }
  4609. #pagetual-nextSwitch>.group {
  4610. display: flex;
  4611. flex-direction: column;
  4612. }
  4613. #pagetual-nextSwitch>.group>span {
  4614. color: #161616;
  4615. cursor: pointer;
  4616. margin: 3px;
  4617. font-size: larger;
  4618. }
  4619. #pagetual-nextSwitch>.group>span:hover {
  4620. color: red;
  4621. }
  4622. #pagetual-nextSwitch>.group>span.current {
  4623. border: 2px dotted red;
  4624. border-radius: 10px;
  4625. }
  4626. #pagetual-nextSwitch>.closeSwitch {
  4627. position: absolute;
  4628. top: 3px;
  4629. right: 10px;
  4630. background: none;
  4631. border: none;
  4632. vertical-align: top;
  4633. transition: transform .15s ease-in-out;
  4634. float: right;
  4635. cursor: pointer;
  4636. }
  4637. #pagetual-nextSwitch svg {
  4638. width: 30px;
  4639. height: 30px;
  4640. vertical-align: middle;
  4641. fill: #161616;
  4642. overflow: hidden;
  4643. }
  4644. #pagetual-nextSwitch button:hover {
  4645. transform: scale(1.2);
  4646. }
  4647. `;
  4648. let frame = document.createElement("div");
  4649. frame.id = "pagetual-nextSwitch";
  4650. frame.innerHTML = createHTML(`
  4651. <div class="title">${i18n("nextSwitch")}</div>
  4652. <button type="button" class="closeSwitch">
  4653. <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2754">
  4654. <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">
  4655. </path>
  4656. </svg>
  4657. </button>
  4658. <div class="group"></div>
  4659. `);
  4660. let group = frame.querySelector(".group");
  4661. let closeBtn = frame.querySelector(".closeSwitch");
  4662. closeBtn.addEventListener("click", e => {
  4663. self.close();
  4664. }, true);
  4665. this.frame = frame;
  4666. let currentSpan;
  4667. ruleParser.curSiteRule.nextLink.forEach((link, i) => {
  4668. let span = document.createElement("span");
  4669. let target = getElement(link, document);
  4670. let index = "<b>" + (i + 1) + "</b>: ";
  4671. if (target) {
  4672. let targetInner = target.innerText.trim();
  4673. span.innerHTML = index + (targetInner || link);
  4674. } else {
  4675. span.innerHTML = index + "Not Found";
  4676. }
  4677. span.title = link;
  4678. span.addEventListener("click", e => {
  4679. if (currentSpan) currentSpan.classList.remove("current");
  4680. span.classList.add("current");
  4681. currentSpan = span;
  4682. nextIndex = i;
  4683. setListData("nextSwitch", location.host, nextIndex === 0 ? "" : nextIndex);
  4684. ruleParser.curUrl += "#pagetual";
  4685. ruleParser.oldUrl = ruleParser.curUrl;
  4686. autoLoadNum = -1;
  4687. if (!ruleParser.nextLinkHref) {
  4688. isLoading = false;
  4689. }
  4690. ruleParser.getNextLink(ruleParser.pageDoc || document);
  4691. self.close();
  4692. }, true);
  4693. if (i == nextIndex) {
  4694. span.classList.add("current");
  4695. currentSpan = span;
  4696. }
  4697. group.appendChild(span);
  4698. });
  4699. }
  4700.  
  4701. start() {
  4702. this.init();
  4703. if (!this.styleEle || !this.styleEle.parentNode) {
  4704. this.styleEle = _GM_addStyle(this.cssText);
  4705. }
  4706. document.documentElement.appendChild(this.frame);
  4707. }
  4708.  
  4709. close() {
  4710. if (this.frame.parentNode) this.frame.parentNode.removeChild(this.frame);
  4711. }
  4712. }
  4713. const nextSwitch = new NextSwitch();
  4714.  
  4715. class Picker {
  4716. //static picker;
  4717. constructor() {
  4718. this.inited = false;
  4719. }
  4720.  
  4721. /*static getInstance() {
  4722. if (!Picker.picker) {
  4723. Picker.picker = new Picker();
  4724. }
  4725. return Picker.picker;
  4726. }*/
  4727.  
  4728. init() {
  4729. if (this.inited) return;
  4730. this.inited = true;
  4731. let self = this;
  4732. this.signList = [];
  4733. this.cssText = `
  4734. body.pagetual-picker,
  4735. body.pagetual-picker *:hover,
  4736. body.pagetual-picker a:hover {
  4737. cursor: crosshair !important;
  4738. }
  4739. #pagetual-picker {
  4740. position: fixed;
  4741. top: 10px;
  4742. left: calc(50% - 178px);
  4743. background: aliceblue;
  4744. padding: 10px;
  4745. border-radius: 5px;
  4746. text-align: center;
  4747. opacity: 0.95;
  4748. color: #161616;
  4749. z-index: 2147483646;
  4750. font-size: 16px;
  4751. overflow: hidden;
  4752. box-shadow: rgb(0 0 0) 0px 0px 10px;
  4753. }
  4754. #pagetual-picker * {
  4755. margin: 0;
  4756. padding: 0;
  4757. font-family: Times New Roman;
  4758. overflow: initial;
  4759. user-select: none;
  4760. line-height: unset;
  4761. min-width: unset;
  4762. min-height: unset;
  4763. }
  4764. #pagetual-picker>.title {
  4765. margin: -5px 45px 10px 45px;
  4766. font-size: 20px;
  4767. font-weight: bold;
  4768. cursor: pointer;
  4769. border-bottom: 1px solid black;
  4770. user-select: none;
  4771. color: orangered;
  4772. height: initial;
  4773. width: initial;
  4774. position: initial;
  4775. transition: transform .3s ease;
  4776. }
  4777. #pagetual-picker>.title:hover {
  4778. transform: scale(1.1);
  4779. }
  4780. #pagetual-picker button {
  4781. background: none;
  4782. border: none;
  4783. vertical-align: top;
  4784. transition: transform .15s ease-in-out;
  4785. float: right;
  4786. cursor: pointer;
  4787. overflow: hidden;
  4788. background-color: unset!important;
  4789. }
  4790. #pagetual-picker button:hover {
  4791. transform: scale(1.2);
  4792. }
  4793. #pagetual-picker>.closePicker {
  4794. position: absolute;
  4795. top: 3px;
  4796. right: 10px;
  4797. }
  4798. #pagetual-picker>.logoIcon {
  4799. position: absolute;
  4800. top: 3px;
  4801. left: 10px;
  4802. }
  4803. #pagetual-picker>.logoIcon.showSign>svg>path {
  4804. fill: gray!important;
  4805. }
  4806. #pagetual-picker textarea{
  4807. display: inline-block;
  4808. width: calc(100% - 65px);
  4809. height: 20px;
  4810. min-width: 250px;
  4811. max-width: calc(65vw - 50px);
  4812. min-height: unset;
  4813. max-height: unset;
  4814. padding: 6px 12px;
  4815. font-size: 16px;
  4816. font-weight: 400;
  4817. line-height: 1.5;
  4818. color: #495057;
  4819. background-color: #fff;
  4820. background-clip: padding-box;
  4821. border: 1px solid #ced4da;
  4822. border-radius: 4px;
  4823. transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
  4824. box-sizing: content-box;
  4825. margin-right: 5px;
  4826. resize: both;
  4827. box-shadow: 0 1px 5px 1px #ddd;
  4828. overflow-wrap: anywhere;
  4829. }
  4830. #pagetual-picker textarea:focus {
  4831. color: black;
  4832. background-color: #fff;
  4833. border-color: #80bdff;
  4834. outline: 0;
  4835. box-shadow: 0 0 0 3.2px rgb(0 123 255 / 25%);
  4836. }
  4837. #pagetual-picker [type=checkbox],
  4838. #pagetual-picker [type=radio] {
  4839. line-height: 20px;
  4840. height: 25px;
  4841. width: 25px;
  4842. margin-left: 5px;
  4843. vertical-align: middle;
  4844. appearance: auto;
  4845. display: inline-block;
  4846. position: initial;
  4847. }
  4848. #pagetual-picker [type=checkbox]:after,
  4849. #pagetual-picker [type=radio]:after,
  4850. #pagetual-picker [type=checkbox]:before,
  4851. #pagetual-picker [type=radio]:before {
  4852. border: none;
  4853. background: none;
  4854. }
  4855. #pagetual-picker label {
  4856. font-size: 18px;
  4857. line-height: 25px;
  4858. vertical-align: middle;
  4859. display: inline-block;
  4860. color: black;
  4861. position: initial;
  4862. cursor: pointer;
  4863. }
  4864. #pagetual-picker .bottom {
  4865. text-align: left;
  4866. margin: 10px 0;
  4867. width: 100%;
  4868. }
  4869. #pagetual-picker .bottom>button {
  4870. float: right;
  4871. }
  4872. #pagetual-picker svg {
  4873. width: 30px;
  4874. height: 30px;
  4875. vertical-align: middle;
  4876. fill: #161616;
  4877. overflow: hidden;
  4878. }
  4879. #pagetual-picker svg * {
  4880. pointer-events: none;
  4881. }
  4882. #pagetual-picker .allpath {
  4883. font-size: 18px;
  4884. margin: 10px auto;
  4885. max-width: 330px;
  4886. word-break: break-all;
  4887. cursor: context-menu;
  4888. overflow: hidden;
  4889. max-height: 42px;
  4890. -moz-transition:max-height 1s ease-in;
  4891. -webkit-transition:max-height 1s ease-in;
  4892. transition:max-height 1s ease-in;
  4893. color: black;
  4894. }
  4895. #pagetual-picker .allpath:hover {
  4896. max-height: calc(100vh - 130px);
  4897. overflow: auto;
  4898. }
  4899. #pagetual-picker .allpath>span.path {
  4900. cursor: pointer;
  4901. }
  4902. #pagetual-picker .allpath>span.path:hover {
  4903. opacity: 0.6;
  4904. }
  4905. #pagetual-picker .allpath>span.path:hover,
  4906. #pagetual-picker .allpath>span.path.checked {
  4907. color: orangered;
  4908. }
  4909. #pagetual-picker .moreConfig {
  4910. display: flex;
  4911. justify-content: space-between;
  4912. border-top: 1px solid;
  4913. padding-top: 10px;
  4914. width: 100%;
  4915. }
  4916. #pagetual-picker .command {
  4917. width: 100%;
  4918. color: black!important;
  4919. text-align: center;
  4920. font-size: large;
  4921. margin-top: 10px;
  4922. box-shadow: 0 1px 6px 0 rgba(0, 0, 0, 0.12);
  4923. border-radius: 5px;
  4924. }
  4925. #pagetual-picker .command:hover {
  4926. color: orangered;
  4927. }
  4928. #pagetual-picker #showDetail {
  4929. float: initial;
  4930. margin-top: 10px;
  4931. }
  4932. #pagetual-picker.showDetail #showDetail {
  4933. float: right;
  4934. }
  4935. #pagetual-picker #showDetail>svg {
  4936. -moz-transition:transform 0.3s ease;
  4937. -webkit-transition:transform 0.3s ease;
  4938. transition:transform 0.3 ease;
  4939. }
  4940. #pagetual-picker.showDetail #showDetail>svg {
  4941. transform: rotate(180deg);
  4942. }
  4943. #pagetual-picker .tempRule {
  4944. display: none;
  4945. margin-top: 10px;
  4946. height: 300px;
  4947. min-height: 150px;
  4948. }
  4949. #pagetual-picker.showDetail .tempRule {
  4950. display: inline-block;
  4951. word-break: break-all;
  4952. }
  4953. #pagetual-picker #saveDetail {
  4954. display: none;
  4955. position: absolute;
  4956. bottom: 10px;
  4957. right: 8px;
  4958. }
  4959. #pagetual-picker.showDetail #saveDetail {
  4960. display: inline-block;
  4961. }
  4962. #pagetual-picker #saveDetail svg {
  4963. width: 35px;
  4964. height: 35px;
  4965. }
  4966. #pagetual-picker .addProp {
  4967. display: none;
  4968. flex-direction: column;
  4969. position: absolute;
  4970. bottom: 45px;
  4971. right: 12px;
  4972. }
  4973. #pagetual-picker.showDetail .addProp {
  4974. display: flex;
  4975. }
  4976. #pagetual-picker .addProp>button {
  4977. font-size: 30px;
  4978. font-family: Arial,sans-serif;
  4979. line-height: 35px;
  4980. color: #161616;
  4981. }
  4982. #pagetual-picker #edit{
  4983. -webkit-animation: jumpAnimation .6s 5;
  4984. animation: jumpAnimation .6s 5;
  4985. }
  4986. @keyframes jumpAnimation {
  4987. 0% {
  4988. transform: scale(1) translateY(0);
  4989. animation-timing-function: ease-out;
  4990. }
  4991. 50% {
  4992. transform: scale(1.2) translateY(-5px);
  4993. animation-timing-function: ease-in;
  4994. }
  4995. 100% {
  4996. transform: scale(1) translateY(0);
  4997. animation-timing-function: ease-out;
  4998. }
  4999. }
  5000. @-webkit-keyframes jumpAnimation {
  5001. 0% {
  5002. -webkit-transform: scale(1) translateY(0);
  5003. animation-timing-function: ease-out;
  5004. }
  5005. 50% {
  5006. -webkit-transform: scale(1.2) translateY(-5px);
  5007. animation-timing-function: ease-in;
  5008. }
  5009. 100% {
  5010. -webkit-transform: scale(1) translateY(0);
  5011. animation-timing-function: ease-out;
  5012. }
  5013. }
  5014. `;
  5015. this.mainSignDiv = this.createSignDiv();
  5016. this.allSignDiv = [];
  5017. let frame = document.createElement("div");
  5018. frame.id = "pagetual-picker";
  5019. frame.innerHTML = createHTML(`
  5020. <button title="Pagetual" type="button" class="logoIcon">
  5021. <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>
  5022. </button>
  5023. <div class="title" title="${i18n("configure")}">${i18n("picker")}</div>
  5024. <button title="${i18n("closePicker")}" type="button" class="closePicker">
  5025. <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>
  5026. </button>
  5027. <div class="allpath" title="${i18n("switchSelector")}"></div>
  5028. <div>
  5029. <textarea class="selector" spellcheck="false" name="selector" placeholder="${i18n("pickerPlaceholder")}"></textarea>
  5030. <button id="check" title="${i18n("pickerCheck")}" type="button">
  5031. <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>
  5032. </button>
  5033. </div>
  5034. <div class="bottom">
  5035. <input name="xpath" id="checkbox_id" type="checkbox" />
  5036. <label for="checkbox_id">XPath</label>
  5037. <button id="edit" title="${i18n("gotoEdit")}" type="button">
  5038. <svg viewBox="0 0 1024 1024" style="color: orangered;fill: orangered;" version="1.1" xmlns="http://www.w3.org/2000/svg">
  5039. <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">
  5040. </path>
  5041. </svg>
  5042. </button>
  5043. </div>
  5044. <div class="moreConfig">
  5045. <div title="${i18n('forceStateIframe')}">
  5046. <input name="forceState" id="forceStateIframe" type="radio" />
  5047. <label for="forceStateIframe">${i18n('iframe')}</label>
  5048. </div>
  5049. <div title="${i18n('forceStateDynamic')}">
  5050. <input name="forceState" id="forceStateDynamic" type="radio" />
  5051. <label for="forceStateDynamic">${i18n('dynamic')}</label>
  5052. </div>
  5053. <div title="${i18n('forceStateDisable')}">
  5054. <input name="forceState" id="forceStateDisable" type="radio" />
  5055. <label for="forceStateDisable">${i18n('disable')}</label>
  5056. </div>
  5057. </div>
  5058. <button id="nextSwitch" class="command" title="${i18n("nextSwitch")}" type="button">${i18n("nextSwitch")}</button>
  5059. <button id="loadNow" class="command" title="${i18n("loadNow")}" type="button">${i18n("loadNow")}</button>
  5060. <button id="autoScroll" class="command" title="${i18n("toggleAutoScroll")}" type="button"></button>
  5061. <button id="ruleRequest" class="command" title="${i18n("ruleRequest")}" type="button">${i18n("ruleRequest")}</button>
  5062. <div>
  5063. <textarea class="tempRule" spellcheck="false" placeholder="{Rule object}" title="Rule for current site"></textarea>
  5064. <button id="showDetail" title="" type="button">
  5065. <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>
  5066. </button>
  5067. <div class="addProp">
  5068. <button id="addOtherProp" title="${i18n("addOtherProp")}" type="button">+</button>
  5069. <button id="addNextSelector" title="${i18n("addNextSelector")}" type="button">></button>
  5070. <button id="addPageSelector" title="${i18n("addPageSelector")}" type="button">❏</button>
  5071. </div>
  5072. <button id="saveDetail" title="${i18n("save")}" type="button">
  5073. <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>
  5074. </button>
  5075. </div>
  5076. `);
  5077. let forceStateIframe = frame.querySelector("#forceStateIframe");//forceState 1 禁用 2 强嵌 3 动态
  5078. let forceStateDynamic = frame.querySelector("#forceStateDynamic");
  5079. let forceStateDisable = frame.querySelector("#forceStateDisable");
  5080. let clickRadio = e => {
  5081. let radio = e.currentTarget.querySelector('input');
  5082. if (radio.checked) {
  5083. forceState = "";
  5084. } else {
  5085. switch (radio.id) {
  5086. case "forceStateIframe":
  5087. forceState = 2;
  5088. break;
  5089. case "forceStateDynamic":
  5090. forceState = 3;
  5091. break;
  5092. case "forceStateDisable":
  5093. forceState = 1;
  5094. break;
  5095. default:
  5096. return;
  5097. }
  5098. }
  5099. setListData("forceState", location.host, forceState);
  5100. self.close();
  5101. setTimeout(() => {
  5102. location.reload();
  5103. }, 500);
  5104. };
  5105. forceStateIframe.parentNode.addEventListener("mousedown", clickRadio);
  5106. forceStateDynamic.parentNode.addEventListener("mousedown", clickRadio);
  5107. forceStateDisable.parentNode.addEventListener("mousedown", clickRadio);
  5108. if (forceState == 1) forceStateDisable.checked = true;
  5109. else if (forceState == 2) forceStateIframe.checked = true;
  5110. else if (forceState == 3) forceStateDynamic.checked = true;
  5111. let closeBtn = frame.querySelector(".closePicker");
  5112. let logoBtn = frame.querySelector(".logoIcon");
  5113. let title = frame.querySelector(".title");
  5114. let allpath = frame.querySelector(".allpath");
  5115. let selectorInput = frame.querySelector(".selector");
  5116. let xpath = frame.querySelector("#checkbox_id");
  5117. let checkBtn = frame.querySelector("#check");
  5118. let editBtn = frame.querySelector("#edit");
  5119. let nextSwitchBtn = frame.querySelector("#nextSwitch");
  5120. let autoScrollBtn = frame.querySelector("#autoScroll");
  5121. let loadNow = frame.querySelector("#loadNow");
  5122. let tempRule = frame.querySelector(".tempRule");
  5123. let showDetailBtn = frame.querySelector("#showDetail");
  5124. let saveDetailBtn = frame.querySelector("#saveDetail");
  5125. let addOtherProp = frame.querySelector("#addOtherProp");
  5126. let addNextSelector = frame.querySelector("#addNextSelector");
  5127. let addPageSelector = frame.querySelector("#addPageSelector");
  5128. let ruleRequestBtn = frame.querySelector("#ruleRequest");
  5129. ruleRequestBtn.addEventListener("click", e => {
  5130. _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});
  5131. }, true);
  5132. autoScrollBtn.addEventListener("click", e => {
  5133. self.close();
  5134. autoScroll = (autoScroll ? 0 : prompt(i18n("autoScrollRate"), autoScrollRate)) || 0;
  5135. autoScroll = parseInt(autoScroll) || 0;
  5136. if (autoScroll < 0) autoScroll = 0;
  5137. if (autoScroll && autoScroll != autoScrollRate) {
  5138. autoScrollRate = autoScroll;
  5139. storage.setItem("autoScrollRate", autoScrollRate);
  5140. }
  5141. setListData("autoScroll", location.host + location.pathname, autoScroll);
  5142. startAutoScroll();
  5143. }, true);
  5144. addOtherProp.addEventListener("click", e => {
  5145. let propName = prompt(i18n("propName"), "author");
  5146. if (!propName) return;
  5147. let propValue = prompt(i18n("propValue"));
  5148. if (!propValue) return;
  5149. if (propValue === "true") propValue = true;
  5150. else if (propValue === "false") propValue = false;
  5151. else if (/^\d+$/.test(propValue)) propValue = parseInt(propValue);
  5152. if (propName === "author" && propValue) {
  5153. author = propValue;
  5154. storage.setItem("author", propValue);
  5155. }
  5156. let editTemp = self.getTempRule();
  5157. if (!editTemp) return;
  5158. editTemp[propName] = propValue;
  5159. self.tempRule.value = JSON.stringify(editTemp, null, 4);
  5160. }, true);
  5161. addNextSelector.addEventListener("click", e => {
  5162. let editTemp = self.getTempRule();
  5163. if (!editTemp) return;
  5164. let selector = self.selectorInput.value;
  5165. if (selector) {
  5166. editTemp.nextLink = selector;
  5167. }
  5168. self.tempRule.value = JSON.stringify(editTemp, null, 4);
  5169. }, true);
  5170. addPageSelector.addEventListener("click", e => {
  5171. let editTemp = self.getTempRule();
  5172. if (!editTemp) return;
  5173. let selector = self.selectorInput.value;
  5174. if (selector) {
  5175. editTemp.pageElement = selector;
  5176. }
  5177. self.tempRule.value = JSON.stringify(editTemp, null, 4);
  5178. }, true);
  5179. showDetailBtn.addEventListener("click", e => {
  5180. frame.classList.toggle("showDetail");
  5181. }, true);
  5182. saveDetailBtn.addEventListener("click", e => {
  5183. let editTemp = self.getTempRule(true);
  5184. if (tempRule.value && !editTemp) {
  5185. return;
  5186. }
  5187. if(!ruleParser.customRules) {
  5188. ruleParser.customRules = [];
  5189. }
  5190. ruleParser.customRules = ruleParser.customRules.filter(item => {return item.url != editTemp.url || item.name != editTemp.name});
  5191. if (tempRule.value) {
  5192. ruleParser.customRules.unshift(editTemp);
  5193. ruleParser.curSiteRule = editTemp;
  5194. } else {
  5195. ruleParser.curSiteRule = {};
  5196. isPause = true;
  5197. }
  5198. storage.setItem("customRules", ruleParser.customRules);
  5199. if (ruleParser.hpRules && ruleParser.curSiteRule && !ruleParser.curSiteRule.smart) {
  5200. ruleParser.addToHpRules(true);
  5201. }
  5202. if (window.confirm(i18n("reloadPage"))) {
  5203. setTimeout(() => {location.reload()}, 100);
  5204. }
  5205. }, true);
  5206. nextSwitchBtn.addEventListener("click", e => {
  5207. self.close();
  5208. nextSwitch.start();
  5209. }, true);
  5210. loadNow.addEventListener("click", e => {
  5211. self.close();
  5212. let loadNum = window.prompt(i18n("loadConfirm"), "1");
  5213. if (loadNum === "" || loadNum === null) return;
  5214. autoLoadNum = Math.abs(parseInt(loadNum));
  5215. nextPage();
  5216. }, true);
  5217. closeBtn.addEventListener("click", e => {
  5218. self.close();
  5219. }, true);
  5220. this.showSign = true;
  5221. logoBtn.addEventListener("click", e => {
  5222. logoBtn.classList.toggle("showSign");
  5223. self.showSign = !self.showSign;
  5224. getBody(document).classList.toggle("pagetual-picker");
  5225. }, true);
  5226. let moving = false;
  5227. let initX = 0, initY = 0, initPos = {x: 0, y: 0};
  5228. let moveHanlder = e => {
  5229. if (moving) {
  5230. frame.style.left = e.clientX - initX + "px";
  5231. frame.style.top = e.clientY - initY + "px";
  5232. e.stopPropagation();
  5233. e.preventDefault();
  5234. } else if(Math.abs(e.clientX - initPos.x) + Math.abs(e.clientY - initPos.y) > 20) {
  5235. moving = true;
  5236. }
  5237. };
  5238. let upHanlder = e => {
  5239. if (moving) {
  5240. moving = false;
  5241. } else {
  5242. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  5243. }
  5244. document.removeEventListener("mousemove", moveHanlder, true);
  5245. title.removeEventListener("mouseup", upHanlder, true);
  5246. e.stopPropagation();
  5247. e.preventDefault();
  5248. };
  5249. title.addEventListener("mousedown", e => {
  5250. initPos = {x: e.clientX, y: e.clientY};
  5251. initX = e.clientX - parseInt(getComputedStyle(frame).left);
  5252. initY = e.clientY - parseInt(getComputedStyle(frame).top);
  5253. document.addEventListener("mousemove", moveHanlder, true);
  5254. title.addEventListener("mouseup", upHanlder, true);
  5255. });
  5256. frame.addEventListener("mouseenter", e => {
  5257. if (!self.showSign || moving) return;
  5258. if (self.mainSignDiv.parentNode) self.mainSignDiv.parentNode.removeChild(self.mainSignDiv);
  5259. self.checkInputSelector(false);
  5260. });
  5261. frame.addEventListener("mouseleave", e => {
  5262. if (!self.showSign) {
  5263. if (self.mainSignDiv.parentNode) self.mainSignDiv.parentNode.removeChild(self.mainSignDiv);
  5264. self.clearSigns();
  5265. return;
  5266. }
  5267. if (moving) return;
  5268. document.documentElement.appendChild(self.mainSignDiv);
  5269. self.clearSigns();
  5270. });
  5271. checkBtn.addEventListener("click", e => {
  5272. self.checkInputSelector();
  5273. if (this.selectorInput.value && self.foundEle) {
  5274. debug(self.foundEle);
  5275. self.foundEle[0].scrollIntoView({ behavior: "smooth" });
  5276. _GM_setClipboard(this.selectorInput.value);
  5277. showTips(i18n("copied"));
  5278. } else showTips("Null");
  5279. });
  5280. xpath.addEventListener("click", e => {
  5281. if (!selectorInput.value) {
  5282. self.setSelectorDiv("");
  5283. return;
  5284. }
  5285. let element = getElement(selectorInput.value, document);
  5286. let selector = self.getSelectorFromEle(element);
  5287. selectorInput.value = selector;
  5288. self.setSelectorDiv(selector);
  5289. });
  5290. editBtn.addEventListener("click", e => {
  5291. rulesData.editTemp = self.getTempRule();
  5292. storage.setItem("rulesData", rulesData);
  5293. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  5294. });
  5295. editBtn.oncontextmenu = e => {
  5296. e.preventDefault();
  5297. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  5298. };
  5299. this.frame = frame;
  5300. this.xpath = xpath;
  5301. this.allpath = allpath;
  5302. this.selectorInput = selectorInput;
  5303. this.nextSwitchBtn = nextSwitchBtn;
  5304. this.autoScrollBtn = autoScrollBtn;
  5305. this.loadNow = loadNow;
  5306. this.tempRule = tempRule;
  5307. this.logoBtn = logoBtn;
  5308. let setTitleTimer;
  5309. this.moveHandler = e => {
  5310. if (!self.showSign || e.target === document) return;
  5311. let target = self.getTarget(e.target);
  5312. self.adjustSignDiv(self.mainSignDiv, target);
  5313. clearTimeout(setTitleTimer);
  5314. setTitleTimer = setTimeout(() => {
  5315. if (self.inPicker && target.hasAttributes()) {
  5316. let title = target.nodeName.toLowerCase() + "\n";
  5317. for (const attr of target.attributes) {
  5318. title += `【${attr.name}】${attr.value ? " ➡️ " + attr.value : ""}\n`;
  5319. }
  5320. getBody(document).title = title;
  5321. }
  5322. }, 100);
  5323. };
  5324. this.clickHandler = e => {
  5325. if (!self.showSign || !e.isTrusted) return;
  5326. if (self.inPicker) {
  5327. e.stopPropagation();
  5328. e.preventDefault();
  5329. }
  5330. let target = self.getTarget(e.target);
  5331. let selector = self.getSelectorFromEle(target);
  5332. selectorInput.value = selector;
  5333. self.setSelectorDiv(selector);
  5334. };
  5335. }
  5336.  
  5337. getTempRule(detail) {
  5338. if (this.tempRule.value) {
  5339. try {
  5340. this.editTemp = JSON.parse(this.tempRule.value);
  5341. } catch (e) {
  5342. this.editTemp = null;
  5343. if (detail) {
  5344. let pos = e && e.message && e.message.match(/position (\d+)/);
  5345. if (pos) {
  5346. pos = parseInt(pos[1]);
  5347. this.tempRule.value = this.tempRule.value.slice(0, pos) + "➡️" + this.tempRule.value.slice(pos);
  5348. }
  5349. showTips(i18n("errorJson"));
  5350. return null;
  5351. }
  5352. }
  5353. }
  5354. if (!this.editTemp) {
  5355. if (ruleParser.curSiteRule.url && !ruleParser.curSiteRule.smart) {
  5356. this.editTemp = ruleParser.curSiteRule;
  5357. } else {
  5358. this.editTemp = {
  5359. name: document.title,
  5360. url: "^" + (location.origin + location.pathname).replace(/[^\/]*$/, "").replace(/^https?/, "https?").replace(/\./g, "\\."),
  5361. example: location.href
  5362. };
  5363. if (author) this.editTemp.author = author;
  5364. }
  5365. delete this.editTemp.from;
  5366. delete this.editTemp.type;
  5367. delete this.editTemp.updatedAt;
  5368. }
  5369. if (this.selectorInput.value && (!this.frame.classList.contains("showDetail") || !this.editTemp || !this.editTemp.pageElement)) {
  5370. if (this.foundEle && this.foundEle.length === 1) {
  5371. let foundEleRect = this.foundEle[0].getBoundingClientRect();
  5372. if (foundEleRect.height < 100) {
  5373. showTips("Next Link", "", 500);
  5374. this.editTemp.nextLink = this.selectorInput.value;
  5375. return this.editTemp;
  5376. }
  5377. }
  5378. showTips("Page Element", "", 500);
  5379. this.editTemp.pageElement = this.selectorInput.value;
  5380. }
  5381. return this.editTemp;
  5382. }
  5383.  
  5384. getTarget(ele) {
  5385. while (ele.parentNode && (ele.offsetWidth === 0 || ele.offsetHeight === 0)) {
  5386. ele = ele.parentNode;
  5387. }
  5388. return ele;
  5389. }
  5390.  
  5391. close() {
  5392. this.clearSigns();
  5393. if (this.frame.parentNode) this.frame.parentNode.removeChild(this.frame);
  5394. if (this.mainSignDiv.parentNode) this.mainSignDiv.parentNode.removeChild(this.mainSignDiv);
  5395. getBody(document).classList.remove("pagetual-picker");
  5396. getBody(document).removeEventListener("mousemove", this.moveHandler, true);
  5397. getBody(document).removeEventListener("click", this.clickHandler, true);
  5398. getBody(document).title = "";
  5399. this.inPicker = false;
  5400. }
  5401.  
  5402. setImportant(ele, prop, value) {
  5403. ele.style.setProperty(prop, value, "important");
  5404. }
  5405.  
  5406. createSignDiv() {
  5407. let signDiv = document.createElement("div");
  5408. this.setImportant(signDiv, "position", "absolute");
  5409. this.setImportant(signDiv, "pointer-events", "none");
  5410. this.setImportant(signDiv, "z-index", "2147483645");
  5411. this.setImportant(signDiv, "background", "rgba(120, 170, 210, 0.6)");
  5412. this.setImportant(signDiv, "transition", "all 0.15s ease-out");
  5413. this.setImportant(signDiv, "box-shadow", "rgb(0 0 0) 0px 0px 3px 0px");
  5414. return signDiv;
  5415. }
  5416.  
  5417. adjustSignDiv(div, target) {
  5418. let rect = target.getBoundingClientRect();
  5419. this.setImportant(div, "width", rect.width + "px");
  5420. this.setImportant(div, "height", rect.height + "px");
  5421. this.setImportant(div, "left", rect.left + window.scrollX + "px");
  5422. this.setImportant(div, "top", rect.top + window.scrollY + "px");
  5423. }
  5424.  
  5425. getSelectorFromEle(ele) {
  5426. return this.xpath.checked ? createXPathFromElement(ele) : geneSelector(ele, true);
  5427. }
  5428.  
  5429. fillTempRuleTextarea() {
  5430. if (!this.frame.classList.contains("showDetail") || !this.editTemp || !this.editTemp.pageElement) this.tempRule.value = JSON.stringify(this.getTempRule(), null, 4);
  5431. }
  5432.  
  5433. setSelectorDiv(selector) {
  5434. let self = this;
  5435. this.allpath.innerHTML = createHTML("");
  5436. if (selector) {
  5437. if (this.xpath.checked) {
  5438. let span = document.createElement("span");
  5439. span.innerText = selector;
  5440. span.addEventListener("click", e => {
  5441. self.selectorInput.value = selector;
  5442. self.checkInputSelector();
  5443. }, true);
  5444. this.allpath.appendChild(span);
  5445. } else {
  5446. selector.split(">").forEach((item, index) => self.geneSelectorItem(item, index));
  5447. }
  5448. }
  5449. this.checkInputSelector();
  5450. }
  5451.  
  5452. geneSelectorItem(item, index) {
  5453. let self = this;
  5454. item = item.trim();
  5455. if (!item) return;
  5456. if (index !== 0) {
  5457. let span = document.createElement("span");
  5458. span.innerText = " > ";
  5459. this.allpath.appendChild(span);
  5460. }
  5461. let span = document.createElement("span");
  5462. span.className = "path";
  5463. span.innerText = item;
  5464. span.addEventListener("click", e => {
  5465. let selector = "";
  5466. let target = e.target;
  5467. while (target) {
  5468. selector = target.innerText + selector;
  5469. target = target.previousElementSibling;
  5470. }
  5471. self.selectorInput.value = selector;
  5472. self.checkInputSelector();
  5473. if (self.checkedPath) {
  5474. self.checkedPath.classList.remove("checked");
  5475. }
  5476. span.classList.add("checked");
  5477. self.checkedPath = span;
  5478. }, true);
  5479. this.allpath.appendChild(span);
  5480. }
  5481.  
  5482. checkInputSelector(fill = true) {
  5483. let self = this;
  5484. this.clearSigns();
  5485. if (!this.selectorInput.value) return;
  5486. let eles = getAllElements(this.selectorInput.value, document);
  5487. this.foundEle = null;
  5488. if (eles && eles.length > 0) {
  5489. this.foundEle = eles;
  5490. eles.forEach(ele => {
  5491. let sign = self.createSignDiv();
  5492. document.documentElement.appendChild(sign);
  5493. self.adjustSignDiv(sign, ele);
  5494. self.signList.push(sign);
  5495. });
  5496. if (fill) this.fillTempRuleTextarea();
  5497. }
  5498. }
  5499.  
  5500. clearSigns() {
  5501. this.signList.forEach(sign => {
  5502. if (sign.parentNode) sign.parentNode.removeChild(sign);
  5503. });
  5504. this.signList = [];
  5505. }
  5506.  
  5507. start() {
  5508. this.init();
  5509. if (this.inPicker) return;
  5510. this.inPicker = true;
  5511. if (!this.styleEle || !this.styleEle.parentNode) {
  5512. this.styleEle = _GM_addStyle(this.cssText);
  5513. }
  5514. document.documentElement.appendChild(this.frame);
  5515. document.documentElement.appendChild(this.mainSignDiv);
  5516. getBody(document).classList.add("pagetual-picker");
  5517.  
  5518. this.logoBtn.classList.remove("showSign");
  5519. this.showSign = true;
  5520.  
  5521. getBody(document).addEventListener("mousemove", this.moveHandler, true);
  5522. getBody(document).addEventListener("click", this.clickHandler, true);
  5523. this.xpath.checked = isXPath(ruleParser.curSiteRule.pageElement);
  5524. this.tempRule.value = "";
  5525. this.editTemp = null;
  5526. this.frame.classList.remove("showDetail");
  5527.  
  5528. this.loadNow.style.display = ruleParser.nextLinkHref ? "block" : "none";
  5529. if (ruleParser.curSiteRule.nextLink && Array && Array.isArray && Array.isArray(ruleParser.curSiteRule.nextLink)) {
  5530. this.nextSwitchBtn.style.display = "block";
  5531. } else {
  5532. this.nextSwitchBtn.style.display = "none";
  5533. }
  5534. this.autoScrollBtn.innerText = i18n(autoScroll ? "disableAutoScroll" : "enableAutoScroll");
  5535.  
  5536. let pageElementSel = ruleParser.curSiteRule.pageElement || "";
  5537. if (Array && Array.isArray && Array.isArray(pageElementSel)) {
  5538. pageElementSel = pageElementSel[nextIndex < pageElementSel.length ? nextIndex : 0];
  5539. }
  5540. this.setSelectorDiv(pageElementSel);
  5541. this.fillTempRuleTextarea();
  5542. }
  5543. }
  5544. const picker = new Picker();
  5545.  
  5546. var editor, editorChanged = false, customRulesInput;
  5547. function createEdit() {
  5548. var options = {
  5549. mode: 'code',
  5550. modes: ['code', 'tree'],
  5551. templates: [
  5552. {
  5553. text: 'New site',
  5554. title: 'Insert a new site',
  5555. className: 'jsoneditor-type-object',
  5556. field: 'SiteTemplate',
  5557. value: {
  5558. 'name': 'Site name',
  5559. 'url': 'Site url'
  5560. }
  5561. }
  5562. ],
  5563. schema: {
  5564. "title": "Sites data",
  5565. "description": "Object containing site config",
  5566. "type": "array",
  5567. "items": {
  5568. "type": 'object',
  5569. "properties": {
  5570. "name": {
  5571. "title": "Site Name",
  5572. "description": "The site's name.",
  5573. "examples": [
  5574. "Google"
  5575. ],
  5576. "type": "string"
  5577. },
  5578. "url": {
  5579. "title": "Site Url",
  5580. "description": "The Regexp of site's url.",
  5581. "examples": [
  5582. "^https:\/\/yande\\.re\/"
  5583. ],
  5584. "type": "string"
  5585. }
  5586. },
  5587. "required": ["name", "url"]
  5588. }
  5589. },
  5590. onChange: () => {
  5591. editorChanged = true;
  5592. }
  5593. };
  5594. setTimeout(() => {
  5595. var container = document.getElementById("jsoneditor");
  5596. if (!container) {
  5597. container = document.createElement("div");
  5598. configCon.appendChild(container);
  5599. }
  5600. container.style.height = '800px';
  5601. container.innerHTML = "";
  5602. try {
  5603. editor = new _unsafeWindow.JSONEditor(container, options);
  5604. editor.set(ruleParser.customRules);
  5605. } catch (e) {
  5606. editor = null;
  5607. container.style.display = 'none';
  5608. customRulesInput.style.display = "";
  5609. }
  5610. }, 500);
  5611. }
  5612.  
  5613. function checkGuidePage(href) {
  5614. if (guidePage.test(href)) {
  5615. if (typeof _unsafeWindow.JSONEditor !== 'undefined') {
  5616. createEdit();
  5617. } else {
  5618. let timeout = 30;
  5619. let checkEditorReady = setInterval(() => {
  5620. if (typeof _unsafeWindow.JSONEditor !== 'undefined') {
  5621. createEdit();
  5622. clearInterval(checkEditorReady);
  5623. } else if (timeout-- <= 0) {
  5624. editor = null;
  5625. customRulesInput.style.display = "";
  5626. clearInterval(checkEditorReady);
  5627. }
  5628. }, 100);
  5629. }
  5630. return true;
  5631. }
  5632. return false;
  5633. }
  5634.  
  5635. function startAutoScroll() {
  5636. clearInterval(autoScrollInterval);
  5637. if (autoScroll <= 0) return;
  5638. let scrollRange_o = 1;
  5639. if (autoScroll > 1000) {
  5640. scrollRange_o = parseInt(autoScroll / 1000);
  5641. }
  5642. let devicePixelRatio = window.devicePixelRatio;
  5643. let scrollRange = Math.ceil(scrollRange_o / devicePixelRatio);
  5644.  
  5645. let scrollTarget, body = getBody(document);
  5646. let checkOverflow = ele => {
  5647. return ele.scrollHeight !== ele.clientHeight && getComputedStyle(ele).overflowY !== "hidden";
  5648. };
  5649. if (document.documentElement.scrollTop || checkOverflow(document.documentElement)) {
  5650. scrollTarget = document.documentElement;
  5651. } else if (body.scrollTop || checkOverflow(body)) {
  5652. scrollTarget = body;
  5653. } else {
  5654. let tempEle;
  5655. let img = body.querySelector('img');
  5656. if (img) {
  5657. tempEle = img;
  5658. while (tempEle && !checkOverflow(tempEle)) {
  5659. tempEle = tempEle.parentNode;
  5660. }
  5661. }
  5662. if (!tempEle && document.activeElement) {
  5663. let tempEle = document.activeElement;
  5664. while (tempEle && !checkOverflow(tempEle)) {
  5665. tempEle = tempEle.parentNode;
  5666. }
  5667. }
  5668. if (tempEle) scrollTarget = tempEle;
  5669. }
  5670. scrollTarget = scrollTarget || document.documentElement;
  5671.  
  5672. autoScrollInterval = setInterval(() => {
  5673. if (isPause && !urlChanging) return;
  5674. if (devicePixelRatio !== window.devicePixelRatio) {
  5675. devicePixelRatio = window.devicePixelRatio;
  5676. scrollRange = Math.ceil(scrollRange_o / devicePixelRatio);
  5677. }
  5678. scrollTarget.scrollTop += scrollRange;
  5679. }, parseInt(1000 / autoScroll));
  5680. }
  5681.  
  5682. var inUpdate = false;
  5683. var importHandler, configCon;
  5684. function initConfig(href) {
  5685. if (location.hostname === "github.com") {
  5686. 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) {
  5687. let issue_body = document.getElementById("issue_body");
  5688. if (!issue_body) return true;
  5689. issue_body.value = issue_body.value.replace("\n", "\n" + location.hash.slice(1) + "\n");
  5690. let starButton = document.createElement("a");
  5691. starButton.href = "https://github.com/hoothin/UserScripts#star";
  5692. starButton.className = "js-toggler-target rounded-left-2 btn-with-aria-count btn-sm btn";
  5693. 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>');
  5694. starButton.style.float = "right";
  5695. document.querySelector(".Layout-main>h2").appendChild(starButton);
  5696. return true;
  5697. } else if (location.href === "https://github.com/hoothin/UserScripts#star") {
  5698. let starButton = document.querySelector(".starring-container:not(.on)>.unstarred>form>button");
  5699. if (starButton) emuClick(starButton);
  5700. return true;
  5701. }
  5702. }
  5703. let isGuidePage = checkGuidePage(href);
  5704.  
  5705. var click2import, importUrlPres;
  5706.  
  5707. let inConfig = isGuidePage;
  5708. if (!inConfig) {
  5709. for (let i = 0; i < configPage.length; i++) {
  5710. if (configPage[i] == location.href) {
  5711. inConfig = true;
  5712. break;
  5713. }
  5714. }
  5715. }
  5716. if (!isGuidePage) {
  5717. if (location.hostname === "hoothin.github.io" || location.hostname === "pagetual.hoothin.com") isGuidePage = true;
  5718. }
  5719. configCon = document.getElementById("configCon");
  5720. if (configCon) {
  5721. configCon.parentNode.removeChild(configCon);
  5722. }
  5723. if (ruleImportUrlReg.test(href) || inConfig) {
  5724. let importing = false;
  5725. if (!inUpdate && rulesData.uninited) {
  5726. setTimeout(() => {
  5727. if (!inUpdate && !importing) showTips(i18n("firstAlert"));
  5728. }, 3000);
  5729. showTips(i18n("firstAlert"));
  5730. }
  5731. let defaultOption = document.querySelector('#discussion_rating_4');
  5732. if (defaultOption) defaultOption.checked = true;
  5733. let createImportBtn = (pre) => {
  5734. let importBtn = document.createElement("button");
  5735. importBtn.id = "pagetualImport";
  5736. importBtn.innerText = i18n("import");
  5737. importBtn.style.marginTop = "100px";
  5738. importBtn.style.float = "right";
  5739. importBtn.style.position = "relative";
  5740. importBtn.style.display = "block";
  5741. importBtn.style.fontSize = "20px";
  5742. importBtn.addEventListener("click", e => {
  5743. let parentNode = importBtn.parentNode;
  5744. if (!parentNode) return;
  5745. parentNode.removeChild(importBtn);
  5746. try {
  5747. let rules = parentNode.innerText.trim();
  5748. let isContent = /['"]name['"]/i.test(rules);
  5749. if (isContent) {
  5750. let ruleList = JSON.parse(`[${rules}]`);
  5751. for (let i in ruleList) {
  5752. let hasRule = false;
  5753. let r = ruleList[i];
  5754. for (let j in ruleParser.customRules) {
  5755. if (ruleParser.customRules[j].name == r.name) {
  5756. ruleParser.customRules[j] = r;
  5757. hasRule = true;
  5758. break;
  5759. }
  5760. }
  5761. if (!hasRule) ruleParser.customRules.push(r);
  5762. ruleParser.hpRules.unshift(r);
  5763. }
  5764. storage.setItem("customRules", ruleParser.customRules);
  5765. storage.setItem("hpRules", ruleParser.hpRules);
  5766. storage.setItem("smartRules", []);
  5767. showTips(i18n("importSucc"));
  5768. } else {
  5769. rules = rules.split("\n");
  5770. let diff = false;
  5771. for (let c = 0; c < rules.length; c++) {
  5772. let urlArr = rules[c].split("|"), url, type = 1;
  5773. if (urlArr.length == 1) {
  5774. url = urlArr[0].trim();
  5775. if (!/^http/.test(url)) {
  5776. showTips(i18n("errorWrongUrl"));
  5777. return;
  5778. }
  5779. } else if (urlArr.length == 2) {
  5780. type = urlArr[0].trim();
  5781. url = urlArr[1].trim();
  5782. if (!/^http/.test(url)) {
  5783. showTips(i18n("errorWrongUrl"));
  5784. return;
  5785. }
  5786. } else {
  5787. break;
  5788. }
  5789. let maxId = 1, hasUrl = false;
  5790. if (!rulesData.urls) {
  5791. rulesData.urls = [];
  5792. maxId = 1;
  5793. } else {
  5794. rulesData.urls.forEach(u => {
  5795. if (maxId < u.id) {
  5796. maxId = u.id;
  5797. }
  5798. if (u.url == url) {
  5799. hasUrl = true;
  5800. }
  5801. });
  5802. if (hasUrl) break;
  5803. }
  5804. diff = true;
  5805. if (!rulesData.sort) rulesData.sort = [1];
  5806. rulesData.urls.push({id: maxId + 1, url: url, type: type});
  5807. rulesData.sort.unshift(maxId + 1);
  5808. }
  5809. if (!diff) {
  5810. showTips(i18n("errorAlreadyExists"));
  5811. setTimeout(() => {
  5812. showTips(i18n("beginUpdate"), "", 50000);
  5813. updateRules(() => {
  5814. showTips(i18n("updateSucc"));
  5815. location.reload();
  5816. }, (rule, err) => {
  5817. showTips(`Failed to update ${rule.url} rules!`);
  5818. debug(err);
  5819. });
  5820. }, 500);
  5821. return;
  5822. }
  5823. storage.setItem("rulesData", rulesData);
  5824.  
  5825. if (rulesData.urls) ruleUrls = ruleUrls.concat(rulesData.urls);
  5826. if (rulesData.sort) {
  5827. let urls = [];
  5828. rulesData.sort.forEach(id => {
  5829. for (let s = 0; s < ruleUrls.length; s++) {
  5830. if (id == ruleUrls[s].id) {
  5831. urls.push(ruleUrls[s]);
  5832. break;
  5833. }
  5834. }
  5835. });
  5836. ruleUrls = urls;
  5837. }
  5838. showTips(i18n("beginUpdate"), "", 30000);
  5839. updateRules(() => {
  5840. showTips(i18n("updateSucc"));
  5841. location.reload();
  5842. }, (rule, err) => {
  5843. showTips(`Failed to update ${rule.url} rules!`);
  5844. debug(err);
  5845. });
  5846. importing = true;
  5847. }
  5848. } catch (e) {
  5849. _GM_notification(e.toString());
  5850. }
  5851. });
  5852. if (pre) {
  5853. let clientHeight = 35 - pre.clientHeight;
  5854. if (clientHeight > -20) clientHeight = -20;
  5855. importBtn.style.marginTop = `${clientHeight}px`;
  5856. pre.appendChild(importBtn);
  5857. }
  5858. return importBtn;
  5859. };
  5860. [].forEach.call(document.querySelectorAll('pre[name=pagetual],pre[name=user-content-pagetual]'), pre => {
  5861. let importBtn = createImportBtn(pre);
  5862. if (rulesData.uninited) {
  5863. pre.style.display = "";
  5864. }
  5865. });
  5866. click2import = document.querySelector("[name='user-content-click2import'],[name='click2import']");
  5867. if (click2import) {
  5868. click2import.innerText = i18n("click2ImportRule");
  5869. click2import.style.display = rulesData.uninited ? "block" : "none";
  5870. }
  5871. if (!importHandler) {
  5872. importHandler = e => {
  5873. if (compareNodeName(e.target, ["pre"])) {
  5874. let nameAttr = e.target.getAttribute("name");
  5875. if (nameAttr == "pagetual" || nameAttr == "user-content-pagetual") {
  5876. if (e.target.querySelector('#pagetualImport')) return;
  5877. let importBtn = createImportBtn(e.target);
  5878. }
  5879. }
  5880. };
  5881. }
  5882. document.removeEventListener("mouseover", importHandler);
  5883. document.addEventListener("mouseover", importHandler);
  5884.  
  5885. if (inConfig) {
  5886. if (!inUpdate && _GM_info.script && _GM_info.script.version && _GM_info.script.version !== '1.0.0') {
  5887. let versionEle = document.querySelector('.markdown-body>h1[id],article>h1');
  5888. let latestVer = versionEle && versionEle.innerText.match(/\d[\d\.]+/)[0];
  5889. if (latestVer && latestVer != _GM_info.script.version) {
  5890. showTips(i18n('outOfDate'), "", 3000);
  5891. }
  5892. }
  5893. _GM_addStyle(`
  5894. p>span:nth-child(1),p>span:nth-child(2),p>span:nth-child(3){
  5895. cursor: pointer;
  5896. user-select: none;
  5897. display: inline-block;
  5898. margin-right: 5px;
  5899. -moz-transition:color 0.3s ease, transform 0.3s;
  5900. -webkit-transition:color 0.3s ease, transform 0.3s;
  5901. transition:color 0.3s ease, transform 0.3s;
  5902. }
  5903. p>span:nth-child(1):hover,p>span:nth-child(2):hover,p>span:nth-child(3):hover{
  5904. color:red;
  5905. transform: scale(1.5);
  5906. -webkit-transform: scale(1.5);
  5907. }
  5908. .updateDate{
  5909. cursor: pointer;
  5910. user-select: none;
  5911. -moz-transition:color 0.3s ease, transform 0.3s;
  5912. -webkit-transition:color 0.3s ease, transform 0.3s;
  5913. transition:color 0.3s ease, transform 0.3s;
  5914. transform-origin: left;
  5915. -webkit-transform-origin: left;
  5916. }
  5917. .updateDate:hover{
  5918. color:red;
  5919. transform: scale(1.1);
  5920. -webkit-transform: scale(1.1);
  5921. }
  5922. input[type=number]::-webkit-inner-spin-button,
  5923. input[type=number]::-webkit-outer-spin-button {
  5924. -webkit-appearance: none;
  5925. margin: 0;
  5926. }
  5927. input[type=number] {
  5928. -moz-appearance:textfield;
  5929. }
  5930. table td>h3 {
  5931. margin: 16px!important;
  5932. padding: 0!important;
  5933. }
  5934. table td>h4 {
  5935. padding: 0!important;
  5936. }
  5937. #saveBtn {
  5938. width: 60vw;
  5939. position: fixed;
  5940. z-index: 999;
  5941. bottom: 0;
  5942. left: 20vw;
  5943. font-size: xx-large;
  5944. opacity: 0.6;
  5945. cursor: pointer;
  5946. -moz-transition:all 0.3s ease;
  5947. -webkit-transition:all 0.3s ease;
  5948. transition:all 0.3s ease;
  5949. }
  5950. #configCon #saveBtn:hover {
  5951. opacity: 1;
  5952. margin-bottom: 0px;
  5953. }
  5954. #configCon #saveBtn {
  5955. margin-bottom: -30px;
  5956. }
  5957. #configCon.showSave #saveBtn {
  5958. margin-bottom: 0px;
  5959. }
  5960. `);
  5961. configCon = document.querySelector(".markdown-body,.theme-default-content");
  5962. if (!configCon) {
  5963. setTimeout(() => {
  5964. location.reload();
  5965. }, 1000);
  5966. return true;
  5967. }
  5968. let insertPos = configCon.querySelector("hr,#jsoneditor");
  5969. configCon = document.createElement("div");
  5970. configCon.id = "configCon";
  5971. insertPos.parentNode.insertBefore(configCon, insertPos);
  5972.  
  5973. importUrlPres = document.querySelectorAll("pre[name='user-content-pagetual'],pre[name='pagetual']");
  5974. if (importUrlPres) {
  5975. [].forEach.call(importUrlPres, importUrlPre => {
  5976. importUrlPre.style.overflow = "hidden";
  5977. importUrlPre.style.display = rulesData.uninited ? "block" : "none";
  5978. });
  5979. }
  5980. let otherconfig = document.querySelector("a[name='user-content-otherconfig'],a[name='otherconfig']");
  5981. if (otherconfig) otherconfig.parentNode.removeChild(otherconfig);
  5982. let rulesExample = document.querySelector("#user-content-rules-example+a,#rules-example>a");
  5983. if (rulesExample) {
  5984. rulesExample.innerText = i18n("rulesExample");
  5985. if (lang == "zh-CN") {
  5986. rulesExample.href = rulesExample.href.replace("en", "cn");
  5987. } else if (lang == "zh-TW" || lang == "zh-HK") {
  5988. rulesExample.href = rulesExample.href.replace("/en", "");
  5989. }
  5990. }
  5991. document.documentElement.scrollTop = 0;
  5992.  
  5993. let newPos, lastPos = 0;
  5994. window.addEventListener('scroll', function(e) {
  5995. newPos = window.scrollY;
  5996. if (newPos > lastPos) {
  5997. configCon.classList.add("showSave");
  5998. } else {
  5999. configCon.classList.remove("showSave");
  6000. }
  6001. lastPos = newPos;
  6002. });
  6003. } else return isGuidePage;
  6004. } else return isGuidePage;
  6005. let ruleBarInsertPos = document.createTextNode(' ');
  6006. configCon.appendChild(ruleBarInsertPos);
  6007. class Rulebar {
  6008. init(ruleUrl) {
  6009. let id = ruleUrl.id;
  6010. this.ruleUrl = ruleUrl;
  6011. this.item = document.createElement("p");
  6012. this.item.dataset.id = id;
  6013. let url = document.createElement("a");
  6014. url.href = ruleUrl.url;
  6015. url.innerHTML = ruleUrl.url;
  6016. url.title = ruleUrl.url;
  6017. let up = document.createElement("span");
  6018. up.innerHTML = "↑ ";
  6019. up.title = i18n("sortTitle");
  6020. let down = document.createElement("span");
  6021. down.innerHTML = "↓ ";
  6022. down.title = i18n("sortTitle");
  6023. let del = document.createElement("span");
  6024. del.innerHTML = "× ";
  6025. up.onclick = e => {
  6026. this.moveUp();
  6027. };
  6028. down.onclick = e => {
  6029. this.moveDown();
  6030. };
  6031. del.onclick = e => {
  6032. this.del();
  6033. };
  6034. this.item.appendChild(up);
  6035. this.item.appendChild(down);
  6036. this.item.appendChild(del);
  6037. this.item.appendChild(url);
  6038. if (ruleParser.rules) {
  6039. url.style.maxWidth = "calc(100% - 150px)";
  6040. url.style.overflow = "hidden";
  6041. url.style.display = "inline-block";
  6042. url.style.textOverflow = "ellipsis";
  6043. url.style.verticalAlign = "bottom";
  6044. url.style.whiteSpace = "nowrap";
  6045. let rulesLength = ruleParser.rules.reduce((acc, cur) => acc + (cur.from == id ? 1 : 0), 0);
  6046. let idSpan = document.createElement("span");
  6047. idSpan.style.float = "right";
  6048. idSpan.innerHTML = `[rules: ${rulesLength}]`;
  6049. this.item.appendChild(idSpan);
  6050. this.idSpan = idSpan;
  6051. }
  6052. configCon.insertBefore(this.item, ruleBarInsertPos);
  6053. }
  6054. updateNum() {
  6055. if (ruleParser.rules) {
  6056. let rulesLength = ruleParser.rules.reduce((acc, cur) => acc + (cur.from == this.item.dataset.id ? 1 : 0), 0);
  6057. this.idSpan.innerHTML = `[rules: ${rulesLength}]`;
  6058. }
  6059. }
  6060. saveSort() {
  6061. let sort = [];
  6062. [].forEach.call(this.item.parentNode.querySelectorAll("p[data-id]"), i => {
  6063. sort.push(i.dataset.id);
  6064. });
  6065. rulesData.sort = sort;
  6066. let urls = [];
  6067. sort.forEach(id => {
  6068. for (let s = 0; s < ruleUrls.length; s++) {
  6069. if (id == ruleUrls[s].id) {
  6070. urls.push(ruleUrls[s]);
  6071. break;
  6072. }
  6073. }
  6074. });
  6075. ruleUrls = urls;
  6076. storage.setItem("rulesData", rulesData);
  6077. showTips(i18n("sortTitle"));
  6078. }
  6079. moveUp() {
  6080. let preE = this.item.previousElementSibling;
  6081. if (compareNodeName(preE, ["p"]) && preE.children.length > 1) {
  6082. this.item.parentNode.insertBefore(this.item, preE);
  6083. this.saveSort();
  6084. }
  6085. }
  6086. moveDown() {
  6087. let nextE = this.item.nextElementSibling;
  6088. if (compareNodeName(nextE, ["p"]) && nextE.children.length > 1) {
  6089. this.item.parentNode.insertBefore(nextE, this.item);
  6090. this.saveSort();
  6091. }
  6092. }
  6093. del() {
  6094. if (this.ruleUrl.id < 2) {
  6095. showTips(i18n("cantDel"));
  6096. } else if (window.confirm(i18n("confirmDel"))) {
  6097. for (let u = 0; u < rulesData.urls.length; u++) {
  6098. if (this.ruleUrl.id == rulesData.urls[u].id) {
  6099. rulesData.urls.splice(u, 1);
  6100. break;
  6101. }
  6102. }
  6103. for (let u = 0; u < ruleUrls.length; u++) {
  6104. if (this.ruleUrl.id == ruleUrls[u].id) {
  6105. ruleUrls.splice(u, 1);
  6106. break;
  6107. }
  6108. }
  6109. for (let u = 0; u < rulesData.sort.length; u++) {
  6110. if (this.ruleUrl.id == rulesData.sort[u]) {
  6111. rulesData.sort.splice(u, 1);
  6112. break;
  6113. }
  6114. }
  6115. rulesData.ruleVersion = 0;
  6116. storage.setItem("rulesData", rulesData);
  6117. ruleParser.rules = ruleParser.rules.filter(item => {return item.from != this.ruleUrl.id});
  6118. storage.setItem("rules", ruleParser.rules);
  6119. this.item.parentNode.removeChild(this.item);
  6120. //location.reload();
  6121. }
  6122. }
  6123. }
  6124. let langSelect = document.createElement("select");
  6125. langSelect.style.float = "right";
  6126. langSelect.style.position = "relative";
  6127. langSelect.style.zIndex = "1";
  6128. let option = document.createElement("option");
  6129. option.value = "";
  6130. option.innerText = "Language";
  6131. langSelect.appendChild(option);
  6132. for (let key in langList) {
  6133. let option = document.createElement("option");
  6134. option.value = key;
  6135. option.innerText = langList[key];
  6136. langSelect.appendChild(option);
  6137. }
  6138. langSelect.value = rulesData.lang || "";
  6139. configCon.appendChild(langSelect);
  6140.  
  6141. let updateP = document.createElement("p"), i = 0;
  6142. let now = new Date().getTime();
  6143.  
  6144.  
  6145. let pastDate = (new Date(updateDate)).toString(), passStr;
  6146. let passTime = (now - updateDate) / 1000;
  6147. if (isNaN(passTime)) {
  6148. passStr = i18n("firstUpdate");
  6149. } else {
  6150. if (passTime < 60) {
  6151. passStr = i18n("passSec", parseInt(passTime));
  6152. } else if (passTime < 60 * 60) {
  6153. passStr = i18n("passMin", parseInt(passTime / 60));
  6154. } else if (passTime < 60 * 60 * 24) {
  6155. passStr = i18n("passHour", parseInt(passTime / 3600));
  6156. } else {
  6157. passStr = i18n("passDay", parseInt(passTime / 86400));
  6158. }
  6159. passStr += " 🖱 " + i18n("click2update");
  6160. }
  6161.  
  6162. let rulebarList = [], updateFail = false;
  6163. updateP.className = "updateDate";
  6164. updateP.innerHTML = passStr;
  6165. updateP.title = i18n("update") + " - " + pastDate;
  6166. configCon.appendChild(updateP);
  6167. if (ruleUrls) {
  6168. ruleUrls.forEach(ruleUrl => {
  6169. let rulebar = new Rulebar();
  6170. rulebar.init(ruleUrl);
  6171. rulebarList.push(rulebar);
  6172. });
  6173. }
  6174. let customUrlsTitle = document.createElement("h2");
  6175. customUrlsTitle.innerHTML = i18n("customUrls");
  6176. configCon.appendChild(customUrlsTitle);
  6177. let customUrlsInput = document.createElement("textarea");
  6178. customUrlsInput.style.width = "100%";
  6179. customUrlsInput.style.position = "relative";
  6180. customUrlsInput.placeholder = "http://wedata.net/databases/AutoPagerize/items_all.json \nhttps://hoothin.github.io/UserScripts/Pagetual/pagetualRules.json";
  6181. customUrlsInput.spellcheck = false;
  6182. configCon.appendChild(customUrlsInput);
  6183.  
  6184. let btns = document.createElement("div");
  6185. btns.style.display = "flex";
  6186. configCon.appendChild(btns);
  6187. let upBtnImg = document.createElement("div");
  6188. upBtnImg.style.width = "33%";
  6189. let upBtnImgTitle = document.createElement("h2");
  6190. upBtnImgTitle.style.whiteSpace = "nowrap";
  6191. upBtnImgTitle.style.overflow = "auto";
  6192. upBtnImgTitle.innerHTML = i18n("upBtnImg");
  6193. upBtnImg.appendChild(upBtnImgTitle);
  6194. let upBtnImgInput = document.createElement("input");
  6195. upBtnImgInput.style.width = "100%";
  6196. upBtnImgInput.style.position = "relative";
  6197. upBtnImgInput.placeholder = "data:image/png;base64,UpBtn";
  6198. upBtnImgInput.value = rulesData.upBtnImg || '';
  6199. upBtnImgInput.spellcheck = false;
  6200. upBtnImg.appendChild(upBtnImgInput);
  6201. btns.appendChild(upBtnImg);
  6202.  
  6203. let downBtnImg = document.createElement("div");
  6204. downBtnImg.style.width = "33%";
  6205. let downBtnImgTitle = document.createElement("h2");
  6206. downBtnImgTitle.style.whiteSpace = "nowrap";
  6207. downBtnImgTitle.style.overflow = "auto";
  6208. downBtnImgTitle.innerHTML = i18n("downBtnImg");
  6209. downBtnImg.appendChild(downBtnImgTitle);
  6210. let downBtnImgInput = document.createElement("input");
  6211. downBtnImgInput.style.width = "100%";
  6212. downBtnImgInput.style.position = "relative";
  6213. downBtnImgInput.placeholder = "data:image/png;base64,DownBtn";
  6214. downBtnImgInput.value = rulesData.downBtnImg || '';
  6215. downBtnImgInput.spellcheck = false;
  6216. downBtnImg.appendChild(downBtnImgInput);
  6217. btns.appendChild(downBtnImg);
  6218.  
  6219. let sideControllerIconDiv = document.createElement("div");
  6220. sideControllerIconDiv.style.width = "33%";
  6221. let sideControllerIconTitle = document.createElement("h2");
  6222. sideControllerIconTitle.style.whiteSpace = "nowrap";
  6223. sideControllerIconTitle.style.overflow = "auto";
  6224. sideControllerIconTitle.innerHTML = i18n("sideControllerIcon");
  6225. sideControllerIconDiv.appendChild(sideControllerIconTitle);
  6226. let sideControllerIconInput = document.createElement("input");
  6227. sideControllerIconInput.style.width = "100%";
  6228. sideControllerIconInput.style.position = "relative";
  6229. sideControllerIconInput.placeholder = "📄";
  6230. sideControllerIconInput.value = rulesData.sideControllerIcon || '';
  6231. sideControllerIconInput.spellcheck = false;
  6232. sideControllerIconDiv.appendChild(sideControllerIconInput);
  6233. btns.appendChild(sideControllerIconDiv);
  6234.  
  6235. let otherBtns = document.createElement("div");
  6236. otherBtns.style.display = "flex";
  6237. configCon.appendChild(otherBtns);
  6238. let loadingText = document.createElement("div");
  6239. loadingText.style.width = "100%";
  6240. let loadingTextTitle = document.createElement("h2");
  6241. loadingTextTitle.style.whiteSpace = "nowrap";
  6242. loadingTextTitle.style.overflow = "auto";
  6243. loadingTextTitle.innerHTML = i18n("loadingTextTitle");
  6244. loadingText.appendChild(loadingTextTitle);
  6245. let loadingTextInput = document.createElement("input");
  6246. loadingTextInput.value = rulesData.loadingText || '';
  6247. loadingTextInput.placeholder = i18n("loadingText");
  6248. loadingTextInput.style.width = "100%";
  6249. loadingTextInput.style.position = "relative";
  6250. loadingTextInput.style.margin = "0";
  6251. loadingTextInput.spellcheck = false;
  6252. loadingText.appendChild(loadingTextInput);
  6253. otherBtns.appendChild(loadingText);
  6254.  
  6255. let opacity = document.createElement("div");
  6256. let opacityTitle = document.createElement("h2");
  6257. opacityTitle.style.whiteSpace = "nowrap";
  6258. opacityTitle.style.overflow = "visible";
  6259. opacityTitle.innerHTML = i18n("opacity");
  6260. opacity.appendChild(opacityTitle);
  6261. let opacityInput = document.createElement("input");
  6262. opacityInput.value = rulesData.opacity * 100;
  6263. opacityInput.type = "number";
  6264. opacityInput.min = 0;
  6265. opacityInput.max = 100;
  6266. opacityInput.style.width = "110px";
  6267. opacityInput.style.position = "relative";
  6268. opacityInput.style.margin = "0";
  6269. opacityInput.placeholder = i18n("opacityPlaceholder");
  6270. opacityInput.spellcheck = false;
  6271. opacityInput.oninput = e => {
  6272. if (opacityInput.value > 100) opacityInput.value = 100;
  6273. else if (opacityInput.value < 0) opacityInput.value = 0;
  6274. };
  6275. opacity.appendChild(opacityInput);
  6276. otherBtns.appendChild(opacity);
  6277.  
  6278. let pageElementCss = document.createElement("div");
  6279. pageElementCss.style.marginBottom = "30px";
  6280. let pageElementCssTitle = document.createElement("h2");
  6281. pageElementCssTitle.innerHTML = i18n("pageElementCss");
  6282. pageElementCss.appendChild(pageElementCssTitle);
  6283. let pageElementCssInput = document.createElement("input");
  6284. pageElementCssInput.value = rulesData.pageElementCss || '';
  6285. pageElementCssInput.style.width = "100%";
  6286. pageElementCssInput.style.position = "relative";
  6287. pageElementCssInput.style.margin = "0";
  6288. pageElementCssInput.placeholder = "font-size: xx-large;";
  6289. pageElementCssInput.spellcheck = false;
  6290. pageElementCss.appendChild(pageElementCssInput);
  6291. configCon.appendChild(pageElementCss);
  6292.  
  6293. let customCss = document.createElement("div");
  6294. customCss.style.marginBottom = "50px";
  6295. let customCssTitle = document.createElement("h2");
  6296. customCssTitle.innerHTML = i18n("customCss");
  6297. customCss.appendChild(customCssTitle);
  6298. let customCssInput = document.createElement("textarea");
  6299. customCssInput.value = rulesData.customCss || '';
  6300. customCssInput.style.width = "100%";
  6301. customCssInput.style.position = "relative";
  6302. customCssInput.style.margin = "0";
  6303. customCssInput.placeholder = ".pagetual {\n}";
  6304. customCssInput.spellcheck = false;
  6305. customCss.appendChild(customCssInput);
  6306. configCon.appendChild(customCss);
  6307.  
  6308. let configTable = document.createElement("table");
  6309. configTable.style.width = "100%";
  6310. let configTbody = document.createElement("tbody");
  6311. configTbody.style.width = "99%";
  6312. configTbody.style.display = "inline-table";
  6313. configTable.appendChild(configTbody);
  6314. configCon.appendChild(configTable);
  6315. function createCheckbox(innerText, val, tag, parentCheck, otherType, alwaysShow) {
  6316. if (typeof val == 'undefined') val = "";
  6317. let title = document.createElement(tag || "h3");
  6318. title.innerHTML = innerText;
  6319. title.style.overflowWrap = "normal";
  6320. let input = document.createElement("input");
  6321. if (otherType === 'key') {
  6322. input.type = 'text';
  6323. input.setAttribute('readOnly', 'readonly');
  6324. input.addEventListener("keydown", e => {
  6325. if (e.key === 'Escape' || e.key === 'Backspace') input.value = '';
  6326. else input.value = e.key;
  6327. e.stopPropagation();
  6328. e.preventDefault();
  6329. });
  6330. } else {
  6331. input.type = otherType || "checkbox";
  6332. }
  6333. input.style.width = "35px";
  6334. input.style.height = "20px";
  6335. input.style.float = "left";
  6336. input.style.margin = "0 2px";
  6337. input.value = val;
  6338. input.checked = val;
  6339. let td = document.createElement("td");
  6340. td.appendChild(input);
  6341. if (parentCheck) {
  6342. title.appendChild(input);
  6343. title.style.margin = "0";
  6344. td.appendChild(title);
  6345. let parent = parentCheck.parentNode.nextElementSibling;
  6346. let tr = parent.querySelector("tr");
  6347. if (!tr) {
  6348. tr = document.createElement("tr");
  6349. parent.appendChild(tr);
  6350. }
  6351. tr.appendChild(td);
  6352. if (!alwaysShow) {
  6353. if (!parentCheck.checked) {
  6354. td.style.display = "none";
  6355. }
  6356. parentCheck.addEventListener("click", e => {
  6357. td.style.display = parentCheck.checked ? "" : "none";
  6358. });
  6359. }
  6360. } else {
  6361. let tr = document.createElement("tr");
  6362. tr.appendChild(td);
  6363. td = document.createElement("td");
  6364. td.appendChild(title);
  6365. tr.appendChild(td);
  6366. configTable.children[0].appendChild(tr);
  6367. }
  6368. let xNodePos = innerText.indexOf('【X】');
  6369. if (xNodePos !== -1) {
  6370. input.style.float = "";
  6371. let xNode = title.firstChild.splitText(xNodePos);
  6372. xNode.splitText(3);
  6373. xNode.parentNode.replaceChild(input, xNode);
  6374. }
  6375. return input;
  6376. }
  6377.  
  6378. let setConfigPageInput = createCheckbox(i18n("setConfigPage"), false);
  6379. let enableWhiteListInput = createCheckbox(i18n("autoRun"), rulesData.enableWhiteList != true);
  6380. let sideControllerInput = createCheckbox(i18n("sideController"), rulesData.sideController);
  6381. let sideControllerAlwaysInput = createCheckbox(i18n("sideControllerAlways"), rulesData.sideControllerAlways, "h4", sideControllerInput);
  6382. let sideControllerScrollInput = createCheckbox(i18n("sideControllerScroll"), rulesData.sideControllerScroll !== false, "h4", sideControllerInput);
  6383. let sideControllerLoadNowInput = createCheckbox(i18n("loadNow"), rulesData.sideControllerLoadNow !== false, "h4", sideControllerInput);
  6384. let enableDebugInput = createCheckbox(i18n("enableDebug"), rulesData.enableDebug != false);
  6385. let enableHistoryInput = createCheckbox(i18n("enableHistory"), rulesData.enableHistory === true);
  6386. let enableHistoryAfterInsertInput = createCheckbox(i18n("enableHistoryAfterInsert"), rulesData.enableHistoryAfterInsert === true, "h4", enableHistoryInput);
  6387. let openInNewTabInput = createCheckbox(i18n("openInNewTab"), rulesData.openInNewTab != false);
  6388. let hidePageBarInput = createCheckbox(i18n("hideBarTips"), rulesData.opacity == 0);
  6389. let hidePageBarArrowInput = createCheckbox(i18n("hideBarArrow"), rulesData.hideBarArrow);
  6390. let hideLoadingIconInput = createCheckbox(i18n("hideLoadingIcon"), rulesData.hideLoadingIcon != false);
  6391. let initRunInput = createCheckbox(i18n("initRun"), rulesData.initRun != false);
  6392. let autoLoadNumInput = createCheckbox(i18n("autoLoadNum"), rulesData.autoLoadNum, "h4", initRunInput, "number");
  6393. let preloadInput = createCheckbox(i18n("preload"), rulesData.preload != false);
  6394. let rateInput = createCheckbox(i18n("turnRate"), rulesData.rate, "h4", preloadInput, "number", true);
  6395. let dbClick2StopInput = createCheckbox(i18n("dbClick2Stop"), rulesData.dbClick2Stop);
  6396. let manualModeInput = createCheckbox(i18n("manualMode"), rulesData.manualMode);
  6397. let clickModeInput = createCheckbox(i18n("clickMode"), rulesData.clickMode);
  6398. let pageBarMenuInput = createCheckbox(i18n("pageBarMenu"), rulesData.pageBarMenu != false);
  6399. let arrowToScrollInput = createCheckbox(i18n("arrowToScroll"), rulesData.arrowToScroll);
  6400. let contentVisibilityInput = createCheckbox(i18n("contentVisibility"), rulesData.contentVisibility);
  6401. let wedata2githubInput = createCheckbox(i18n("wedata2github"), rulesData.wedata2github);
  6402. let customFirstInput = createCheckbox(i18n("customFirst"), rulesData.customFirst);
  6403. let lastPageTipsInput = createCheckbox(i18n("lastPageTips"), rulesData.lastPageTips);
  6404. let updateNotificationInput = createCheckbox(i18n("updateNotification"), rulesData.updateNotification != false);
  6405.  
  6406. let hideBarInput = createCheckbox(i18n("hideBar"), rulesData.hideBar && !rulesData.hideBarButNoStop, "h4", dbClick2StopInput, 'radio');
  6407. hideBarInput.name = 'hideBar';
  6408. let hideBarButNoStopInput = createCheckbox(i18n("hideBarButNoStop"), rulesData.hideBarButNoStop, "h4", dbClick2StopInput, 'radio');
  6409. hideBarButNoStopInput.name = 'hideBar';
  6410. hideBarInput.addEventListener('mouseup', e => {
  6411. if (hideBarInput.checked) {
  6412. setTimeout(() => {hideBarInput.checked = false}, 0);
  6413. }
  6414. });
  6415. hideBarButNoStopInput.addEventListener('mouseup', e => {
  6416. if (hideBarButNoStopInput.checked) {
  6417. setTimeout(() => {hideBarButNoStopInput.checked = false}, 0);
  6418. }
  6419. });
  6420. hidePageBarInput.addEventListener('click', e => {
  6421. opacityInput.value = hidePageBarInput.checked ? 0 : 100;
  6422. });
  6423.  
  6424. let dbClick2StopCtrlInput = createCheckbox(i18n("dbClick2StopCtrl"), rulesData.dbClick2StopCtrl, "h4", dbClick2StopInput);
  6425. let dbClick2StopAltInput = createCheckbox(i18n("dbClick2StopAlt"), rulesData.dbClick2StopAlt, "h4", dbClick2StopInput);
  6426. let dbClick2StopShiftInput = createCheckbox(i18n("dbClick2StopShift"), rulesData.dbClick2StopShift, "h4", dbClick2StopInput);
  6427. let dbClick2StopMetaInput = createCheckbox(i18n("dbClick2StopMeta"), rulesData.dbClick2StopMeta, "h4", dbClick2StopInput);
  6428. let dbClick2StopKeyInput = createCheckbox(i18n("dbClick2StopKey"), rulesData.dbClick2StopKey, "h4", dbClick2StopInput, "key");
  6429.  
  6430. let otherConfigPage = (rulesData.configPage || configPage[0]) != location.href.replace(/#.*/, "");
  6431. if (!otherConfigPage) {
  6432. setConfigPageInput.parentNode.parentNode.style.display = "none";
  6433. }
  6434.  
  6435. updateP.onclick = e => {
  6436. updateFail = false;
  6437. //ruleParser.rules = [];
  6438. showTips(i18n("beginUpdate"), "", 30000);
  6439. updateRules(() => {
  6440. if (!updateFail) {
  6441. showTips(i18n("updateSucc"));
  6442. if (importUrlPres) {
  6443. [].forEach.call(importUrlPres, importUrlPre => {
  6444. importUrlPre.style.display = "none";
  6445. });
  6446. }
  6447. if (click2import) click2import.style.display = "none";
  6448. }
  6449. updateP.innerHTML = i18n("passSec", 0);
  6450. updateP.title = i18n("update");
  6451. rulebarList.forEach(rulebar => {
  6452. rulebar.updateNum();
  6453. });
  6454. }, (rule, err) => {
  6455. if (rule.id == 1) {
  6456. showTips(`Failed to update wedata rules! Try to switch to wedata mirror!`);
  6457. wedata2githubInput.scrollIntoView({ behavior: "smooth" });
  6458. } else {
  6459. showTips(`Failed to update ${rule.url} rules!`);
  6460. }
  6461. debug(err);
  6462. updateFail = true;
  6463. });
  6464. };
  6465. let customRulesTitle = document.createElement("h2");
  6466. 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');
  6467. configCon.appendChild(customRulesTitle);
  6468. customRulesInput = document.createElement("textarea");
  6469. customRulesInput.spellcheck = false;
  6470. configCon.appendChild(customRulesInput);
  6471. if (rulesData.editTemp) {
  6472. if (!ruleParser.customRules) {
  6473. ruleParser.customRules = [];
  6474. }
  6475. for (let i in ruleParser.customRules) {
  6476. if (ruleParser.customRules[i].url == rulesData.editTemp.url) {
  6477. ruleParser.customRules.splice(i, 1);
  6478. break;
  6479. }
  6480. }
  6481. ruleParser.customRules.unshift(rulesData.editTemp);
  6482. rulesData.editTemp = null;
  6483. storage.setItem("rulesData", rulesData);
  6484. customRulesInput.previousElementSibling.scrollIntoView();
  6485. }
  6486. customRulesInput.style.width = "100%";
  6487. customRulesInput.style.height = "800px";
  6488. 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]`;
  6489. let preCustom = getFormatJSON(ruleParser.customRules);
  6490. customRulesInput.value = preCustom;
  6491. if (isGuidePage) customRulesInput.style.display = "none";
  6492. let blacklistInput = document.createElement("textarea");
  6493. blacklistInput.style.width = "100%";
  6494. blacklistInput.style.height = "500px";
  6495. blacklistInput.style.display = "none";
  6496. blacklistInput.spellcheck = false;
  6497. 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";
  6498. blacklistInput.value = rulesData.blacklist ? rulesData.blacklist.join("\n") : "";
  6499. let blacklistBtn = document.createElement("button");
  6500. blacklistBtn.innerText = i18n("editBlacklist");
  6501. blacklistBtn.style.width = "100%";
  6502. blacklistBtn.onclick = e => {
  6503. blacklistInput.style.display = blacklistInput.style.display == "none" ? "" : "none";
  6504. };
  6505. configCon.appendChild(blacklistBtn);
  6506. configCon.appendChild(blacklistInput);
  6507. let saveBtn = document.createElement("button");
  6508. saveBtn.innerHTML = i18n("save");
  6509. saveBtn.id = "saveBtn";
  6510. configCon.appendChild(saveBtn);
  6511. saveBtn.onclick = e => {
  6512. try {
  6513. let customRules;
  6514. if (editor) {
  6515. if (editorChanged) {
  6516. editorChanged = false;
  6517. storage.setItem("hpRules", []);
  6518. storage.setItem("smartRules", []);
  6519. }
  6520. customRules = editor.get();
  6521. if (!customRules) {
  6522. customRules = "";
  6523. } else {
  6524. if (Array && Array.isArray && !Array.isArray(customRules)) {
  6525. showTips(i18n("errorRulesMustBeArray"));
  6526. return;
  6527. }
  6528. }
  6529. } else {
  6530. if (customRulesInput.value != preCustom) {
  6531. storage.setItem("hpRules", []);
  6532. storage.setItem("smartRules", []);
  6533. }
  6534. if (customRulesInput.value == "") {
  6535. customRules = "";
  6536. } else {
  6537. customRules = JSON.parse(customRulesInput.value);
  6538. if (Array && Array.isArray && !Array.isArray(customRules)) {
  6539. showTips(i18n("errorRulesMustBeArray"));
  6540. return;
  6541. }
  6542. customRulesInput.value = JSON.stringify(customRules, null, 4);
  6543. }
  6544. }
  6545. debug(customRules);
  6546. storage.setItem("customRules", customRules);
  6547. } catch(e) {
  6548. debug(e);
  6549. let pos = e && e.message && e.message.match(/position (\d+)/);
  6550. if (pos && !editor) {
  6551. pos = parseInt(pos[1]);
  6552. customRulesInput.value = customRulesInput.value.slice(0, pos) + "➡️" + customRulesInput.value.slice(pos);
  6553. }
  6554. showTips(i18n("errorJson"));
  6555. return;
  6556. }
  6557. rulesData.lang = langSelect.value || "";
  6558. if (setConfigPageInput.checked) rulesData.configPage = location.href;
  6559. rulesData.wedata2github = wedata2githubInput.checked;
  6560. let opacity = parseInt(opacityInput.value) || 0;
  6561. if (opacity > 100) opacity = 100;
  6562. else if (opacity < 0) opacity = 0;
  6563. rulesData.opacity = opacity / 100;
  6564. rulesData.blacklist = blacklistInput.value ? blacklistInput.value.trim().split("\n") : "";
  6565. rulesData.hideBar = hideBarInput.checked;
  6566. rulesData.hideBarButNoStop = hideBarButNoStopInput.checked;
  6567. rulesData.dbClick2Stop = dbClick2StopInput.checked;
  6568. rulesData.enableWhiteList = !enableWhiteListInput.checked;
  6569. rulesData.enableDebug = enableDebugInput.checked;
  6570. rulesData.updateNotification = updateNotificationInput.checked;
  6571. rulesData.enableHistory = enableHistoryInput.checked;
  6572. rulesData.enableHistoryAfterInsert = enableHistoryAfterInsertInput.checked;
  6573. rulesData.openInNewTab = openInNewTabInput.checked;
  6574. rulesData.hideLoadingIcon = hideLoadingIconInput.checked;
  6575. rulesData.hideBarArrow = hidePageBarArrowInput.checked;
  6576. rulesData.customFirst = customFirstInput.checked;
  6577. rulesData.lastPageTips = lastPageTipsInput.checked;
  6578. rulesData.initRun = initRunInput.checked;
  6579. rulesData.autoLoadNum = autoLoadNumInput.value !== "0" ? autoLoadNumInput.value : '';
  6580. rulesData.rate = parseFloat(rateInput.value) || 0;
  6581. rulesData.preload = preloadInput.checked;
  6582. rulesData.manualMode = manualModeInput.checked;
  6583. rulesData.clickMode = clickModeInput.checked;
  6584. rulesData.pageBarMenu = pageBarMenuInput.checked;
  6585. rulesData.arrowToScroll = arrowToScrollInput.checked;
  6586. rulesData.contentVisibility = contentVisibilityInput.checked;
  6587. if (rulesData.sideController != sideControllerInput.checked) {
  6588. rulesData.sideControllerPos = false;
  6589. }
  6590. rulesData.sideController = sideControllerInput.checked;
  6591. rulesData.sideControllerScroll = sideControllerScrollInput.checked;
  6592. rulesData.sideControllerLoadNow = sideControllerLoadNowInput.checked;
  6593. rulesData.sideControllerAlways = sideControllerAlwaysInput.checked;
  6594. rulesData.pageElementCss = pageElementCssInput.value;
  6595. rulesData.customCss = customCssInput.value;
  6596. rulesData.upBtnImg = upBtnImgInput.value;
  6597. rulesData.downBtnImg = downBtnImgInput.value;
  6598. rulesData.sideControllerIcon = sideControllerIconInput.value;
  6599. rulesData.loadingText = loadingTextInput.value;
  6600. rulesData.dbClick2StopCtrl = dbClick2StopCtrlInput.checked;
  6601. rulesData.dbClick2StopAlt = dbClick2StopAltInput.checked;
  6602. rulesData.dbClick2StopShift = dbClick2StopShiftInput.checked;
  6603. rulesData.dbClick2StopMeta = dbClick2StopMetaInput.checked;
  6604. rulesData.dbClick2StopKey = dbClick2StopKeyInput.value;
  6605. storage.setItem("rulesData", rulesData);
  6606. let customUrls = customUrlsInput.value.trim(), urlImported = false;
  6607. if (customUrls) {
  6608. customUrls = customUrls.split(/\n/);
  6609. for (let c = 0; c < customUrls.length; c++) {
  6610. let url;
  6611. if (/^0\s*\|/.test(customUrls[c])) {
  6612. url = customUrls[c].replace(/^0\s*\|\s*/, "").trim();
  6613. if (!/^http/.test(url)) {
  6614. showTips(i18n("errorWrongUrl"));
  6615. return;
  6616. }
  6617. } else {
  6618. url = customUrls[c].trim();
  6619. if (!/^http/.test(url)) {
  6620. showTips(i18n("errorWrongUrl"));
  6621. return;
  6622. }
  6623. }
  6624. let maxId = 1, hasUrl = false;
  6625. if (!rulesData.urls) {
  6626. rulesData.urls = [];
  6627. }
  6628. ruleUrls.forEach(u => {
  6629. if (maxId < u.id) {
  6630. maxId = u.id;
  6631. }
  6632. if (u.url == url) {
  6633. hasUrl = true;
  6634. }
  6635. });
  6636. if (hasUrl) break;
  6637. if (!rulesData.sort) rulesData.sort = [1];
  6638. let newRule = {id: maxId + 1, url: url};
  6639. ruleUrls.push(newRule);
  6640. rulesData.urls.push(newRule);
  6641. rulesData.sort.push(maxId + 1);
  6642. storage.setItem("rulesData", rulesData);
  6643. let rulebar = new Rulebar();
  6644. rulebar.init(newRule);
  6645. rulebarList.push(rulebar);
  6646. }
  6647. }
  6648. showTips(i18n("settingsSaved"));
  6649. };
  6650. return true;
  6651. }
  6652.  
  6653. function updateRules (success, fail, keepCache) {
  6654. if (!storage.supportCrossSave()) {
  6655. fail({url:''}, "Not support cross storage");
  6656. showTips("Current platform do not support cross storage!");
  6657. return;
  6658. }
  6659. if (inUpdate) return;
  6660. inUpdate = true;
  6661. let ruleIndex = ruleUrls.length - 1;
  6662. if (!keepCache) {
  6663. storage.setItem("hpRules", []);
  6664. storage.setItem("smartRules", []);
  6665. }
  6666. let allOk = true;
  6667. let preLength = ruleParser.rules.length;
  6668. let fetchVersion = -1;
  6669. async function needUpdate(url, id) {
  6670. if (!/^https:\/\/hoothin\.github\.io\/|\/hoothin\/UserScripts\/.*\/Pagetual\/pagetualRules\.json/i.test(url)) {
  6671. return true;
  6672. }
  6673. let rulesLength = ruleParser.rules.reduce((acc, cur) => acc + (cur.from == id ? 1 : 0), 0);
  6674. if (rulesLength === 0) return true;
  6675. if (fetchVersion >= 0) {
  6676. return fetchVersion > (rulesData.ruleVersion || 0);
  6677. }
  6678. fetchVersion = await new Promise(resolve => {
  6679. _GM_xmlhttpRequest({
  6680. url: url.replace(/\/\w+\.json/i, "/version"),
  6681. method: 'GET',
  6682. timeout: 20000,
  6683. headers: {
  6684. 'accept': 'application/json,text/html'
  6685. },
  6686. onload: function(res) {
  6687. let version = parseInt(res.response || res.responseText);
  6688. resolve(version || -1);
  6689. },
  6690. onerror: function(e) {
  6691. resolve(-1);
  6692. },
  6693. ontimeout: function(e) {
  6694. resolve(-1);
  6695. }
  6696. });
  6697. });
  6698. return fetchVersion > (rulesData.ruleVersion || 0);
  6699. }
  6700. async function addNextRule() {
  6701. if (ruleIndex < 0) {
  6702. let now = new Date().getTime();
  6703. storage.setItem("ruleLastUpdate", now);
  6704. storage.setItem("rules", ruleParser.rules);
  6705. let curLength = ruleParser.rules.length;
  6706. if (curLength !== preLength && rulesData.updateNotification) {
  6707. _GM_notification({
  6708. text: `Rules has updated( ${preLength} => ${curLength} )`,
  6709. title: "Pagetual rules updated",
  6710. onclick: (event) => {
  6711. event.preventDefault();
  6712. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  6713. }
  6714. });
  6715. }
  6716. inUpdate = false;
  6717. let rulesDataChanged = false;
  6718. if (fetchVersion >= 0 && rulesData.ruleVersion !== fetchVersion) {
  6719. rulesData.ruleVersion = fetchVersion;
  6720. rulesDataChanged = true;
  6721. }
  6722. if (rulesData.uninited && allOk && ruleUrls.length > 1) {
  6723. rulesData.uninited = false;
  6724. rulesDataChanged = true;
  6725. }
  6726. if (rulesDataChanged) {
  6727. storage.setItem("rulesData", rulesData);
  6728. }
  6729. success();
  6730. } else {
  6731. let rule = ruleUrls[ruleIndex--];
  6732. if (await needUpdate(rule.url, rule.id)) {
  6733. ruleParser.addRuleByUrl(rule.url, rule.id, (json, err) => {
  6734. if (!json) {
  6735. allOk = false;
  6736. fail(rule, err);
  6737. }
  6738. addNextRule();
  6739. });
  6740. } else {
  6741. addNextRule();
  6742. }
  6743. }
  6744. }
  6745. addNextRule();
  6746. }
  6747.  
  6748. function objIsArr(obj) {
  6749. return obj &&
  6750. typeof obj === 'object' &&
  6751. typeof obj.length === 'number' &&
  6752. !(obj.propertyIsEnumerable('length'));
  6753. }
  6754.  
  6755. function isVisible(el, win) {
  6756. if(!el || !el.offsetParent)return false;
  6757. var loopable = true,
  6758. visible = el.nodeName && win.getComputedStyle(el).display != 'none' && win.getComputedStyle(el).visibility != 'hidden';
  6759. while(loopable && visible) {
  6760. el = el.parentNode;
  6761.  
  6762. if(el && el.nodeType === 1 && !compareNodeName(el, ["body"])) {
  6763. visible = win.getComputedStyle(el).display != 'none' && win.getComputedStyle(el).visibility != 'hidden';
  6764. }else {
  6765. loopable = false;
  6766. }
  6767. }
  6768. return visible;
  6769. }
  6770.  
  6771. function getElementTop(ele) {
  6772. if (!ele) return 0;
  6773. if (ele.getBoundingClientRect) {
  6774. return ele.getBoundingClientRect().top + document.documentElement.scrollTop;
  6775. }
  6776. var actualTop = ele.offsetTop;
  6777. var current = ele.offsetParent;
  6778. while (current) {
  6779. actualTop += current.offsetTop;
  6780. current = current.offsetParent;
  6781. }
  6782. return actualTop;
  6783. }
  6784.  
  6785. function getElementLeft(ele) {
  6786. if (!ele) return 0;
  6787. if (ele.getBoundingClientRect) {
  6788. return ele.getBoundingClientRect().left + document.documentElement.scrollLeft;
  6789. }
  6790. var actualLeft = ele.offsetLeft;
  6791. var current = ele.offsetParent;
  6792. while (current) {
  6793. actualLeft += current.offsetLeft;
  6794. current = current.offsetParent;
  6795. }
  6796. return actualLeft;
  6797. }
  6798.  
  6799. function getElementBottom(ele) {
  6800. return getElementTop(ele) + (ele.offsetHeight || ele.scrollHeight);
  6801. }
  6802.  
  6803. function getFormatJSON(obj){
  6804. if(!objIsArr(obj) || obj.length === 0)return "";
  6805. return JSON.stringify(obj, null, 4);
  6806. }
  6807.  
  6808. function globMatch(first, second) {
  6809. if (first === '*') {
  6810. return true;
  6811. }
  6812. if (first.length == 0 && second.length == 0){
  6813. return true;
  6814. }
  6815.  
  6816. if (first.length > 1 && first[0] == '*' &&
  6817. second.length == 0){
  6818. return false;
  6819. }
  6820.  
  6821. if ((first.length > 1 && first[0] == '?') ||
  6822. (first.length != 0 && second.length != 0 &&
  6823. first[0] == second[0])){
  6824. return globMatch(first.substring(1),
  6825. second.substring(1));
  6826. }
  6827.  
  6828. if (first.length > 0 && first[0] == '*'){
  6829. return globMatch(first.substring(1), second) ||
  6830. globMatch(first, second.substring(1));
  6831. }
  6832.  
  6833. return false;
  6834. }
  6835.  
  6836. let pageReady = false;
  6837. function initRules(callback) {
  6838. charset = (document.characterSet || document.charset || document.inputEncoding);
  6839. let equiv = document.querySelector('[http-equiv="Content-Type"]');
  6840. if (equiv && equiv.content) {
  6841. let innerCharSet = equiv.content.match(/charset\=([^;]+)/);
  6842. if (!innerCharSet) {
  6843. charsetValid = false;
  6844. } else if (innerCharSet[1].replace("-", "").toLowerCase() != charset.replace("-", "").toLowerCase()) {
  6845. charsetValid = false;
  6846. }
  6847. } else charsetValid = false;
  6848. storage.getItem("rulesData", data => {
  6849. /*0 wedata格式,1 pagetual格式*/
  6850. ruleUrls = [{
  6851. id: 1,
  6852. url: data && data.wedata2github ? 'https://hoothin.github.io/UserScripts/Pagetual/items_all.json' : 'http://wedata.net/databases/AutoPagerize/items_all.json',
  6853. type: 0,
  6854. }];
  6855. if (data) {
  6856. rulesData = data;
  6857. if (data.urls) ruleUrls = ruleUrls.concat(data.urls);
  6858. if (data.sort) {
  6859. let urls = [];
  6860. data.sort.forEach(id => {
  6861. for (let s = 0; s < ruleUrls.length; s++) {
  6862. if (id == ruleUrls[s].id) {
  6863. urls.push(ruleUrls[s]);
  6864. break;
  6865. }
  6866. }
  6867. });
  6868. ruleUrls = urls;
  6869. }
  6870. }
  6871. if (rulesData.lang) {
  6872. setLang(rulesData.lang);
  6873. }
  6874. if (rulesData.firstRun) {
  6875. rulesData.firstRun = false;
  6876. storage.setItem("rulesData", rulesData);
  6877. setTimeout(() => {
  6878. storage.getItem("rulesData", data => {
  6879. if (data.firstRun === false) {
  6880. _GM_openInTab(firstRunPage, {active: true});
  6881. }
  6882. });
  6883. }, 100);
  6884. }
  6885. _GM_registerMenuCommand(i18n("configure"), () => {
  6886. _GM_openInTab(rulesData.configPage || configPage[0], {active: true});
  6887. });
  6888. if (rulesData.blacklist && rulesData.blacklist.length > 0) {
  6889. let href = location.href.slice(0, 500);
  6890. let commentStart = false;
  6891. for (let i = 0; i < rulesData.blacklist.length; i++) {
  6892. let curGlob = rulesData.blacklist[i];
  6893. if (!curGlob) continue;
  6894. if (curGlob.indexOf("//") == 0) continue;
  6895. if (commentStart) {
  6896. if (/\*\/$/.test(curGlob)) {
  6897. commentStart = false;
  6898. }
  6899. continue;
  6900. }
  6901. if (curGlob.indexOf("/*") == 0) {
  6902. commentStart = true;
  6903. continue;
  6904. }
  6905. if (curGlob.indexOf("/") == 0) {
  6906. let regMatch = curGlob.match(/^\/(.*)\/(\w*)$/);
  6907. if (regMatch && new RegExp(regMatch[1], regMatch[2]).test(href)) {
  6908. forceState == 1;
  6909. return;
  6910. }
  6911. } else if (globMatch(curGlob, href)) {
  6912. forceState == 1;
  6913. return;
  6914. }
  6915. }
  6916. }
  6917. _GM_registerMenuCommand(i18n("editCurrent"), () => {
  6918. picker.start();
  6919. });
  6920. ruleParser.initSavedRules(async () => {
  6921. let upBtnImg = rulesData.upBtnImg, downBtnImg = rulesData.downBtnImg, _sideControllerIcon = rulesData.sideControllerIcon;
  6922. if (upBtnImg && downBtnImg) {
  6923. downSvgCSS = downSvgCSS.replace("transform: rotate(180deg);", "");
  6924. } else if (upBtnImg && !downBtnImg) {
  6925. downBtnImg = upBtnImg;
  6926. } else if(downBtnImg && !upBtnImg) {
  6927. upBtnImg = downBtnImg;
  6928. }
  6929. if (upBtnImg) {
  6930. upSvg = /https?:|data/.test(upBtnImg) ? `<img class="pagetual" src="${upBtnImg}"/>` : `<span>${upBtnImg}</span>`;
  6931. }
  6932. if (downBtnImg) {
  6933. downSvg = /https?:|data/.test(downBtnImg) ? `<img class="pagetual" src="${downBtnImg}"/>` : `<span>${downBtnImg}</span>`;
  6934. }
  6935. if (_sideControllerIcon) {
  6936. sideControllerIcon = /https?:|data/.test(_sideControllerIcon) ? `<img class="pagetual" src="${_sideControllerIcon}"/>` : `<span>${_sideControllerIcon}</span>`;
  6937. }
  6938. setLoadingDiv(rulesData.loadingText || i18n("loadingText"));
  6939. if (typeof(rulesData.opacity) == "undefined") {
  6940. rulesData.opacity = 1;
  6941. }
  6942. if (typeof(rulesData.hideBar) == "undefined") {
  6943. rulesData.hideBar = false;
  6944. }
  6945. if (typeof(rulesData.dbClick2Stop) == "undefined") {
  6946. rulesData.dbClick2Stop = true;
  6947. }
  6948. if (typeof(rulesData.enableWhiteList) == "undefined") {
  6949. rulesData.enableWhiteList = false;
  6950. }
  6951. if (typeof(rulesData.enableHistory) == "undefined") {
  6952. rulesData.enableHistory = false;
  6953. }
  6954. if (typeof(rulesData.openInNewTab) == "undefined") {
  6955. rulesData.openInNewTab = false;
  6956. }
  6957. if (typeof(rulesData.enableDebug) == "undefined") {
  6958. rulesData.enableDebug = true;
  6959. }
  6960. if (typeof(rulesData.updateNotification) == "undefined") {
  6961. rulesData.updateNotification = true;
  6962. }
  6963. if (typeof(rulesData.initRun) == "undefined") {
  6964. rulesData.initRun = true;
  6965. }
  6966. if (typeof(rulesData.preload) == "undefined") {
  6967. rulesData.preload = true;
  6968. }
  6969. if (typeof(rulesData.customFirst) == "undefined") {
  6970. rulesData.customFirst = false;
  6971. }
  6972. if (typeof(rulesData.manualMode) == "undefined") {
  6973. rulesData.manualMode = false;
  6974. }
  6975. if (typeof(rulesData.clickMode) == "undefined") {
  6976. rulesData.clickMode = false;
  6977. }
  6978. if (typeof(rulesData.pageBarMenu) == "undefined") {
  6979. rulesData.pageBarMenu = true;
  6980. }
  6981. if (typeof(rulesData.arrowToScroll) == "undefined") {
  6982. rulesData.arrowToScroll = false;
  6983. }
  6984. if (typeof(rulesData.hideLoadingIcon) == "undefined") {
  6985. rulesData.hideLoadingIcon = false;
  6986. }
  6987. if (typeof(rulesData.hideBarArrow) == "undefined") {
  6988. rulesData.hideBarArrow = false;
  6989. }
  6990. if (typeof(rulesData.lastPageTips) == "undefined") {
  6991. rulesData.lastPageTips = true;
  6992. }
  6993. if (typeof(rulesData.rate) == "undefined") {
  6994. rulesData.rate = 1;
  6995. }
  6996. rate = rulesData.rate;
  6997. if (rulesData.autoLoadNum && rulesData.initRun) {
  6998. autoLoadNum = parseInt(rulesData.autoLoadNum);
  6999. }
  7000. openInNewTab = rulesData.openInNewTab ? 1 : 0;
  7001. enableDebug = rulesData.enableDebug;
  7002.  
  7003. let _nextSwitch = await getListData("nextSwitch", location.host);
  7004. if (typeof(_nextSwitch) !== "undefined") {
  7005. nextIndex = _nextSwitch || 0;
  7006. }
  7007.  
  7008. let _forceState = await getListData("forceState", location.host);
  7009. if (typeof(_forceState) == "undefined") {
  7010. _forceState = await getData("forceState_" + location.host);
  7011. }
  7012. if (typeof(_forceState) == "undefined") {
  7013. _forceState = (rulesData.enableWhiteList ? 1 : 0);
  7014. }
  7015. forceState = _forceState;
  7016.  
  7017. autoScroll = await getListData("autoScroll", location.host + location.pathname) || 0;
  7018.  
  7019. updateDate = await getData("ruleLastUpdate");
  7020.  
  7021. let _loadNowNum = await getData("loadNowNum");
  7022. if (typeof(_loadNowNum) != "undefined") {
  7023. loadNowNum = _loadNowNum;
  7024. }
  7025. let _autoScrollRate = await getData("autoScrollRate");
  7026. if (_autoScrollRate) {
  7027. autoScrollRate = _autoScrollRate;
  7028. }
  7029.  
  7030. author = await getData("author") || "";
  7031.  
  7032. manualPause = !!await getListData("pauseState", location.host);
  7033.  
  7034. let href = location.href.slice(0, 100);
  7035. try {
  7036. if (_unsafeWindow.initedPagetual) {
  7037. if (ruleImportUrlReg.test(href)) {
  7038. showTips(i18n('duplicate'));
  7039. }
  7040. return;
  7041. }
  7042. _unsafeWindow.initedPagetual = true;
  7043. } catch(e) {showTips(e)}
  7044. listenUrl();
  7045. _GM_registerMenuCommand(i18n("update"), () => {
  7046. showTips(i18n("beginUpdate"), "", 60000);
  7047. updateRules(() => {
  7048. showTips(i18n("updateSucc"));
  7049. location.reload();
  7050. },(rule, err) => {
  7051. showTips(`Failed to update ${rule.url} rules!`);
  7052. debug(err);
  7053. });
  7054. });
  7055. _GM_registerMenuCommand(i18n(forceState == 1 ? "enable" : "disableSite"), () => {
  7056. if (forceState == 1) {
  7057. forceState = 0;
  7058. showTips(i18n("enableSiteTips"));
  7059. changeStop(false, true);
  7060. } else {
  7061. forceState = 1;
  7062. showTips(i18n("disableSiteTips"));
  7063. changeStop(true, true);
  7064. sideController.remove();
  7065. }
  7066. setListData("forceState", location.host, forceState);
  7067. if (!ruleParser.curSiteRule.url) {
  7068. setTimeout(() => {
  7069. location.reload();
  7070. }, 500);
  7071. }
  7072. });
  7073. _GM_registerMenuCommand(i18n("toggleAutoScroll"), () => {
  7074. autoScroll = (autoScroll ? 0 : prompt(i18n("autoScrollRate"), autoScrollRate)) || 0;
  7075. autoScroll = parseInt(autoScroll) || 0;
  7076. if (autoScroll < 0) autoScroll = 0;
  7077. if (autoScroll && autoScroll != autoScrollRate) {
  7078. autoScrollRate = autoScroll;
  7079. storage.setItem("autoScrollRate", autoScrollRate);
  7080. }
  7081. setListData("autoScroll", location.host + location.pathname, autoScroll);
  7082. startAutoScroll();
  7083. });
  7084. startAutoScroll();
  7085.  
  7086.  
  7087. if (initConfig(href)) {
  7088. document.addEventListener("click", e => {
  7089. if (e.target && typeof e.target.dataset.pagetualPicker !== 'undefined') {
  7090. e.preventDefault();
  7091. e.stopPropagation();
  7092. picker.start();
  7093. }
  7094. });
  7095. return;
  7096. }
  7097. pageReady = true;
  7098. if (forceState == 1) return;
  7099. let now = new Date().getTime();
  7100. if (!updateDate || now - updateDate > 2 * 24 * 60 * 60 * 1000) {
  7101. updateRules(() => {
  7102. }, (rule, err) => {}, true);
  7103. storage.setItem("ruleLastUpdate", now);
  7104. }
  7105. callback();
  7106. });
  7107. });
  7108. }
  7109.  
  7110. let xhrFailed = false;
  7111. function requestDoc(url, callback) {
  7112. let postParams = url.match(/#p{(.*)}$/);
  7113. if (postParams) {
  7114. postParams = postParams[1];
  7115. url = url.replace(/#p{.*/, "");
  7116. }
  7117. let ruleHeaders = ruleParser.curSiteRule.headers;
  7118. let headers = {
  7119. 'Referer': location.href,
  7120. 'User-Agent': navigator.userAgent,
  7121. 'accept': 'text/html,application/xhtml+xml,application/xml',
  7122. "Content-Type": (postParams ? "application/x-www-form-urlencoded" : "text/html") + ";charset=" + charset,
  7123. };
  7124. if (ruleHeaders) {
  7125. if (ruleHeaders.referer) {
  7126. headers.referer = ruleHeaders.referer;
  7127. }
  7128. if (ruleHeaders.userAgent) {
  7129. headers.userAgent = ruleHeaders.userAgent;
  7130. }
  7131. if (ruleHeaders.accept) {
  7132. headers.accept = ruleHeaders.accept;
  7133. }
  7134. if (ruleHeaders.contentType) {
  7135. headers.contentType = ruleHeaders.contentType;
  7136. let ruleCharset = ruleHeaders.contentType.match(/charset\=([^;]+)/);
  7137. if (ruleCharset) charset = ruleCharset[1];
  7138. }
  7139. if (ruleHeaders.cookie) {
  7140. headers.cookie = ruleHeaders.cookie;
  7141. }
  7142. }
  7143. _GM_xmlhttpRequest({
  7144. url: url,
  7145. method: postParams ? 'POST' : 'GET',
  7146. data: postParams,
  7147. overrideMimeType: 'text/html;charset=' + charset,
  7148. headers: headers,
  7149. timeout: 50000,
  7150. onload: async function(res) {
  7151. if (isPause) return callback(false);
  7152. var doc = null, response = res.response;
  7153. try {
  7154. doc = document.implementation.createHTMLDocument('');
  7155. doc.documentElement.innerHTML = response;
  7156. } catch (e) {
  7157. debug('parse error:' + e.toString());
  7158. }
  7159. let pageElement = null;
  7160. let preCode = ruleParser.curSiteRule.pagePre;
  7161. if (preCode) {
  7162. try {
  7163. let preResult;
  7164. if (typeof preCode == 'function') {
  7165. preResult = await preCode(response, doc);
  7166. } else if (preCode.length == 2) {
  7167. preResult = response.replace(new RegExp(preCode[0], "gi"), preCode[1]);
  7168. } else {
  7169. preResult = await new AsyncFunction("response", "doc", '"use strict";' + preCode)(response, doc);
  7170. }
  7171. if (typeof preResult !== "undefined") {
  7172. if (typeof preResult === "string") {
  7173. doc.documentElement.innerHTML = preResult;
  7174. } else pageElement = preResult;
  7175. }
  7176. } catch(e) {
  7177. debug(e);
  7178. }
  7179. }
  7180. let base = doc.querySelector("base");
  7181. ruleParser.basePath = (base && base.href) || url;
  7182. if (charsetValid && !ruleHeaders) {
  7183. let equiv = doc.querySelector('[http-equiv="Content-Type"]');
  7184. if (equiv && equiv.content) {
  7185. let innerCharSet = equiv.content.match(/charset\=([^;]+)/);
  7186. if (innerCharSet && innerCharSet[1].replace("-", "").toLowerCase() != charset.replace("-", "").toLowerCase()) {
  7187. charset = innerCharSet[1];
  7188. return requestDoc(url, callback);
  7189. }
  7190. }
  7191. }
  7192. if (pageElement === null) {
  7193. pageElement = ruleParser.getPageElement(doc);
  7194. }
  7195. if ((!pageElement || pageElement.length == 0) && res.status >= 400) {
  7196. debug(res.status + " " + url, "Error status");
  7197. if (!ruleParser.curSiteRule.smart || !xhrFailed) {
  7198. xhrFailed = true;
  7199. return callback(false);
  7200. }
  7201. }
  7202. if (inCors && (!pageElement || pageElement.length == 0) && ruleParser.curSiteRule.smart) {
  7203. let article;
  7204. for (let i = 0; i < mainSel.length; i++) {
  7205. article = doc.querySelectorAll(mainSel[i]);
  7206. if (article && article.length === 1) break;
  7207. }
  7208. if (article && article.length == 1) {
  7209. article = article[0];
  7210. ruleParser.curSiteRule.pageElement = article.nodeName.toLowerCase() + (article.id ? "#" + article.id : "") + (article.className ? "." + article.className.replace(/ /g, ".") : "") + ">*";
  7211. pageElement = article.children;
  7212. } else {
  7213. ruleParser.curSiteRule.pageElement = allOfBody;
  7214. pageElement = ruleParser.getPageElement(doc);
  7215. }
  7216. ruleParser.getInsert(true);
  7217. }
  7218. //只有1的話怕不是圖片哦
  7219. if (pageElement && (pageElement.length > 1 || (pageElement.length == 1 && !compareNodeName(pageElement[0], ["img"])))) {
  7220. await ruleParser.insertPage(doc, pageElement, url, callback, false);
  7221. if (ruleParser.curSiteRule.action == 1) {
  7222. isLoading = true;
  7223. requestFromIframe(url, async (doc, eles) => {
  7224. if (eles) {
  7225. await ruleParser.insertPage(doc, eles, url, callback, true);
  7226. } else isLoading = false;
  7227. });
  7228. } else ruleParser.curSiteRule.action = 0;
  7229. } else if ((ruleParser.curSiteRule.smart || curPage == 1) && !inCors) {
  7230. ruleParser.curSiteRule.action = 1;
  7231. requestFromIframe(url, async (doc, eles) => {
  7232. if (eles) {
  7233. await ruleParser.insertPage(doc, eles, url, callback, true);
  7234. } else isLoading = false;
  7235. });
  7236. } else {
  7237. debug("Stop as no page element");
  7238. ruleParser.noValidContent(url);
  7239. changeStop(true);
  7240. callback(false);
  7241. }
  7242. },
  7243. onerror: function(e) {
  7244. debug(e, "NetError");
  7245. callback(false);
  7246. },
  7247. ontimeout: function(e) {
  7248. debug(e, "NetTimeout");
  7249. callback(false);
  7250. }
  7251. });
  7252. }
  7253.  
  7254. function initPage() {
  7255. ruleParser.initPage(() => {
  7256. if (ruleParser.curSiteRule.autoLoadNum) {
  7257. autoLoadNum = ruleParser.curSiteRule.autoLoadNum;
  7258. }
  7259. if (ruleParser.curSiteRule.nextLink && Array && Array.isArray && Array.isArray(ruleParser.curSiteRule.nextLink)) {
  7260. _GM_registerMenuCommand(i18n("nextSwitch"), () => {
  7261. nextSwitch.start();
  7262. });
  7263. }
  7264. if (ruleParser.nextLinkHref) {
  7265. let isJs = ruleParser.hrefIsJs(ruleParser.nextLinkHref);
  7266. if (!isJs) {
  7267. let inForce = (forceState == 2 || forceState == 3);
  7268. _GM_registerMenuCommand(i18n(inForce ? "cancelForceIframe" : "forceIframe"), () => {
  7269. if (inForce) {
  7270. setListData("forceState", location.host, "");
  7271. } else {
  7272. let _state = ruleParser.curSiteRule.action > 0 || confirm(i18n("forceAllBody")) ? 2 : 3;
  7273. setListData("forceState", location.host, _state);
  7274. }
  7275. setTimeout(() => {
  7276. location.reload();
  7277. }, 500);
  7278. });
  7279. }
  7280. _GM_registerMenuCommand(i18n("loadNow"), () => {
  7281. if (autoLoadNum != -1) {
  7282. autoLoadNum = -1;
  7283. return;
  7284. }
  7285. let loadNum = window.prompt(i18n("loadConfirm"), loadNowNum);
  7286. if (loadNum === "" || loadNum === null) return;
  7287. loadNum = Math.abs(parseInt(loadNum)) || 0;
  7288. if (loadNowNum != loadNum) {
  7289. loadNowNum = loadNum;
  7290. storage.setItem("loadNowNum", loadNowNum);
  7291. }
  7292. autoLoadNum = loadNum;
  7293. nextPage();
  7294. });
  7295. }
  7296. initListener();
  7297. });
  7298. }
  7299.  
  7300. var pageBarStyle, mainStyleEle, mainStyleStyle;
  7301. function initView() {
  7302. if (!mainStyleStyle) {
  7303. mainStyleStyle = `
  7304. .pagetual_pageBar{
  7305. -moz-transition:all 0.3s ease-in-out 0s;
  7306. -webkit-transition:all 0.3s ease-in-out 0s;
  7307. transition:all 0.3s ease-in-out 0s;
  7308. font-family: Arial,sans-serif !important;
  7309. text-align: center !important;
  7310. }
  7311. .pagetual_pageBar.stop {
  7312. -webkit-filter: invert(100%);
  7313. filter: invert(100%);
  7314. opacity: 1!important;
  7315. }
  7316. .pagetual_pageBar.hide {
  7317. display: none!important;
  7318. }
  7319. .pagetual-hide {
  7320. display: none!important;
  7321. }
  7322. .pagetual_pageBar:hover {
  7323. opacity: 1!important;
  7324. box-shadow: 0px 0px 10px 0px #000000aa;
  7325. border-radius: 20px;
  7326. background-color: rgb(240 240 240 / 80%);
  7327. border-color: transparent!important;
  7328. }
  7329. .pagetual_pageBar span {
  7330. vertical-align: super;
  7331. }
  7332. .pagetual_pageBar a::before,
  7333. .pagetual_pageBar a::after {
  7334. content: none;
  7335. }
  7336. .pagetual_pageBar a>span {
  7337. margin-top: 0!important;
  7338. pointer-events: none;
  7339. padding: unset;
  7340. opacity: 0;
  7341. -moz-transition:margin-top 0.3s ease-in-out 0s, opacity .3s;
  7342. -webkit-transition:margin-top 0.3s ease-in-out 0s, opacity .3s;
  7343. transition:margin-top 0.3s ease-in-out 0s, opacity .3s;
  7344. transform: none;
  7345. left: 0;
  7346. margin-left: calc(50% - 20px);
  7347. }
  7348. .pagetual_pageBar a>span:hover {
  7349. color: red;
  7350. }
  7351. .pagetual_pageBar a:hover>span {
  7352. opacity: 1!important;
  7353. }
  7354. .pagetual_pageBar span.prevScreen,
  7355. .pagetual_pageBar span.nextScreen {
  7356. display: block!important;
  7357. top: unset !important;
  7358. padding: unset !important;
  7359. opacity: 0!important;
  7360. }
  7361. .pagetual_pageBar a:hover>span.prevScreen {
  7362. margin-top: -${rulesData.opacity == 1 ? 31 : 30}px!important;
  7363. pointer-events: all;
  7364. }
  7365. .pagetual_pageBar span.refreshRing {
  7366. position: absolute;
  7367. top: 0;
  7368. opacity: 0;
  7369. height: 30px;
  7370. margin-left: calc(50% - 23px);
  7371. display: block!important;
  7372. }
  7373. .pagetual_pageBar span.refreshRing>svg {
  7374. background: white;
  7375. border-radius: 50%;
  7376. }
  7377. .pagetual_pageBar a:hover>span.refreshRing {
  7378. opacity: 0.3;
  7379. -webkit-animation: pagetual_ring 2.0s infinite linear;
  7380. animation: pagetual_ring 2.0s infinite linear;
  7381. }
  7382. @-webkit-keyframes pagetual_ring {
  7383. 0% { -webkit-transform: rotate(0deg) }
  7384. 100% {
  7385. -webkit-transform: rotate(360deg);
  7386. }
  7387. }
  7388. @keyframes pagetual_ring {
  7389. 0% {
  7390. transform: rotate(0deg);
  7391. -webkit-transform: rotate(0deg);
  7392. } 100% {
  7393. transform: rotate(360deg);
  7394. -webkit-transform: rotate(360deg);
  7395. }
  7396. }
  7397. .pagetual_pageBar a:hover>span.nextScreen {
  7398. margin-top: 30px!important;
  7399. pointer-events: all;
  7400. }
  7401. .pagetual_pageBar span>svg {
  7402. -moz-transition:transform 0.5s ease, opacity 0.3s ease;
  7403. -webkit-transition:transform 0.5s ease, opacity 0.3s ease;
  7404. transition:transform 0.5 ease, opacity 0.3s ease;
  7405. opacity: 0;
  7406. }
  7407. .pagetual_pageBar.stop span>svg{
  7408. opacity: 1;
  7409. }
  7410. .pagetual_pageBar.stop span>svg>path{
  7411. transform: scale(.8);
  7412. transform-origin: center;
  7413. -moz-transition:transform 0.3s ease;
  7414. -webkit-transition:transform 0.3s ease;
  7415. transition:transform 0.3 ease;
  7416. }
  7417. .pagetual_pageBar.stop:hover span>svg>path{
  7418. transform: unset;
  7419. }
  7420. .pagetual_pageBar:hover span>svg {
  7421. opacity: 1;
  7422. }
  7423. .pagetual_pageBar span>svg.upSvg:hover {
  7424. transform: rotate(360deg) scale3d(1.2, 1.2, 1.2);
  7425. }
  7426. .pagetual_pageBar span>svg.downSvg:hover {
  7427. transform: rotate(540deg) scale3d(1.2, 1.2, 1.2)!important;
  7428. }
  7429. .pagetual_pageBar .pagetual_pageNum{
  7430. color: #55555f;
  7431. }
  7432. .pagetual_pageBar .pagetual_pageNum:hover{
  7433. color: #ff6464;
  7434. }
  7435. .pagetual_tipsWords {
  7436. font-size: 50px;
  7437. font-weight: bold;
  7438. font-family: "黑体", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
  7439. "Oxygen", "Ubuntu", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji",
  7440. "Segoe UI Emoji", "Segoe UI Symbol";
  7441. color: #ffffff;
  7442. min-height: 70px;
  7443. max-width: 80%;
  7444. line-height: 1.5;
  7445. position: fixed;
  7446. left: 50%;
  7447. top: 10%;
  7448. margin-left: -99999px;
  7449. padding: 0 15px;
  7450. z-index: 2147483647;
  7451. background-color: #000;
  7452. border: 1px solid #303030;
  7453. border-radius: 10px;
  7454. opacity: 0;
  7455. filter: alpha(opacity=65);
  7456. box-shadow: 5px 5px 20px 0px #000;
  7457. -moz-transition:opacity 0.3s ease-in-out 0s;
  7458. -webkit-transition:opacity 0.3s ease-in-out 0s;
  7459. transition:opacity 0.3s ease-in-out 0s;
  7460. pointer-events: none;
  7461. word-break: break-all;
  7462. }
  7463. .pagetual_tipsWords>a {
  7464. color: #ffffff;
  7465. }
  7466. .pagetual_loading {
  7467. width: 50px;
  7468. height: 50px;
  7469. margin: 10px auto;
  7470. border-radius: 100%;
  7471. display: flex;
  7472. -webkit-animation: pagetual_loading_scaleout 1.0s infinite ease-in-out;
  7473. animation: pagetual_loading_scaleout 1.0s infinite ease-in-out;
  7474. }
  7475. @-webkit-keyframes pagetual_loading_scaleout {
  7476. 0% { -webkit-transform: scale(0.0) }
  7477. 100% {
  7478. -webkit-transform: scale(1.0);
  7479. opacity: 0;
  7480. }
  7481. }
  7482. @keyframes pagetual_loading_scaleout {
  7483. 0% {
  7484. transform: scale(0.0);
  7485. -webkit-transform: scale(0.0);
  7486. } 100% {
  7487. transform: scale(1.0);
  7488. -webkit-transform: scale(1.0);
  7489. opacity: 0;
  7490. }
  7491. }
  7492. .pagetual_loading_text {
  7493. white-space: nowrap;
  7494. -webkit-animation: pagetual_loading_opacity 2.6s infinite ease-in-out;
  7495. animation: pagetual_loading_opacity 2.6s infinite ease-in-out;
  7496. }
  7497. @-webkit-keyframes pagetual_loading_opacity {
  7498. 0% { opacity: 1 }
  7499. 50% { opacity: 0.2 }
  7500. 100% { opacity: 1 }
  7501. }
  7502. @keyframes pagetual_loading_opacity {
  7503. 0% { opacity: 1 }
  7504. 50% { opacity: 0.2 }
  7505. 100% { opacity: 1 }
  7506. }
  7507. `;
  7508. 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%);"}`;
  7509. }
  7510. if (!mainStyleEle || !mainStyleEle.parentNode) {
  7511. mainStyleEle = _GM_addStyle(mainStyleStyle);
  7512. }
  7513. }
  7514. var loadingDiv = document.createElement("div");
  7515. 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;";
  7516.  
  7517. 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;`;
  7518. function setLoadingDiv(loadingText) {
  7519. 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>`}`);
  7520. }
  7521.  
  7522. 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>`;
  7523. 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;`;
  7524. 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>`;
  7525. 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);`;
  7526.  
  7527. 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;`;
  7528. 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;`;
  7529. var sideControllerIcon = '';
  7530.  
  7531. var tipsWords = document.createElement("div");
  7532. tipsWords.className = "pagetual_tipsWords";
  7533.  
  7534. function changeStop(stop, save) {
  7535. isPause = stop;
  7536. [].forEach.call(getBody(document).querySelectorAll(".pagetual_pageBar,#pagetual-sideController"), bar => {
  7537. if (isPause) {
  7538. bar.classList.add("stop");
  7539. } else {
  7540. bar.classList.remove("stop");
  7541. }
  7542. });
  7543. if (!isPause) ruleParser.showAddedElements();
  7544. manualPause = isPause;
  7545. if (save && sideController.inited) setListData("pauseState", location.host, isPause ? true : "");
  7546. }
  7547.  
  7548. function changeHideBar(hide) {
  7549. isHideBar = hide;
  7550. [].forEach.call(getBody(document).querySelectorAll(".pagetual_pageBar"), bar => {
  7551. if (isHideBar) {
  7552. bar.classList.add("hide");
  7553. } else {
  7554. bar.classList.remove("hide");
  7555. }
  7556. });
  7557. }
  7558.  
  7559. function isInViewPort(element) {
  7560. const viewWidth = window.innerWidth || document.documentElement.clientWidth;
  7561. const viewHeight = window.innerHeight || document.documentElement.clientHeight;
  7562. const {
  7563. top,
  7564. right,
  7565. bottom,
  7566. left,
  7567. } = element.getBoundingClientRect();
  7568.  
  7569. return (
  7570. top >= 0 &&
  7571. left >= 0 &&
  7572. right <= viewWidth + 1 &&
  7573. top <= viewHeight * rate &&
  7574. isVisible(element, _unsafeWindow)
  7575. );
  7576. }
  7577.  
  7578. function getPageBar() {
  7579. let preBar = null, nextBar = null;
  7580. let pageBars = [].slice.call(document.querySelectorAll(".pagetual_pageBar"));
  7581. for (let i = 0; i < pageBars.length; i++) {
  7582. let pageBar = pageBars[i];
  7583. if (!pageBar || !getBody(document).contains(pageBar)) continue;
  7584. let {
  7585. top,
  7586. right,
  7587. bottom,
  7588. left,
  7589. } = pageBar.getBoundingClientRect();
  7590. if (top > 500) {
  7591. nextBar = pageBar;
  7592. preBar = (i - 1 >= 0 ? pageBars[i - 1] : null);
  7593. if (pageBar && getBody(document).contains(pageBar)) {
  7594. let {
  7595. top,
  7596. right,
  7597. bottom,
  7598. left,
  7599. } = pageBar.getBoundingClientRect();
  7600. if (top < -500) {
  7601. preBar = pageBar;
  7602. } else preBar = (i - 2 >= 0 ? pageBars[i - 2] : null);
  7603. }
  7604. break;
  7605. }
  7606. }
  7607. if (!nextBar) preBar = pageBars[pageBars.length - 2];
  7608. return {preBar: preBar, nextBar: nextBar};
  7609. }
  7610.  
  7611. var urlChanged = false;
  7612. var urlChanging = false;
  7613. var urlchangeHandler = e => {
  7614. if (ruleParser && ruleParser.curSiteRule && ruleParser.curSiteRule.listenUrlChange == false) return;
  7615. isPause = true;
  7616. setTimeout(() => {
  7617. lastActiveUrl = location.href;
  7618. if (urlChanging) return;
  7619. urlChanging = true;
  7620. let href = location.href.slice(0, 60);
  7621. if (href == configPage[1]) {
  7622. setTimeout(() => {
  7623. initConfig(href);
  7624. urlChanging = false;
  7625. }, 1000);
  7626. } else {
  7627. setTimeout(() => {
  7628. if (guidePage.test(href)) {
  7629. setTimeout(() => {
  7630. initConfig(href);
  7631. urlChanging = false;
  7632. }, 1000);
  7633. } else {
  7634. ruleParser.urlChanged();
  7635. if (!ruleParser.nextLinkHref) {
  7636. isLoading = false;
  7637. }
  7638. urlChanging = false;
  7639. //if (!pageReady && !ruleImportUrlReg.test(href)) location.reload();
  7640. }
  7641. }, 500);
  7642. }
  7643. }, 1);
  7644. };
  7645. window.addEventListener('pagetual_pushState', urlchangeHandler);
  7646. /*var _wr = function(type) {
  7647. var orig = history[type];
  7648. return function() {
  7649. var rv = orig.apply(this, arguments);
  7650. var e = new Event('pagetual_' + type);
  7651. e.arguments = arguments;
  7652. window.dispatchEvent(e);
  7653. return rv;
  7654. };
  7655. };
  7656. history.pushState = _wr('pushState');*/
  7657.  
  7658. function listenUrl() {
  7659. var prevPathname = window.location.pathname;
  7660. var prevSearch = window.location.search;
  7661. var checkUrlTime = 100;
  7662. var checkUrlTimer;
  7663. var checkClickedEle = null;
  7664. var clickedSth = false;
  7665. var checkFunc = () => {
  7666. if (forceState == 1) return;
  7667. if (checkClickedEle) {
  7668. if (!clickedSth && checkClickedEle && checkClickedEle.nodeName) {
  7669. if (compareNodeName(checkClickedEle, ["a", "button"])) {
  7670. clickedSth = true;
  7671. } else {
  7672. let targetStyle = _unsafeWindow.getComputedStyle(checkClickedEle);
  7673. if (targetStyle.cursor == "pointer") clickedSth = true;
  7674. }
  7675. }
  7676. checkClickedEle = null;
  7677. }
  7678. if (checkUrlTime < 5000) {
  7679. checkUrlTime += checkUrlTime>>1;
  7680. }
  7681. clearTimeout(checkUrlTimer);
  7682. checkUrlTimer = setTimeout(checkFunc, checkUrlTime);
  7683. if (document.hidden) return;
  7684. if (clickedSth) {
  7685. ruleParser.checkClickHref();
  7686. clickedSth = false;
  7687. } else if (!ruleParser.canListenUrlChange()) {
  7688. return;
  7689. }
  7690. if ((prevPathname !== window.location.pathname || prevSearch !== window.location.search) && window.location.href != ruleParser.historyUrl) {
  7691. checkUrlTime = 2000;
  7692. urlWillChange = true;
  7693. var e = new Event('pagetual_pushState');
  7694. e.arguments = arguments;
  7695. window.dispatchEvent(e);
  7696. clickedSth = false;
  7697. }
  7698. prevPathname = window.location.pathname;
  7699. prevSearch = window.location.search;
  7700. };
  7701. checkUrlTimer = setTimeout(checkFunc, checkUrlTime);
  7702.  
  7703. document.addEventListener("click", e => {
  7704. if (!checkClickedEle) {
  7705. checkClickedEle = e.target;
  7706. checkUrlTime = 300;
  7707. clearTimeout(checkUrlTimer);
  7708. checkUrlTimer = setTimeout(checkFunc, checkUrlTime);
  7709. }
  7710. });
  7711. }
  7712.  
  7713. let scrollContainer;
  7714. function distToBottom () {
  7715. let scrolly = window.scrollY;
  7716. let windowHeight = window.innerHeight || document.documentElement.clientHeight;
  7717. if (!scrollContainer || !document.documentElement.contains(scrollContainer)) {
  7718. if (curPage > 1 || ruleParser.nextLinkHref) {
  7719. let pageEle = ruleParser.getPageElement(document);
  7720. if (pageEle && pageEle.length) {
  7721. let parent = pageEle[0].parentNode, pageScrollY = parent.scrollTop;
  7722. while (parent && pageScrollY == 0) {
  7723. parent = parent.parentNode;
  7724. pageScrollY = parent.scrollTop;
  7725. }
  7726. if (pageScrollY) {
  7727. scrollContainer = parent;
  7728. return scrollContainer.scrollHeight - pageScrollY - windowHeight;
  7729. }
  7730. }
  7731. }
  7732. }
  7733. if (scrollContainer) {
  7734. return scrollContainer.scrollHeight - scrollContainer.scrollTop - windowHeight;
  7735. }
  7736.  
  7737. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  7738. return scrollH - scrolly - windowHeight;
  7739. }
  7740.  
  7741. let scrollHandler, clickToResetHandler, dblclickHandler, keydownHandler, hashchangeHandler, manualModeKeyHandler, pagetualNextHandler, keyupHandler, messageHandler;
  7742. function initListener () {
  7743. document.removeEventListener('scroll', scrollHandler, true);
  7744. document.removeEventListener('wheel', scrollHandler, true);
  7745. document.removeEventListener('dblclick', dblclickHandler);
  7746. document.removeEventListener('keydown', keydownHandler);
  7747. window.removeEventListener('hashchange', hashchangeHandler, false);
  7748. document.removeEventListener('keydown', manualModeKeyHandler);
  7749. document.removeEventListener('pagetual.next', pagetualNextHandler, false);
  7750. document.removeEventListener('keyup', keyupHandler);
  7751. _unsafeWindow.removeEventListener('message', messageHandler, true);
  7752. let loadmoreBtn, loadingMore = true, lastScroll = 0, checkLoadMoreTimes = 0, loadMoreInv;
  7753. if (ruleParser.curSiteRule.smart) {
  7754. loadingMore = false;
  7755. } else if (ruleParser.curSiteRule.loadMore) {
  7756. loadingMore = false;
  7757. }
  7758. clickMode = typeof ruleParser.curSiteRule.clickMode == 'undefined' ? rulesData.clickMode : ruleParser.curSiteRule.clickMode;
  7759. let clickingNext = false;
  7760. let clickNext = async () => {
  7761. if (clickingNext) return;
  7762. clickingNext = true;
  7763. setTimeout(() => {
  7764. clickingNext = false;
  7765. }, 1500);
  7766. let nextLink = ruleParser.nextLinkHref;
  7767. if (!nextLink) return;
  7768. let isJs = ruleParser.hrefIsJs(nextLink);
  7769. if (isJs) {
  7770. let nextBtn = ruleParser.nextLinkEle;
  7771. if (!nextBtn || !nextBtn.offsetParent) nextBtn = await ruleParser.getNextLink(document, true);
  7772. if (nextBtn) emuClick(nextBtn);
  7773. } else {
  7774. window.location.href = nextLink;
  7775. }
  7776. };
  7777. let checkScrollReach = () => {
  7778. let dist = distToBottom();
  7779. if (clickMode) {
  7780. if (dist < 10) {
  7781. clickNext();
  7782. }
  7783. } else if (dist < bottomGap) {
  7784. nextPage();
  7785. }
  7786. };
  7787. messageHandler = e => {
  7788. if (e.data.command === 'pagetual') {
  7789. let action = e.data.action;
  7790. let detail = e.data.detail;
  7791. switch (action) {
  7792. case "config":
  7793. if (!detail || typeof detail !== 'object') return;
  7794. rulesData = {
  7795. ...rulesData,
  7796. ...detail
  7797. }
  7798. storage.setItem("rulesData", rulesData);
  7799. break;
  7800. case "nextPage":
  7801. if (detail === "" || detail === null) return;
  7802. detail = parseInt(detail) || 0;
  7803. if (loadNowNum != detail) {
  7804. loadNowNum = detail;
  7805. }
  7806. autoLoadNum = detail;
  7807. nextPage();
  7808. break;
  7809. case "loadMore":
  7810. clearInterval(loadMoreInv);
  7811. if (detail === -1) return;
  7812. loadmoreBtn = getLoadMore(document, loadmoreBtn);
  7813. loadmoreBtn && emuClick(loadmoreBtn);
  7814. if (detail === 0) {
  7815. loadMoreInv = setInterval(() => {
  7816. loadmoreBtn = getLoadMore(document, loadmoreBtn);
  7817. loadmoreBtn && emuClick(loadmoreBtn);
  7818. }, 500);
  7819. }
  7820. break;
  7821. }
  7822. }
  7823. return true;
  7824. }
  7825. _unsafeWindow.addEventListener('message', messageHandler, true);
  7826. scrollHandler = e => {
  7827. if (urlChanged && !isLoading) {
  7828. ruleParser.initPage(() => {});
  7829. urlChanged = false;
  7830. loadingMore = false;
  7831. return;
  7832. }
  7833. if (isPause) return;
  7834. if (!loadingMore) {
  7835. loadmoreBtn = getLoadMore(document, loadmoreBtn);
  7836. if (loadmoreBtn) {
  7837. if (isInViewPort(loadmoreBtn)) {
  7838. emuClick(loadmoreBtn);
  7839. loadingMore = true;
  7840. setTimeout(() => {loadingMore = false}, 200);
  7841. }
  7842. } else {
  7843. loadingMore = true;
  7844. if (!ruleParser.curSiteRule.smart || checkLoadMoreTimes++ < 3) {
  7845. setTimeout(() => {loadingMore = false}, 200);
  7846. }
  7847. }
  7848. }
  7849. if (!isLoading && !stopScroll) {
  7850. checkScrollReach();
  7851. }
  7852. ruleParser.changeVisibility();
  7853. let curScroll = getBody(document).scrollTop || document.documentElement.scrollTop;
  7854. if (ruleParser.curSiteRule.lockScroll) {
  7855. if (isLoading && Math.abs(lastScroll - curScroll) > 350) {
  7856. getBody(document).scrollTop = lastScroll;
  7857. document.documentElement.scrollTop = lastScroll;
  7858. } else {
  7859. lastScroll = curScroll;
  7860. }
  7861. }
  7862. if (targetY >= 0) {
  7863. if (Math.abs(targetY - curScroll) < 100) {
  7864. targetY = -1;
  7865. }
  7866. }
  7867. if (curScroll <= 20 && curScroll > 0) {
  7868. if (sideController.inited) {
  7869. sideController.pagenum.innerHTML = createHTML("1");
  7870. }
  7871. }
  7872. };
  7873. dblclickHandler = e => {
  7874. if (forceState == 1 || compareNodeName(e.target, ["input", "textarea", "select", "a", "button", "svg", "use", "img", "path"])) return;
  7875. if (!rulesData.dbClick2StopKey) {
  7876. if ((rulesData.dbClick2StopCtrl && !e.ctrlKey) ||
  7877. (rulesData.dbClick2StopAlt && !e.altKey) ||
  7878. (rulesData.dbClick2StopShift && !e.shiftKey) ||
  7879. (rulesData.dbClick2StopMeta && !e.metaKey)) {
  7880. return;
  7881. }
  7882. }
  7883. if (!compareNodeName(e.target, ["body"]) && !e.target.classList.contains('pagetual_pageBar')) {
  7884. try {
  7885. let selection = window.getSelection();
  7886. let selStr = selection.toString().trim();
  7887. if (!selStr) {
  7888. selection = selection.getRangeAt(0);
  7889. selStr = selection && selection.cloneContents().children[0];
  7890. if (selStr && !compareNodeName(selStr, ["img"])) selStr = false;
  7891. }
  7892. if (selStr) {
  7893. return;
  7894. }
  7895. } catch (e) {}
  7896. }
  7897. if (rulesData.dbClick2Stop && (ruleParser.nextLinkHref || loadmoreBtn)) {
  7898. setTimeout(() => {
  7899. if (rulesData.hideBarButNoStop || rulesData.hideBar) {
  7900. changeHideBar(!isHideBar);
  7901. }
  7902. if (!rulesData.hideBarButNoStop) {
  7903. changeStop(!isPause);
  7904. showTips(i18n(isPause ? "disable" : "enable"));
  7905. }
  7906. if (!isPause) {
  7907. checkScrollReach();
  7908. }
  7909. }, 10);
  7910. }
  7911. };
  7912. document.addEventListener('dblclick', dblclickHandler);
  7913. clickToResetHandler = e => {
  7914. if (!ruleParser.nextLinkHref) isLoading = false;
  7915. };
  7916. document.addEventListener('click', clickToResetHandler);
  7917. if (rulesData.dbClick2StopKey) {
  7918. keydownHandler = e => {
  7919. if ((rulesData.dbClick2StopCtrl && !e.ctrlKey) ||
  7920. (rulesData.dbClick2StopAlt && !e.altKey) ||
  7921. (rulesData.dbClick2StopShift && !e.shiftKey) ||
  7922. (rulesData.dbClick2StopMeta && !e.metaKey)) {
  7923. return;
  7924. }
  7925. if (document.activeElement &&
  7926. (compareNodeName(document.activeElement, ["input", "textarea"]) ||
  7927. document.activeElement.contentEditable == 'true')) {
  7928. return;
  7929. }
  7930. var key = e.key.toLowerCase();
  7931. if (rulesData.dbClick2StopKey.toLowerCase() == key) {
  7932. if (forceState == 1) {
  7933. forceState = 0;
  7934. showTips(i18n("enableSiteTips"));
  7935. changeStop(false, true);
  7936. } else {
  7937. forceState = 1;
  7938. showTips(i18n("disableSiteTips"));
  7939. changeStop(true, true);
  7940. sideController.remove();
  7941. }
  7942. if (!ruleParser.curSiteRule.url) {
  7943. setListData("forceState", location.host, forceState);
  7944. setTimeout(() => {
  7945. location.reload();
  7946. }, 500);
  7947. }
  7948. }
  7949. };
  7950. document.addEventListener('keydown', keydownHandler);
  7951. }
  7952. if (ruleParser.curSiteRule.listenHashChange) {
  7953. hashchangeHandler = () => {
  7954. isPause = true;
  7955. ruleParser.urlChanged();
  7956. if (!ruleParser.nextLinkHref) isLoading = false;
  7957. };
  7958. window.addEventListener('hashchange', hashchangeHandler, false);
  7959. }
  7960. let manualMode = typeof ruleParser.curSiteRule.manualMode == 'undefined' ? rulesData.manualMode : ruleParser.curSiteRule.manualMode;
  7961. if (manualMode) {
  7962. manualModeKeyHandler = e => {
  7963. if (document.activeElement &&
  7964. (compareNodeName(document.activeElement, ["input", "textarea"]) ||
  7965. document.activeElement.contentEditable == 'true')) {
  7966. return;
  7967. }
  7968. if (e.keyCode == 39) {
  7969. clickNext();
  7970. } else if (e.keyCode == 37) {
  7971. history.back();
  7972. }
  7973. };
  7974. document.addEventListener('keydown', manualModeKeyHandler);
  7975. pagetualNextHandler = () => {
  7976. clickNext();
  7977. };
  7978. document.addEventListener('pagetual.next', pagetualNextHandler, false);
  7979. return;
  7980. }
  7981. if (rulesData.arrowToScroll) {
  7982. keyupHandler = e => {
  7983. if (document.activeElement &&
  7984. (compareNodeName(document.activeElement, ["input", "textarea"]) ||
  7985. document.activeElement.contentEditable == 'true')) {
  7986. return;
  7987. }
  7988. if (e.keyCode == 39) {
  7989. let nextPageBar=getPageBar().nextBar;
  7990. if (nextPageBar) {
  7991. scrollToPageBar(nextPageBar);
  7992. } else {
  7993. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  7994. window.scrollTo({ top: scrollTop + (window.innerHeight || document.documentElement.clientHeight), behavior: 'instant'});
  7995. }
  7996. } else if (e.keyCode == 37) {
  7997. let prePageBar = getPageBar().preBar;
  7998. if (prePageBar) {
  7999. scrollToPageBar(prePageBar);
  8000. } else {
  8001. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  8002. window.scrollTo({ top: scrollTop - (window.innerHeight || document.documentElement.clientHeight), behavior: 'instant'});
  8003. }
  8004. }
  8005. };
  8006. document.addEventListener('keyup', keyupHandler);
  8007. }
  8008. if (!ruleParser.curSiteRule.wheel) {
  8009. document.addEventListener('scroll', scrollHandler, true);
  8010. }
  8011. document.addEventListener('wheel', scrollHandler, true);
  8012. }
  8013.  
  8014. let hideTipsTimeout;
  8015. function showTips(content, href, time, wordColor, backColor) {
  8016. initView();
  8017. document.documentElement.appendChild(tipsWords);
  8018. tipsWords.style.color = wordColor || 0xFFFFFF;
  8019. tipsWords.style.backgroundColor = backColor || 0x000;
  8020. let _time = 1500;
  8021. if (href) {
  8022. _time = 3500;
  8023. tipsWords.innerHTML = createHTML(`<a href='${href}' target='_blank'>${content}</a>`);
  8024. tipsWords.style.pointerEvents = 'all';
  8025. } else {
  8026. tipsWords.innerHTML = createHTML(content);
  8027. }
  8028. tipsWords.style.marginLeft = -tipsWords.offsetWidth / 2 + "px";
  8029. setTimeout(() => {
  8030. tipsWords.style.marginLeft = -tipsWords.offsetWidth / 2 + "px";
  8031. }, 0);
  8032. setTimeout(() => {
  8033. tipsWords.style.opacity = 0.8;
  8034. clearTimeout(hideTipsTimeout);
  8035. hideTipsTimeout = setTimeout(() => {
  8036. tipsWords.style.opacity = 0;
  8037. tipsWords.style.pointerEvents = '';
  8038. }, time || _time);
  8039. }, 1);
  8040. }
  8041.  
  8042. const loadmoreReg = /^\s*((点击)?加载更多|(點擊)?加載更多|load\s*more( comments)?|もっと読み込む)[\.…▼\s]*$/i;
  8043. 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";
  8044. function getLoadMore(doc, loadmoreBtn) {
  8045. if (!loadmoreBtn || !getBody(doc).contains(loadmoreBtn) || /less/.test(loadmoreBtn.innerText)) loadmoreBtn = null;
  8046. if (!ruleParser.curSiteRule.smart && !ruleParser.curSiteRule.loadMore) return null;
  8047. if (loadmoreBtn) return loadmoreBtn;
  8048. let btnSel = ruleParser.curSiteRule.loadMore || defaultLoadmoreSel;
  8049. if (btnSel) {
  8050. loadmoreBtn = getElement(btnSel, doc, null, true);
  8051. }
  8052. if (!loadmoreBtn) {
  8053. let buttons = getBody(doc).querySelectorAll("input,button,a,div[onclick]");
  8054. for (let i = 0; i < buttons.length; i++) {
  8055. let button = buttons[i];
  8056. if (!button.innerText || button.innerText.length > 20) continue;
  8057. if (button && loadmoreReg.test(button.innerText)) {
  8058. loadmoreBtn = button;
  8059. break;
  8060. }
  8061. }
  8062. }
  8063. if (loadmoreBtn && !ruleParser.curSiteRule.loadMore && loadmoreBtn.dataset.ajax !== "true") {
  8064. let href = loadmoreBtn.getAttribute("href");
  8065. if (href && href != "/" && !ruleParser.hrefIsJs(href)) {
  8066. loadmoreBtn = null;
  8067. }
  8068. }
  8069. if (loadmoreBtn && /less/.test(loadmoreBtn.innerText)) loadmoreBtn = null;
  8070. if (loadmoreBtn) debug(loadmoreBtn, 'Load more button');
  8071. return loadmoreBtn;
  8072. }
  8073.  
  8074. var targetY = -1;
  8075. function scrollToPageBar(bar) {
  8076. if (window.pageYOffset == 0) {
  8077. bar.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" });
  8078. } else {
  8079. let yOffset = -20;
  8080. if (typeof ruleParser.curSiteRule.pageBarTop !== 'undefined') {
  8081. yOffset = -ruleParser.curSiteRule.pageBarTop;
  8082. }
  8083. targetY = bar.getBoundingClientRect().top + window.pageYOffset + yOffset;
  8084. window.scrollTo({ top: targetY, behavior: 'smooth'});
  8085. }
  8086. }
  8087.  
  8088. const pageNumReg=/[&\/\?](p=|page[=\/_-]?)\d+|[_-]\d+\./;
  8089. function createPageBar(url) {
  8090. curPage++;
  8091. sideController.setup();
  8092. let posEle = null;
  8093. let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  8094. let insert = ruleParser.getInsert();
  8095. if (!insert || !insert.parentNode) return;
  8096. if (forceState == 2) {
  8097. posEle = getBody(document);
  8098. posEle = posEle.children[posEle.children.length - 1];
  8099. } else {
  8100. posEle = insert;
  8101. }
  8102. while (posEle && !posEle.offsetParent) {
  8103. posEle = posEle.previousElementSibling || posEle.parentNode;
  8104. }
  8105. if (posEle) {
  8106. let actualBottom = getElementBottom(posEle);
  8107. bottomGap = scrollH - actualBottom + (window.innerHeight || document.documentElement.clientHeight) * rate;
  8108. if (bottomGap < 100) bottomGap = 100;
  8109. } else {
  8110. bottomGap = 1000;
  8111. }
  8112. if (hidePageBar) return null;
  8113. url = url.replace(/#p{.*/, "");
  8114. let example = (ruleParser.curSiteRule.insertPos == 2 || ruleParser.curSiteRule.insertPos == "in") ? insert.children[0] : (insert.parentNode.children[0] || insert);
  8115. while (example && (compareNodeName(example, ["script", "style"]) || example.className == "pagetual_pageBar")) {
  8116. example = example.nextElementSibling;
  8117. }
  8118. if (!example || !example.parentNode) example = insert;
  8119. if (example.nodeType != 1) {
  8120. example = example.previousElementSibling || example.parentNode;
  8121. if (!example || example.nodeType != 1) return;
  8122. }
  8123. let exampleStyle = _unsafeWindow.getComputedStyle(example);
  8124. let inTable, inLi;
  8125. if (forceState == 2) {
  8126. inTable = inLi = false;
  8127. } else {
  8128. inTable = compareNodeName(example.parentNode, ["table", "tbody"]) ||
  8129. compareNodeName(example, ["tr", "tbody"]) ||
  8130. exampleStyle.display == "table-row" ||
  8131. (example.nextElementSibling && compareNodeName(example.nextElementSibling, ["tr", "tbody"]));
  8132. inLi = compareNodeName(example, ["li"]) || (example.nextElementSibling && compareNodeName(example.nextElementSibling, ["li"]));
  8133. }
  8134. let pageBar = document.createElement(inTable ? "tr" : (inLi ? "li" : "div"));
  8135. let upSpan = document.createElement("span");
  8136. let downSpan = document.createElement("span");
  8137. let pageText = document.createElement("a");
  8138. let pageNum;
  8139. pageBar.className = isHideBar ? "pagetual_pageBar hide" : "pagetual_pageBar";
  8140. pageBar.id = "pagetual_pageBar" + curPage;
  8141. pageBar.setAttribute("translate", "no");
  8142. if (isPause) {
  8143. pageBar.classList.add("stop");
  8144. }
  8145. pageBar.style.cssText = pageBarStyle;
  8146. pageBar.title = i18n(isPause ? "enable" : "disable");
  8147. upSpan.innerHTML = createHTML(upSvg);
  8148. upSpan.children[0].style.cssText = upSvgCSS;
  8149. upSpan.title = i18n("toTop");
  8150. downSpan.innerHTML = createHTML(downSvg);
  8151. downSpan.children[0].style.cssText = downSvgCSS;
  8152. downSpan.title = i18n("toBottom");
  8153. upSpan.style.cssText = initStyle;
  8154. downSpan.style.cssText = initStyle;
  8155. pageText.href = url;
  8156. pageText.style.cssText = pageTextStyle;
  8157. pageText.title = i18n("current");
  8158. if (openInNewTab == 1) pageText.target = "_blank";
  8159. pageBar.appendChild(upSpan);
  8160. pageBar.appendChild(pageText);
  8161. let touched = false;
  8162. let touchBodyHandler = e => {
  8163. touched = false;
  8164. getBody(document).removeEventListener('touchstart', touchBodyHandler, { passive: false, capture: false });
  8165. };
  8166. pageText.addEventListener("touchstart", e => {
  8167. if (touched) return;
  8168. touched = true;
  8169. pageText.style.pointerEvents = 'none';
  8170. setTimeout(() => {
  8171. pageText.style.pointerEvents = 'all';
  8172. }, 250);
  8173. getBody(document).addEventListener("touchstart", touchBodyHandler, { passive: false, capture: false });
  8174. }, { passive: false, capture: false });
  8175. if (ruleParser.nextTitle) {
  8176. pageText.innerHTML = createHTML(ruleParser.nextTitle + " ");
  8177. pageText.title = ruleParser.nextTitle;
  8178. }
  8179. if (ruleParser.curSiteRule.pageNum || pageNumReg.test(url)) {
  8180. pageText.innerHTML = createHTML(pageText.innerHTML + i18n("page"));
  8181. pageNum = document.createElement("span");
  8182. let num = ruleParser.getPageNumFromUrl(url, curPage);
  8183. pageNum.innerHTML = createHTML(num + "<i style='font-size: 0;'>&nbsp;</i>");
  8184. pageNum.className = "pagetual_pageNum";
  8185. pageNum.title = i18n("inputPageNum");
  8186. pageNum.style.cssText = pageTextStyle;
  8187. pageNum.style.cursor = "pointer";
  8188. pageNum.style.color = "";
  8189. pageNum.style.marginLeft = "5px";
  8190. pageNum.addEventListener("click", e => {
  8191. let pageInput = prompt(i18n("inputPageNum"), num || "1");
  8192. if (pageInput) {
  8193. let localPageBar = document.querySelector("#pagetual_pageBar" + pageInput);
  8194. if (localPageBar) {
  8195. scrollToPageBar(localPageBar);
  8196. } else {
  8197. let pageLink = ruleParser.getLinkByPage(url, pageInput);
  8198. if (pageLink) {
  8199. _GM_openInTab(pageLink, {active:true});
  8200. }
  8201. }
  8202. }
  8203. e.preventDefault();
  8204. e.stopPropagation();
  8205. });
  8206. pageBar.appendChild(pageNum);
  8207. } else {
  8208. pageText.innerHTML = createHTML(pageText.innerHTML + i18n("page") + curPage + "<i style='font-size: 0;'>&nbsp;</i>");
  8209. }
  8210. let preBtn = document.createElement("span");
  8211. preBtn.innerHTML = createHTML("∧");
  8212. preBtn.title = i18n("prevPage");
  8213. preBtn.className = "prevScreen";
  8214. 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; ";
  8215. let nextBtn = document.createElement("span");
  8216. nextBtn.innerHTML = createHTML("∨");
  8217. nextBtn.title = i18n("nextPage");
  8218. nextBtn.className = "nextScreen";
  8219. 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; ";
  8220. let localPage = curPage;
  8221. preBtn.addEventListener("click", e => {
  8222. e.stopPropagation();
  8223. e.preventDefault();
  8224. let prePageBar = document.querySelector("#pagetual_pageBar" + (localPage - 1));
  8225. if (prePageBar) {
  8226. scrollToPageBar(prePageBar);
  8227. } else {
  8228. let scrollTop = getBody(document).scrollTop || document.documentElement.scrollTop;
  8229. targetY = scrollTop - (window.innerHeight || document.documentElement.clientHeight);
  8230. window.scrollTo({ top: targetY, behavior: 'smooth'});
  8231. }
  8232. });
  8233. nextBtn.addEventListener("click", e => {
  8234. e.stopPropagation();
  8235. e.preventDefault();
  8236. let nextPageBar = document.querySelector("#pagetual_pageBar" + (localPage + 1));
  8237. if (nextPageBar) {
  8238. scrollToPageBar(nextPageBar);
  8239. } else {
  8240. scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  8241. targetY = scrollH || 9999999;
  8242. window.scrollTo({ top: targetY, behavior: 'smooth'});
  8243. }
  8244. });
  8245. if (!rulesData.hideBarArrow) {
  8246. pageText.insertBefore(preBtn, pageText.firstChild);
  8247. pageText.insertBefore(nextBtn, pageText.firstChild);
  8248. }
  8249. if (curForceIframe) {
  8250. let bgRing = document.createElement("span");
  8251. bgRing.className = "refreshRing";
  8252. bgRing.style.display = "none";
  8253. bgRing.innerHTML = createHTML(upSvg);
  8254. pageText.title = "Refresh";
  8255. pageText.appendChild(bgRing);
  8256. pageText.addEventListener("click", e => {
  8257. e.stopPropagation();
  8258. if (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) return;
  8259. e.preventDefault();
  8260. let nextEle = pageBar && pageBar.nextElementSibling;
  8261. if (nextEle && nextEle.name == 'pagetual-iframe') {
  8262. if (curForceIframe == nextEle) {
  8263. nextEle.setAttribute("loaded", "refresh");
  8264. }
  8265. nextEle.src = nextEle.src;
  8266. }
  8267. });
  8268. } else if (rulesData.pageBarMenu) {
  8269. pageText.addEventListener("click", e => {
  8270. e.stopPropagation();
  8271. if (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) return;
  8272. e.preventDefault();
  8273. picker.start();
  8274. });
  8275. }
  8276. pageBar.appendChild(downSpan);
  8277. if (forceState == 2) {
  8278. pageBar.style.width = "99%";
  8279. } else {
  8280. let parentStyle = _unsafeWindow.getComputedStyle(example.parentNode);
  8281. let parentWidth = example.parentNode.offsetWidth || parseInt(parentStyle.width);
  8282. pageBar.style.width = parentWidth - parseInt(parentStyle.paddingLeft) - parseInt(parentStyle.paddingRight) - 10 + "px";
  8283. pageBar.style.margin = '10px 5px';
  8284. if (parentStyle.display == "grid" || parentStyle.display == "inline-grid") {
  8285. pageBar.style.gridColumn = "1/-1";
  8286. }
  8287. if (inTable) {
  8288. example = compareNodeName(example, ["tr", "tbody"]) ? example : example.nextElementSibling || example;
  8289. if (compareNodeName(example, ["tbody"])) example = example.querySelector("tr");
  8290. let nextTr = example;
  8291. while (nextTr && nextTr.children.length == 0) nextTr = nextTr.nextElementSibling;
  8292. if (nextTr) example = nextTr;
  8293. let tdNum = 0;
  8294. if (exampleStyle.display == "table-row") {
  8295. [].forEach.call(example.children, el => {
  8296. tdNum += el.colSpan || 1;
  8297. });
  8298. } else {
  8299. [].forEach.call(example.children, el => {
  8300. if (compareNodeName(el, ["td", "th"])) {
  8301. tdNum += el.colSpan || 1;
  8302. }
  8303. });
  8304. }
  8305. pageBar.style.cssText = "";
  8306. pageBar.style.display = "table-row";
  8307. pageBar.style.backgroundColor = "unset";
  8308. pageBar.style.lineHeight = "20px";
  8309. pageBar.style.boxShadow = "";
  8310. let td = document.createElement("td");
  8311. td.colSpan = tdNum || 1;
  8312. let inTd = document.createElement("div");
  8313. inTd.style.cssText = pageBarStyle;
  8314. inTd.style.display = "";
  8315. inTd.className = pageBar.className;
  8316. pageBar.className = "";
  8317. inTd.appendChild(upSpan);
  8318. inTd.appendChild(pageText);
  8319. if (pageNum) inTd.appendChild(pageNum);
  8320. inTd.appendChild(downSpan);
  8321. td.appendChild(inTd);
  8322. pageBar.appendChild(td);
  8323. } else if (inLi) {
  8324. example = compareNodeName(example, ["li"]) ? example : example.nextElementSibling || example;
  8325. pageBar.style.opacity = 1;
  8326. pageBar.style.display = getComputedStyle(example).display;
  8327. pageBar.style.backgroundColor = "unset";
  8328. pageBar.style.lineHeight = "20px";
  8329. pageBar.style.boxShadow = "";
  8330. pageBar.style.border = "";
  8331. pageBar.style.width = "";
  8332. pageBar.style.maxWidth = "unset";
  8333. pageBar.style.flex = "auto";
  8334. let inTd = document.createElement("div");
  8335. inTd.style.cssText = pageBarStyle;
  8336. inTd.style.display = "";
  8337. inTd.style.margin = "0"
  8338. inTd.style.padding = "0 0";
  8339. inTd.style.textAlign = "center";
  8340. inTd.style.minWidth = "150px";
  8341. inTd.style.width = 'calc(100% - 20px)';
  8342. inTd.className = pageBar.className;
  8343. pageBar.className = "";
  8344. inTd.appendChild(upSpan);
  8345. inTd.appendChild(pageText);
  8346. if (pageNum) inTd.appendChild(pageNum);
  8347. inTd.appendChild(downSpan);
  8348. if (pageBar.style.display === 'table-row') {
  8349. let td = document.createElement("td");
  8350. td.colSpan = example.children.length;
  8351. td.style.width = '100%';
  8352. td.appendChild(inTd);
  8353. pageBar.appendChild(td);
  8354. } else {
  8355. inTd.style.width = '100%';
  8356. pageBar.appendChild(inTd);
  8357. }
  8358. }
  8359. }
  8360.  
  8361. upSpan.addEventListener("click", e => {
  8362. getBody(document).scrollTop = 0;
  8363. document.documentElement.scrollTop = 0;
  8364. e.preventDefault();
  8365. e.stopPropagation();
  8366. });
  8367. downSpan.addEventListener("click", e => {
  8368. if (!e.altKey && !e.ctrlKey && !e.shiftKey && !e.metaKey) {
  8369. changeStop(true);
  8370. }
  8371. pageBar.title = i18n(isPause ? "enable" : "disable");
  8372. scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
  8373. getBody(document).scrollTop = scrollH || 9999999;
  8374. document.documentElement.scrollTop = scrollH || 9999999;
  8375. e.preventDefault();
  8376. e.stopPropagation();
  8377. });
  8378. pageBar.addEventListener("click", e => {
  8379. changeStop(!isPause, true);
  8380. pageBar.title = i18n(isPause ? "enable" : "disable");
  8381. });
  8382. ruleParser.insertElement(pageBar);
  8383. ruleParser.runPageBar(pageBar);
  8384.  
  8385. if (sideController.inited) {
  8386. try {
  8387. let observer = new IntersectionObserver(entries => {
  8388. if (entries[0].intersectionRatio > 0) {
  8389. sideController.pagenum.innerHTML = createHTML(localPage);
  8390. }
  8391. });
  8392. observer.observe(pageBar);
  8393. } catch(e) {}
  8394. }
  8395. return pageBar;
  8396. }
  8397.  
  8398. async function waitForElement(sel, doc, maxTime) {
  8399. if (!sel) return null;
  8400. return new Promise((resolve) => {
  8401. let passedTime = 0;
  8402. let checkInv = setInterval(() => {
  8403. let result = getElement(sel, doc, null, true);
  8404. if (result) {
  8405. clearInterval(checkInv);
  8406. resolve(result);
  8407. } else if (maxTime) {
  8408. passedTime += 100;
  8409. if (passedTime >= maxTime) {
  8410. clearInterval(checkInv);
  8411. resolve(result);
  8412. }
  8413. }
  8414. }, 100);
  8415. });
  8416. }
  8417.  
  8418. async function clickAction(sel, doc) {
  8419. let btn = await waitForElement(sel, doc);
  8420. emuClick(btn, doc);
  8421. }
  8422.  
  8423. async function enterAction(sel, doc) {
  8424. let btn = await waitForElement(sel, doc);
  8425. let eventParam = { key: "Enter", keyCode: 13, bubbles: true };
  8426. let event = new KeyboardEvent('keydown', eventParam);
  8427. btn.dispatchEvent(event);
  8428. event = new KeyboardEvent('keyup', eventParam);
  8429. btn.dispatchEvent(event);
  8430. event = new KeyboardEvent('keypress', eventParam);
  8431. btn.dispatchEvent(event);
  8432. }
  8433.  
  8434. async function inputAction(sel, v, doc) {
  8435. let input = await waitForElement(sel, doc);
  8436. let event = new Event('focus', { bubbles: true });
  8437. input.dispatchEvent(event);
  8438. let lastValue = input.value;
  8439. if (input.nodeName.toUpperCase() == "INPUT") {
  8440. var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
  8441. nativeInputValueSetter.call(input, v);
  8442. } else if (input.nodeName.toUpperCase() == "TEXTAREA") {
  8443. var nativeTextareaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set;
  8444. nativeTextareaValueSetter.call(input, v);
  8445. } else {
  8446. input.innerHTML = createHTML(v);
  8447. }
  8448. event = new Event('input', { bubbles: true });
  8449. let tracker = input._valueTracker;
  8450. if (tracker) {
  8451. tracker.setValue(lastValue);
  8452. }
  8453. input.dispatchEvent(event);
  8454. event = new Event('change', { bubbles: true });
  8455. input.dispatchEvent(event);
  8456. debug(input, `input ${sel}`);
  8457. }
  8458.  
  8459. function emuClick(btn, doc) {
  8460. if (!doc) doc = document;
  8461. let curScroll = getBody(doc).scrollTop || doc.documentElement.scrollTop;
  8462. let orgHref = btn.getAttribute('href');
  8463. if (orgHref && orgHref.replace(location.origin + location.pathname, "").indexOf("#") === 0) {
  8464. let hashAction = e => {
  8465. e.preventDefault();
  8466. getBody(doc).scrollTop = curScroll;
  8467. doc.documentElement.scrollTop = curScroll;
  8468. btn.removeEventListener('click', hashAction, false);
  8469. };
  8470. btn.addEventListener('click', hashAction, false);
  8471. }
  8472. if (!PointerEvent) return btn.click();
  8473. let eventParam = {
  8474. isTrusted: true,
  8475. altKey: false,
  8476. azimuthAngle: 0,
  8477. bubbles: true,
  8478. button: 0,
  8479. buttons: 0,
  8480. clientX: 1,
  8481. clientY: 1,
  8482. cancelBubble: false,
  8483. cancelable: true,
  8484. composed: true,
  8485. ctrlKey: false,
  8486. defaultPrevented: false,
  8487. detail: 1,
  8488. eventPhase: 2,
  8489. fromElement: null,
  8490. height: 1,
  8491. isPrimary: false,
  8492. metaKey: false,
  8493. pointerId: 1,
  8494. pointerType: "mouse",
  8495. pressure: 0,
  8496. relatedTarget: null,
  8497. returnValue: true,
  8498. shiftKey: false,
  8499. toElement: null,
  8500. twist: 0,
  8501. which: 1
  8502. };
  8503. let mouseEvent = new PointerEvent("mousedown", eventParam);
  8504. btn.dispatchEvent(mouseEvent);
  8505. mouseEvent = new PointerEvent("mouseup", eventParam);
  8506. btn.dispatchEvent(mouseEvent);
  8507. let dispatchTouchEvent = (ele, type) => {
  8508. let touchEvent;
  8509. try {
  8510. touchEvent = document.createEvent('TouchEvent')
  8511. touchEvent.initTouchEvent(type, true, true)
  8512. } catch (err) {
  8513. try {
  8514. touchEvent = document.createEvent('UIEvent')
  8515. touchEvent.initUIEvent(type, true, true)
  8516. } catch (err) {
  8517. touchEvent = document.createEvent('Event')
  8518. touchEvent.initEvent(type, true, true)
  8519. }
  8520. }
  8521. if (touchEvent) {
  8522. try {
  8523. touchEvent.targetTouches = [{
  8524. pageX: 1,
  8525. pageY: 1,
  8526. clientX: 1,
  8527. clientY: 1,
  8528. target: btn
  8529. }];
  8530. touchEvent.touches = [{
  8531. pageX: 1,
  8532. pageY: 1,
  8533. clientX: 1,
  8534. clientY: 1,
  8535. target: btn
  8536. }];
  8537. touchEvent.changedTouches = [{
  8538. pageX: 1,
  8539. pageY: 1,
  8540. clientX: 1,
  8541. clientY: 1,
  8542. target: btn
  8543. }];
  8544. } catch (err) {}
  8545. ele.dispatchEvent(touchEvent);
  8546. }
  8547. }
  8548. dispatchTouchEvent(btn, "touchstart");
  8549. dispatchTouchEvent(btn, "touchend");
  8550.  
  8551. btn.click();
  8552. }
  8553.  
  8554. function emuInput(input, v) {
  8555. let result = false;
  8556. if (!input) return true;
  8557. let event = new Event('focus', { bubbles: true });
  8558. input.dispatchEvent(event);
  8559. let lastValue = input.value;
  8560. if (input.type == 'file') {
  8561. let file = v;
  8562. let blob = new Blob([file], {
  8563. type: 'text/plain'
  8564. });
  8565. file = new File([blob], 'noname.txt', { type: blob.type });
  8566. let dataTransfer = new DataTransfer();
  8567. dataTransfer.items.add(file);
  8568. input.files = dataTransfer.files;
  8569. v = "c:/fakepath/fakefile";
  8570. } else if (/INPUT/i.test(input.nodeName)) {
  8571. var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
  8572. nativeInputValueSetter.call(input, v);
  8573. } else if (/SELECT/i.test(input.nodeName)) {
  8574. var nativeSelectValueSetter = Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, "value").set;
  8575. nativeSelectValueSetter.call(input, v);
  8576. } else if (input.nodeName.toUpperCase() == "TEXTAREA") {
  8577. var nativeTextareaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set;
  8578. nativeTextareaValueSetter.call(input, v);
  8579. } else {
  8580. input.innerHTML = createHTML(v);
  8581. }
  8582. event = new Event('input', { bubbles: true });
  8583. let tracker = input._valueTracker;
  8584. if (tracker) {
  8585. tracker.setValue(lastValue);
  8586. }
  8587. input.dispatchEvent(event);
  8588. event = new Event('change', { bubbles: true });
  8589. input.dispatchEvent(event);
  8590. return result;
  8591. }
  8592.  
  8593. var failFromIframe = 0;
  8594. var inCors = false;
  8595. var checkRemoveIntv;
  8596. function requestFromIframe(url, callback){
  8597. if (location.protocol === 'https:' && !/^https:/.test(url)) {
  8598. ruleParser.noValidContent(url);
  8599. }
  8600. url = url.indexOf('=') == -1 ? url.replace(/#[^#]*/,"") : url;
  8601. let iframe = document.createElement('iframe');
  8602. iframe.name = 'pagetual-iframe';
  8603. iframe.width = '100%';
  8604. iframe.height = '1000';
  8605. iframe.frameBorder = '0';
  8606. if (ruleParser.curSiteRule.sandbox != false) {
  8607. iframe.sandbox = "allow-same-origin allow-scripts allow-popups allow-forms";
  8608. }
  8609. 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;';
  8610. let waitTime = 100, checkEval;
  8611. ruleParser.runWait((_checkEval, _waitTime) => {
  8612. if (_checkEval) {
  8613. checkEval = _checkEval;
  8614. }
  8615. if (_waitTime) {
  8616. waitTime = _waitTime;
  8617. }
  8618. });
  8619. if (checkRemoveIntv) clearInterval(checkRemoveIntv);
  8620. checkRemoveIntv = setInterval(() => {
  8621. if (!iframe || !getBody(document).contains(iframe)) {
  8622. clearInterval(checkRemoveIntv);
  8623. loadPageOver();
  8624. }
  8625. }, 500);
  8626. let loadedHandler = async e => {
  8627. if (e.data != 'pagetual-iframe:DOMLoaded' && e.type != 'load') return;
  8628. clearInterval(checkRemoveIntv);
  8629. window.removeEventListener('message', loadedHandler, false);
  8630. iframe.removeEventListener('load', loadedHandler, false);
  8631. let pageEleTryTimes = 0;
  8632. async function checkIframe() {
  8633. if (urlChanged || isPause) {
  8634. return callback(false, false);
  8635. }
  8636. try {
  8637. let doc = iframe.contentDocument || iframe.contentWindow.document;
  8638. if (checkEval && !await checkEval(doc)) {
  8639. setTimeout(() => {
  8640. checkIframe();
  8641. }, waitTime);
  8642. return;
  8643. } else {
  8644. let preCode = ruleParser.curSiteRule.pagePre, eles = null;
  8645. if (preCode) {
  8646. try {
  8647. let preResult;
  8648. if (typeof preCode == 'function') {
  8649. preResult = await preCode(doc.documentElement.innerHTML, doc);
  8650. } else if (preCode.length == 2) {
  8651. preResult = doc.documentElement.innerHTML.replace(new RegExp(preCode[0], "gi"), preCode[1]);
  8652. } else {
  8653. preResult = await new AsyncFunction("response", "doc", '"use strict";' + preCode)(doc.documentElement.innerHTML, doc);
  8654. }
  8655. if (typeof preResult !== "undefined") {
  8656. if (typeof preResult === "string") {
  8657. doc.documentElement.innerHTML = preResult;
  8658. } else eles = preResult;
  8659. }
  8660. } catch(e) {
  8661. debug(e);
  8662. }
  8663. }
  8664. let base = doc.querySelector("base");
  8665. ruleParser.basePath = (base && base.href) || url;
  8666. if (eles === null) eles = ruleParser.getPageElement(doc, iframe.contentWindow, pageEleTryTimes < 25);
  8667. if (eles && eles.length > 0) {
  8668. await ruleParser.hookUrl(doc);
  8669. await callback(doc, eles);
  8670. } else if (pageEleTryTimes++ < 100) {
  8671. getBody(doc).scrollTop = 9999999;
  8672. if (doc.documentElement) {
  8673. doc.documentElement.scrollTop = 9999999;
  8674. }
  8675. setTimeout(() => {
  8676. checkIframe();
  8677. }, waitTime);
  8678. return;
  8679. } else {
  8680. if (failFromIframe++ > 2) {
  8681. failFromIframe = 0;
  8682. debug("Stop as failFromIframe");
  8683. changeStop(true);
  8684. callback(false, false);
  8685. } else {
  8686. ruleParser.noValidContent(url);
  8687. callback(false, false);
  8688. }
  8689. }
  8690. }
  8691. } catch(e) {
  8692. inCors = true;
  8693. if (forceState === 3) {
  8694. debug("Stop as cors");
  8695. isPause = true;
  8696. }
  8697. if (!ruleParser.curSiteRule.pageElement) {
  8698. ruleParser.curSiteRule.pageElement = allOfBody;
  8699. ruleParser.getInsert(true);
  8700. }
  8701. ruleParser.curSiteRule.action = 0;
  8702. ruleParser.nextLinkHref = url;
  8703. callback(false, false);
  8704. nextPage();
  8705. }
  8706. if (iframe && iframe.parentNode) iframe.parentNode.removeChild(iframe);
  8707. }
  8708. setTimeout(() => {
  8709. checkIframe();
  8710. }, waitTime);
  8711. };
  8712. let code = ruleParser.curSiteRule.iframeInit;
  8713. if (code) {
  8714. let checkReady = setInterval(() => {
  8715. let doc;
  8716. try {
  8717. doc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document);
  8718. } catch(e) {
  8719. clearInterval(checkReady);
  8720. return;
  8721. }
  8722. if (doc) {
  8723. clearInterval(checkReady);
  8724. try {
  8725. Function('win', 'iframe', '"use strict";' + code)(iframe.contentWindow, iframe);
  8726. } catch(e) {
  8727. debug(e);
  8728. }
  8729. }
  8730. }, 50);
  8731. }
  8732. window.addEventListener('message', loadedHandler, false);
  8733. iframe.addEventListener('load', loadedHandler, false);
  8734. iframe.src = url;
  8735. try {
  8736. getBody(document).appendChild(iframe);
  8737. } catch (e) {
  8738. return callback(false, false);
  8739. }
  8740. }
  8741.  
  8742. var emuIframe, lastActiveUrl, orgContent, meetCors = false;
  8743. function emuPage(callback) {
  8744. let orgPage = null, preContent = null, iframeDoc, checkTimes = 0, loadmoreBtn, pageEle, nextLink, loadmoreEnd = false, waitTimes = 80, changed = false, checkNext = 0;
  8745. let activeClass = "active";
  8746. if (typeof ruleParser.curSiteRule.activeClass !== 'undefined') {
  8747. activeClass = ruleParser.curSiteRule.activeClass;
  8748. }
  8749. function returnFalse(log) {
  8750. if (curPage > 1) {
  8751. ruleParser.reachedLastPage();
  8752. } else {
  8753. sideController.remove();
  8754. }
  8755. debug(log);
  8756. isPause = true;
  8757. callback(false, false);
  8758. if (emuIframe && emuIframe.parentNode) {
  8759. emuIframe.parentNode.removeChild(emuIframe);
  8760. emuIframe = null;
  8761. }
  8762. }
  8763. async function cloneStatus() {
  8764. if (!iframeDoc) return;
  8765. let inputs = document.querySelectorAll("input:not([type=button],[type=image],[type=reset],[type=submit])");
  8766. let selectOptions = document.querySelectorAll("select>option");
  8767. [...inputs].forEach(input => {
  8768. let sel = geneSelector(input, true, true);
  8769. let mirrorEle = iframeDoc.querySelector(sel);
  8770. if (!mirrorEle) return;
  8771. emuInput(mirrorEle, input.value);
  8772. });
  8773. [...selectOptions].forEach(option => {
  8774. let sel = geneSelector(option, true, true);
  8775. let mirrorEle = iframeDoc.querySelector(sel);
  8776. if (!mirrorEle) return;
  8777. let selected = option.selected;
  8778. mirrorEle.selected = !!selected;
  8779. mirrorEle.parentNode.dispatchEvent(new Event('change'));
  8780. });
  8781. if (activeClass) {
  8782. let actives = document.querySelectorAll("." + activeClass);
  8783. for (let active of actives) {
  8784. let sel = geneSelector(active, true, true).replace("." + activeClass, "");
  8785. let mirrorEle = await waitForElement(sel, iframeDoc, 5000);
  8786. if (!mirrorEle || mirrorEle.classList.contains(activeClass)) {
  8787. continue;
  8788. }
  8789. emuClick(mirrorEle);
  8790. await sleep(300);
  8791. }
  8792. }
  8793. }
  8794. async function checkPage() {
  8795. if (isPause) return loadPageOver();
  8796. try {
  8797. iframeDoc = emuIframe.contentDocument || emuIframe.contentWindow.document;
  8798. } catch(e) {
  8799. returnFalse("Stop as cors");
  8800. return;
  8801. }
  8802. getBody(iframeDoc).scrollTop = 9999999;
  8803. if (iframeDoc.documentElement) {
  8804. iframeDoc.documentElement.scrollTop = 9999999;
  8805. }
  8806.  
  8807. let waitTime = 200, checkEval;
  8808. ruleParser.runWait((_checkEval, _waitTime) => {
  8809. if (_checkEval) {
  8810. checkEval = _checkEval;
  8811. }
  8812. if (_waitTime) {
  8813. waitTime = _waitTime;
  8814. }
  8815. });
  8816.  
  8817. if (!orgPage) {
  8818. if (!loadmoreEnd) {
  8819. loadmoreBtn = getLoadMore(iframeDoc);
  8820. if (loadmoreBtn && isVisible(loadmoreBtn, emuIframe.contentWindow)) {
  8821. emuClick(loadmoreBtn, iframeDoc);
  8822. let intv = setInterval(() => {
  8823. loadmoreBtn = getLoadMore(iframeDoc);
  8824. if (!loadmoreBtn || !getBody(document).contains(loadmoreBtn) || !isVisible(loadmoreBtn, emuIframe.contentWindow)) {
  8825. clearInterval(intv);
  8826. loadmoreEnd = true;
  8827. setTimeout(() => {
  8828. checkPage();
  8829. }, 500);
  8830. } else if (isInViewPort(loadmoreBtn)) {
  8831. emuClick(loadmoreBtn, iframeDoc);
  8832. }
  8833. }, 200);
  8834. return;
  8835. } else {
  8836. loadmoreEnd = true;
  8837. }
  8838. }
  8839. if (checkEval && !await checkEval(iframeDoc)) {
  8840. waitTimes = 50;
  8841. setTimeout(() => {
  8842. checkPage();
  8843. }, waitTime);
  8844. return;
  8845. } else {
  8846. if (!nextLink || !nextLink.offsetParent) nextLink = await ruleParser.getNextLink(iframeDoc, true);
  8847. if (nextLink) pageEle = ruleParser.getPageElement(iframeDoc, emuIframe.contentWindow, true);
  8848. if (!pageEle || pageEle.length == 0 || !nextLink) {
  8849. getBody(iframeDoc).scrollTop = 9999999;
  8850. if (iframeDoc.documentElement) {
  8851. iframeDoc.documentElement.scrollTop = 9999999;
  8852. }
  8853. if (waitTimes-- > 0) {
  8854. setTimeout(() => {
  8855. checkPage();
  8856. }, waitTime);
  8857. return;
  8858. }
  8859. }
  8860. }
  8861. if (!pageEle || pageEle.length == 0) {
  8862. returnFalse("Stop as no page when emu");
  8863. return;
  8864. }
  8865. pageEle = [].filter.call(pageEle, ele => {return ele && !compareNodeName(ele, ["style", "script", "meta"])});
  8866. if (compareNodeName(pageEle[0], ["ul"]) || pageEle.length == 1) pageEle = pageEle[0];
  8867. else if (pageEle[0].parentNode == pageEle[1].parentNode) {
  8868. pageEle = pageEle[0].parentNode;
  8869. } else {
  8870. pageEle = pageEle[0];
  8871. }
  8872. if (ruleParser.curSiteRule.smart && orgContent != pageEle.innerHTML) {
  8873. orgContent = pageEle.innerHTML;
  8874. if (waitTimes-- > 0) {
  8875. setTimeout(() => {
  8876. checkPage();
  8877. }, 500);
  8878. return;
  8879. }
  8880. }
  8881. orgPage = pageEle;
  8882. if (nextLink) {
  8883. if (compareNodeName(orgPage, ["img"])) {
  8884. if (!ruleParser.curSiteRule.lazyImgSrc) ruleParser.curSiteRule.lazyImgSrc = "0";
  8885. if (orgPage.src) {
  8886. orgContent = orgPage.src;
  8887. } else {
  8888. setTimeout(() => {
  8889. checkPage();
  8890. }, 500);
  8891. return;
  8892. }
  8893. } else {
  8894. orgContent = orgPage.innerHTML;
  8895. }
  8896. preContent = orgContent;
  8897. if (!isVisible(nextLink, emuIframe.contentWindow)) {
  8898. returnFalse("Stop as next hide when emu");
  8899. } else {
  8900. emuClick(nextLink, iframeDoc);
  8901. setTimeout(() => {
  8902. checkPage();
  8903. }, 500);
  8904. }
  8905. } else {
  8906. returnFalse("Stop as no next when emu");
  8907. }
  8908. return;
  8909. }
  8910. if (!ruleParser.checkStopSign(nextLink, iframeDoc)) {
  8911. return returnFalse("Stop as stopSign");
  8912. }
  8913. if (checkTimes++ > 200) {
  8914. returnFalse("Stop as timeout when emu");
  8915. return;
  8916. }
  8917. if (checkEval && !await checkEval(iframeDoc)) {
  8918. checkTimes = 0;
  8919. setTimeout(() => {
  8920. checkPage();
  8921. }, waitTime);
  8922. return;
  8923. }
  8924. let eles = ruleParser.getPageElement(iframeDoc, emuIframe.contentWindow, true), checkItem;
  8925. if (eles && eles.length > 0) {
  8926. eles = [].filter.call(eles, ele => {return ele && !compareNodeName(ele, ["style", "script", "meta"])});
  8927. if (compareNodeName(eles[0], ["ul"]) || eles.length == 1) checkItem = eles[0];
  8928. else if (eles[0].parentNode == eles[1].parentNode) {
  8929. checkItem = eles[0].parentNode;
  8930. } else {
  8931. checkItem = eles[0];
  8932. }
  8933. }
  8934. if (!checkItem) {
  8935. setTimeout(() => {
  8936. checkPage();
  8937. }, waitTime);
  8938. } else {
  8939. let checkInner;
  8940. if (compareNodeName(checkItem, ["img"])) {
  8941. if (checkItem.src) {
  8942. checkInner = checkItem.src;
  8943. } else {
  8944. setTimeout(() => {
  8945. checkPage();
  8946. }, waitTime);
  8947. return;
  8948. }
  8949. } else {
  8950. checkInner = checkItem.innerHTML;
  8951. }
  8952. if (orgPage != checkItem || checkInner != preContent) {
  8953. changed = true;
  8954. checkNext = 0;
  8955. orgPage = checkItem;
  8956. preContent = checkInner;
  8957. setTimeout(() => {
  8958. checkPage();
  8959. }, ruleParser.curSiteRule.smart ? 1000 : 500);
  8960. } else if (changed) {
  8961. checkTimes = 0;
  8962. if (orgContent == preContent && (ruleParser.curSiteRule.smart || ruleParser.curSiteRule.stopSame)) {
  8963. returnFalse("Stop as same content");
  8964. } else {
  8965. orgContent = preContent;
  8966. await ruleParser.hookUrl(iframeDoc);
  8967. if (!nextLink || !nextLink.offsetParent) {
  8968. nextLink = await ruleParser.getNextLink(iframeDoc, true);
  8969. }
  8970. if (!nextLink && ++checkNext < 5) {
  8971. setTimeout(() => {
  8972. checkPage();
  8973. }, waitTime);
  8974. }
  8975. callback(iframeDoc, eles);
  8976. }
  8977. } else {
  8978. if (checkTimes % 10 === 5) {
  8979. if (!nextLink || !nextLink.offsetParent) {
  8980. nextLink = await ruleParser.getNextLink(iframeDoc, true);
  8981. }
  8982. if (nextLink) {
  8983. emuClick(nextLink, iframeDoc);
  8984. }
  8985. }
  8986. setTimeout(() => {
  8987. checkPage();
  8988. }, waitTime);
  8989. }
  8990. }
  8991. }
  8992. if (!emuIframe) {
  8993. let loaded = false;
  8994. emuIframe = document.createElement('iframe');
  8995. emuIframe.name = 'pagetual-iframe';
  8996. let notSetSandbox = typeof ruleParser.curSiteRule.sandbox == 'undefined';
  8997. if (notSetSandbox || ruleParser.curSiteRule.sandbox == true) {
  8998. emuIframe.sandbox = "allow-same-origin allow-scripts allow-popups allow-forms";
  8999. } else if (ruleParser.curSiteRule.sandbox) {
  9000. emuIframe.sandbox = ruleParser.curSiteRule.sandbox;
  9001. }
  9002. emuIframe.width = '100%';
  9003. emuIframe.height = '100%';
  9004. emuIframe.frameBorder = '0';
  9005. 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;';
  9006. emuIframe.addEventListener("load", e => {
  9007. try {
  9008. iframeDoc = emuIframe.contentDocument || emuIframe.contentWindow.document;
  9009. } catch(e) {
  9010. if (e.message && e.message.indexOf("cross-origin") != -1 && notSetSandbox && emuIframe.hasAttribute("sandbox")) {
  9011. emuIframe.removeAttribute("sandbox");
  9012. meetCors = true;
  9013. callback(false, false);
  9014. if (ruleParser.curSiteRule.smart) {
  9015. ruleParser.findNoNext();
  9016. }
  9017. } else {
  9018. returnFalse("Stop as cors");
  9019. }
  9020. return;
  9021. }
  9022. setTimeout(async () => {
  9023. if (meetCors && ruleParser.curSiteRule.smart) {
  9024. ruleParser.smartRules = ruleParser.smartRules.filter(item => {return item && item.url !== ruleParser.curSiteRule.url;});
  9025. storage.setItem("smartRules", ruleParser.smartRules);
  9026. }
  9027. meetCors = false;
  9028. let code = ruleParser.curSiteRule.init;
  9029. if (code) {
  9030. try {
  9031. 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)});
  9032. } catch(e) {
  9033. debug(e);
  9034. }
  9035. } else {
  9036. let refreshByClickSel = ruleParser.curSiteRule.refreshByClick;
  9037. if (iframeDoc && refreshByClickSel) {
  9038. let clickBtn = await waitForElement(refreshByClickSel, iframeDoc);
  9039. await sleep(500);
  9040. await cloneStatus();
  9041. emuClick(clickBtn, iframeDoc);
  9042. await sleep(500);
  9043. } else {
  9044. await cloneStatus();
  9045. await sleep(500);
  9046. }
  9047. }
  9048. if (loaded) return;
  9049. loaded = true;
  9050. checkPage();
  9051. }, 500);
  9052. });
  9053. let code = ruleParser.curSiteRule.iframeInit;
  9054. if (code) {
  9055. let checkReady = setInterval(() => {
  9056. try {
  9057. iframeDoc = emuIframe.contentDocument || (emuIframe.contentWindow && emuIframe.contentWindow.document);
  9058. } catch(e) {
  9059. clearInterval(checkReady);
  9060. return;
  9061. }
  9062. if (iframeDoc) {
  9063. clearInterval(checkReady);
  9064. try {
  9065. Function('win', 'iframe', '"use strict";' + code)(emuIframe.contentWindow, emuIframe);
  9066. } catch(e) {
  9067. debug(e);
  9068. }
  9069. }
  9070. }, 50);
  9071. }
  9072. if (!lastActiveUrl) lastActiveUrl = location.href;
  9073. emuIframe.src = lastActiveUrl;
  9074. getBody(document).appendChild(emuIframe);
  9075. } else {
  9076. if (emuIframe.src != lastActiveUrl || meetCors) {
  9077. emuIframe.src = lastActiveUrl;
  9078. return;
  9079. }
  9080. checkPage();
  9081. }
  9082. }
  9083.  
  9084. var scrollToResizeInited = false;
  9085. var resizePool = [];
  9086. var scrollingToResize = false;
  9087.  
  9088. function isTouchViewPort(element) {
  9089. const viewWidth = window.innerWidth || document.documentElement.clientWidth;
  9090. const viewHeight = window.innerHeight || document.documentElement.clientHeight;
  9091. const {
  9092. top,
  9093. right,
  9094. bottom,
  9095. left,
  9096. } = element.getBoundingClientRect();
  9097.  
  9098. return (
  9099. top < viewHeight &&
  9100. left < viewWidth &&
  9101. right > 0 &&
  9102. bottom > 0
  9103. );
  9104. }
  9105.  
  9106. function resizeIframe(iframe, frameDoc, pageEle) {
  9107. if (targetY >= 0) {
  9108. window.scrollTo({ top: targetY, behavior: 'instant'});
  9109. targetY = -1;
  9110. }
  9111. let curScroll = getBody(document).scrollTop || document.documentElement.scrollTop;
  9112. if (ruleParser.curSiteRule.smart || forceState === 2) {
  9113. let height = (getBody(frameDoc).scrollHeight || getBody(frameDoc).offsetHeight || 500);
  9114. if (!iframe.style.height || parseInt(iframe.style.height) === 0 || height - parseInt(iframe.style.height) > window.innerHeight) {
  9115. iframe.style.height = height + "px";
  9116. iframe.style.minHeight = iframe.style.height;
  9117. }
  9118. iframe.style.width = "100%";
  9119. frameDoc.documentElement.scrollTop = 0;
  9120. frameDoc.documentElement.scrollLeft = 0;
  9121. } else {
  9122. if (pageEle) {
  9123. if (document.body.scrollWidth) frameDoc.documentElement.style.width = document.body.scrollWidth + "px";
  9124. let fitWidth = ruleParser.curSiteRule.fitWidth !== false;
  9125. let targetElement = pageEle[0];
  9126. if (!targetElement) return;
  9127. if (pageEle.length > 1) {
  9128. targetElement = targetElement.parentNode;
  9129. }
  9130. let scrollHeight = targetElement.scrollHeight || targetElement.offsetHeight || 500;
  9131. iframe.style.height = scrollHeight + "px";
  9132. let scrollTop = 0, scrollLeft = 0;
  9133. getBody(frameDoc).scrollTop = 0;
  9134. getBody(frameDoc).scrollLeft = 0;
  9135. while (targetElement && targetElement.offsetParent) {
  9136. targetElement.offsetParent.scrollTop = targetElement.offsetTop;
  9137. if (targetElement.offsetParent.scrollTop == 0) {
  9138. scrollTop += targetElement.offsetTop;
  9139. }
  9140. if (fitWidth) {
  9141. targetElement.offsetParent.scrollLeft = targetElement.offsetLeft;
  9142. if (targetElement.offsetParent.scrollLeft == 0) {
  9143. scrollLeft += targetElement.offsetLeft;
  9144. }
  9145. }
  9146. targetElement = targetElement.offsetParent;
  9147. }
  9148. frameDoc.documentElement.scrollTop = scrollTop;
  9149. frameDoc.documentElement.scrollLeft = scrollLeft;
  9150. if (frameDoc.documentElement.scrollTop == 0 && frameDoc.documentElement.scrollLeft == 0) {
  9151. getBody(frameDoc).scrollTop += scrollTop;
  9152. getBody(frameDoc).scrollLeft += scrollLeft;
  9153. }
  9154. if (!fitWidth && iframe.style.marginLeft == '0px') {
  9155. iframe.style.width = "100vw";
  9156. iframe.style.maxWidth = "100vw";
  9157. iframe.style.minWidth = "100vw";
  9158. var cWidth = document.body.clientWidth || document.documentElement.clientWidth;
  9159. var iWidth = window.innerWidth;
  9160. iframe.style.marginLeft = -iframe.getBoundingClientRect().left - (iWidth - cWidth) / 2 + "px";
  9161. }
  9162. }
  9163. }
  9164. let newScroll = getBody(document).scrollTop || document.documentElement.scrollTop;
  9165. if (newScroll != curScroll) {
  9166. getBody(document).scrollTop = curScroll;
  9167. document.documentElement.scrollTop = curScroll;
  9168. }
  9169. }
  9170.  
  9171. function scrollToResize(e) {
  9172. if (scrollingToResize) return;
  9173. else {
  9174. scrollingToResize = true;
  9175. let resizeHandler = () => {
  9176. let touched = 0;
  9177. for (let i = 0; i < resizePool.length; i++) {
  9178. let resizeArr = resizePool[i];
  9179. let iframe = resizeArr[1]();
  9180. if (isTouchViewPort(iframe)) {
  9181. touched++;
  9182. let pageEle = resizeArr[0]();
  9183. let frameDoc = resizeArr[2]();
  9184. resizeIframe(iframe, frameDoc, pageEle);
  9185. } else if (touched) {
  9186. if (touched == 1) {
  9187. let pageEle = resizeArr[0]();
  9188. let frameDoc = resizeArr[2]();
  9189. resizeIframe(iframe, frameDoc, pageEle);
  9190. }
  9191. break;
  9192. } else if (!iframe.parentNode) {
  9193. resizePool.splice(i, 1);
  9194. break;
  9195. }
  9196. }
  9197. };
  9198. setTimeout(() => {
  9199. scrollingToResize = false;
  9200. }, 300);
  9201. resizeHandler();
  9202. }
  9203. }
  9204.  
  9205. var curForceIframe;
  9206. function forceIframe(url, callback) {
  9207. url = url.indexOf('=') == -1 ? url.replace(/#[^#]*/,"") : url;
  9208. let curIframe = document.createElement('iframe'), iframeDoc, pageElement = null, inAction = true;
  9209. let loadedHandler = () => {
  9210. let getPageEle = () => {
  9211. if (ruleParser.curSiteRule.smart) {
  9212. return null;
  9213. } else {
  9214. if (!pageElement || pageElement.length === 0 || !pageElement[0].offsetParent) {
  9215. pageElement = ruleParser.getPageElement(iframeDoc, curIframe.contentWindow);
  9216. }
  9217. return pageElement;
  9218. }
  9219. };
  9220. resizeIframe(curIframe, iframeDoc, getPageEle());
  9221. let loaded = curIframe.getAttribute("loaded");
  9222. if (loaded == "true") {
  9223. return;
  9224. }
  9225. curIframe.setAttribute("loaded", "true");
  9226. let getIframe = () => {
  9227. return curIframe;
  9228. };
  9229. let getFrameDoc = () => {
  9230. return iframeDoc;
  9231. };
  9232. ruleParser.insertPage(iframeDoc, [], url, ele => {
  9233. callback(curIframe, loaded == "refresh");
  9234. inAction = false;
  9235. }, true);
  9236. if (!loaded) {
  9237. resizePool.push([getPageEle, getIframe, getFrameDoc]);
  9238. }
  9239. };
  9240. let checkIframeTimer = setInterval(() => {
  9241. if (!curIframe.parentNode) {
  9242. clearInterval(checkIframeTimer);
  9243. return curIframe.getAttribute("loaded") == "true" || callback(false);
  9244. }
  9245. }, 500);
  9246. let code = ruleParser.curSiteRule.iframeInit;
  9247. if (code) {
  9248. let checkReady = setInterval(() => {
  9249. try {
  9250. iframeDoc = curIframe.contentDocument || (curIframe.contentWindow && curIframe.contentWindow.document);
  9251. } catch(e) {
  9252. clearInterval(checkReady);
  9253. return;
  9254. }
  9255. if (iframeDoc) {
  9256. clearInterval(checkReady);
  9257. try {
  9258. Function('win', 'iframe', '"use strict";' + code)(curIframe.contentWindow, curIframe);
  9259. } catch(e) {
  9260. debug(e);
  9261. }
  9262. }
  9263. }, 50);
  9264. }
  9265. let waitTime = 300, checkEval;
  9266. ruleParser.runWait((_checkEval, _waitTime) => {
  9267. if (_checkEval) {
  9268. checkEval = _checkEval;
  9269. }
  9270. if (_waitTime) {
  9271. waitTime = _waitTime;
  9272. }
  9273. });
  9274. async function checkIframe() {
  9275. if (checkEval && !await checkEval(iframeDoc)) {
  9276. setTimeout(() => {
  9277. checkIframe();
  9278. }, waitTime);
  9279. return;
  9280. }
  9281. loadedHandler();
  9282. }
  9283. curIframe.name = 'pagetual-iframe';
  9284. curIframe.sandbox = "allow-same-origin allow-scripts allow-popups allow-forms";
  9285. curIframe.frameBorder = '0';
  9286. curIframe.scrolling = "no";
  9287. 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;';
  9288. curIframe.addEventListener("load", async e => {
  9289. clearInterval(checkIframeTimer);
  9290. if (isPause) return callback(false);
  9291. try {
  9292. iframeDoc = curIframe.contentDocument || curIframe.contentWindow.document;
  9293. } catch(e) {
  9294. debug("Stop as cors");
  9295. isPause = true;
  9296. callback(false);
  9297. return;
  9298. }
  9299. let css;
  9300. if (rulesData.customCss && ruleParser.curSiteRule.css) {
  9301. let globalCssArr = rulesData.customCss.split("inIframe:");
  9302. let ruleCssArr = ruleParser.curSiteRule.css.split("inIframe:");
  9303. let mainCss = globalCssArr[0] + ruleCssArr[0], inCss = (globalCssArr[1] || "") + (ruleCssArr[1] || "");
  9304. css = mainCss + (inCss ? ("inIframe:" + inCss) : "");
  9305. } else {
  9306. css = ruleParser.curSiteRule.css || rulesData.customCss;
  9307. }
  9308. if (css) {
  9309. let cssArr = css.split("inIframe:");
  9310. if (cssArr && cssArr.length > 1) {
  9311. let styleEle = iframeDoc.createElement("style");
  9312. styleEle.innerHTML = cssArr[1];
  9313. iframeDoc.head.appendChild(styleEle);
  9314. }
  9315. }
  9316. curIframe.style.height = "";
  9317. checkIframe();
  9318. iframeDoc.addEventListener('wheel', e => {
  9319. document.dispatchEvent(new Event('wheel'));
  9320. }, true);
  9321. });
  9322. let checkTimes = 0, findPageEle = false;
  9323. let forceRefresh = e => {
  9324. if (inAction || !iframeDoc) return;
  9325. inAction = true;
  9326. let foundNext = () => {
  9327. document.removeEventListener("scroll", forceRefresh);
  9328. }
  9329. setTimeout(async () => {
  9330. inAction = false;
  9331. if (!ruleParser.nextLinkHref && !isPause) {
  9332. checkTimes++;
  9333. await ruleParser.getNextLink(iframeDoc, true);
  9334. if (ruleParser.nextLinkHref) {
  9335. foundNext();
  9336. if (isLoading) isLoading = false;
  9337. } else if (checkTimes >= 10) {
  9338. foundNext();
  9339. } else if (checkTimes >= 3 && !findPageEle) {
  9340. if (!pageElement) pageElement = ruleParser.getPageElement(iframeDoc, curIframe.contentWindow);
  9341. if (!pageElement) {
  9342. inAction = true;
  9343. curIframe.contentWindow.location.reload();
  9344. } else {
  9345. findPageEle = true;
  9346. }
  9347. }
  9348. } else {
  9349. foundNext();
  9350. }
  9351. }, 100);
  9352. };
  9353. document.addEventListener("scroll", forceRefresh);
  9354. curIframe.src = url;
  9355. curForceIframe = curIframe;
  9356. let insert = ruleParser.getInsert();
  9357. let body = getBody(document);
  9358. let curScroll = body.scrollTop || document.documentElement.scrollTop;
  9359. if (forceState == 2) {
  9360. document.documentElement.appendChild(loadingDiv);
  9361. body.appendChild(curIframe);
  9362. let bodyStyle = getComputedStyle(body);
  9363. if (bodyStyle.display == "flex" || bodyStyle.display == "inline-flex") {
  9364. body.style.flexDirection = "column";
  9365. }
  9366. } else {
  9367. ruleParser.insertElement(curIframe);
  9368. }
  9369. body.scrollTop = curScroll;
  9370. document.documentElement.scrollTop = curScroll;
  9371.  
  9372. if (!scrollToResizeInited) {
  9373. scrollToResizeInited = true;
  9374. document.addEventListener("scroll", scrollToResize);
  9375. }
  9376. return curIframe;
  9377. }
  9378.  
  9379. function loadPageOver() {
  9380. isLoading = false;
  9381. stopScroll = true;
  9382. setTimeout(() => {stopScroll = false;}, 300);
  9383. if (loadingDiv.parentNode) {
  9384. loadingDiv.parentNode.removeChild(loadingDiv);
  9385. }
  9386. if (rate !== 1 && !clickMode) {
  9387. setTimeout(() => {
  9388. if (distToBottom() < bottomGap) {
  9389. nextPage();
  9390. }
  9391. }, 1);
  9392. }
  9393. if (sideController.inited) {
  9394. sideController.frame.classList.remove("loading");
  9395. }
  9396. }
  9397.  
  9398. function checkAutoLoadNum() {
  9399. if (autoLoadNum >= 0) {
  9400. if (autoLoadNum !== 0 && --autoLoadNum === 0) {
  9401. autoLoadNum = -1;
  9402. } else {
  9403. setTimeout(() => nextPage(), 1);
  9404. }
  9405. }
  9406. }
  9407.  
  9408. async function nextPage() {
  9409. if (isPause || isLoading || forceState === 1) return;
  9410. if (ruleParser.curSiteRule.delay) {
  9411. try {
  9412. let checkDelay = ((typeof ruleParser.curSiteRule.delay === 'function') ? ruleParser.curSiteRule.delay : Function('"use strict";' + ruleParser.curSiteRule.delay))();
  9413. if (!checkDelay) return;
  9414. } catch(e) {
  9415. debug(e);
  9416. }
  9417. }
  9418. let nextLink = ruleParser.nextLinkHref;
  9419. if (!nextLink) {
  9420. isLoading = true;
  9421. if (curPage === 1) {
  9422. await ruleParser.getNextLink(document, true);
  9423. nextLink = ruleParser.nextLinkHref;
  9424. }
  9425. if (!nextLink) {
  9426. if (curPage === 1) {
  9427. if (ruleParser.curSiteRule.pinUrl) {
  9428. setTimeout(() => {isLoading = false;}, 500);
  9429. } else if (tryTimes++ < 5) {
  9430. setTimeout(() => {isLoading = false;}, 1000);
  9431. } else {
  9432. ruleParser.findNoNext();
  9433. }
  9434. } else if (!showedLastPageTips) {
  9435. ruleParser.reachedLastPage();
  9436. showedLastPageTips = true;
  9437. }
  9438. return;
  9439. }
  9440. isLoading = false;
  9441. }
  9442. showedLastPageTips = false;
  9443. let pvGallery = document.querySelector("span.pv-gallery-container");
  9444. if (pvGallery && pvGallery.style.display !== "none") return;
  9445. let insert = ruleParser.getInsert();
  9446. if (insert) {
  9447. if (curPage === 1) {
  9448. initView();
  9449. }
  9450. /*if (curPage == 1) {
  9451. window.postMessage({
  9452. command: 'pagetual.insert'
  9453. }, '*');
  9454. }*/
  9455. let isJs = ruleParser.curSiteRule.action == 3 || ruleParser.hrefIsJs(nextLink);
  9456. if (!isJs) {
  9457. emuIframe = null;
  9458. lastActiveUrl = nextLink;
  9459. if (location.protocol === "https:" && /^http:/.test(nextLink)) {
  9460. nextLink = nextLink.replace(/^http/, "https");
  9461. }
  9462. }
  9463. isLoading = true;
  9464. if (curPage !== 1 || !isJs || !ruleParser.curSiteRule.smart) {
  9465. ruleParser.beginLoading(loadingDiv);
  9466. } else {
  9467. if (sideController.inited) {
  9468. sideController.frame.classList.add("loading");
  9469. }
  9470. }
  9471. let sleep = ruleParser.curSiteRule.sleep || 0;
  9472. setTimeout(() => {
  9473. if (ruleParser.curSiteRule.pageElementByJs) {
  9474. var over = eles => {
  9475. if (urlChanged || isPause) {
  9476. loadPageOver();
  9477. return;
  9478. }
  9479. if (eles) {
  9480. ruleParser.insertPage(document, eles, nextLink, () => {
  9481. createPageBar(nextLink);
  9482. checkAutoLoadNum();
  9483. }, true);
  9484. } else {
  9485. debug("Stop as no page when get by js");
  9486. isPause = true;
  9487. loadPageOver();
  9488. }
  9489. };
  9490. try {
  9491. ((typeof ruleParser.curSiteRule.pageElementByJs === 'function') ? ruleParser.curSiteRule.pageElementByJs : Function("over", "pageNum",'"use strict";' + ruleParser.curSiteRule.pageElementByJs))(over, curPage);
  9492. } catch(e) {
  9493. debug(e);
  9494. }
  9495. } else if ((forceState === 2 || ruleParser.curSiteRule.action == 2) && !isJs) {
  9496. forceIframe(nextLink, (iframe, refresh) => {
  9497. if (urlChanged || isPause) {
  9498. loadPageOver();
  9499. return;
  9500. }
  9501. if (!refresh) {
  9502. let pageBar = createPageBar(nextLink);
  9503. if (pageBar && iframe && iframe.parentNode) iframe.parentNode.insertBefore(pageBar, iframe);
  9504. }
  9505. loadPageOver();
  9506. checkAutoLoadNum();
  9507. });
  9508. } else if ((forceState === 3 || ruleParser.curSiteRule.action == 1) && !isJs) {
  9509. requestFromIframe(nextLink, async (doc, eles) => {
  9510. if (urlChanged || isPause) {
  9511. loadPageOver();
  9512. return;
  9513. }
  9514. if (eles) {
  9515. await ruleParser.insertPage(doc, eles, nextLink, () => {
  9516. createPageBar(nextLink);
  9517. checkAutoLoadNum();
  9518. }, true);
  9519. } else {
  9520. loadPageOver();
  9521. if (autoLoadNum >= 0) {
  9522. setTimeout(() => nextPage(), 2000);
  9523. }
  9524. }
  9525. });
  9526. } else {
  9527. if (!isJs) {
  9528. requestDoc(nextLink, (eles) => {
  9529. if (urlChanged || isPause) {
  9530. loadPageOver();
  9531. return;
  9532. }
  9533. if (eles) {
  9534. createPageBar(nextLink);
  9535. checkAutoLoadNum();
  9536. } else {
  9537. loadPageOver();
  9538. if (autoLoadNum >= 0) {
  9539. setTimeout(() => nextPage(), 2000);
  9540. }
  9541. }
  9542. });
  9543. } else {
  9544. emuPage((doc, eles) => {
  9545. if (urlChanged || isPause) {
  9546. loadPageOver();
  9547. return;
  9548. }
  9549. if (eles) {
  9550. ruleParser.insertPage(doc, eles, "", () => {
  9551. createPageBar(nextLink);
  9552. checkAutoLoadNum();
  9553. }, true);
  9554. } else {
  9555. loadPageOver();
  9556. if (autoLoadNum >= 0) {
  9557. setTimeout(() => nextPage(), 2000);
  9558. }
  9559. }
  9560. });
  9561. }
  9562. }
  9563. }, sleep);
  9564. }
  9565. }
  9566.  
  9567. function init() {
  9568. if (document.readyState === 'loading' || document.readyState === 'uninitialized') {
  9569. let domReady = e => {
  9570. initRules(() => {
  9571. initPage();
  9572. });
  9573. document.removeEventListener("DOMContentLoaded", domReady, false);
  9574. };
  9575. document.addEventListener("DOMContentLoaded", domReady, false);
  9576. } else {
  9577. initRules(() => {
  9578. initPage();
  9579. });
  9580. }
  9581. }
  9582.  
  9583. function visibilitychangeHandler() {
  9584. document.removeEventListener('visibilitychange', visibilitychangeHandler);
  9585. init();
  9586. }
  9587.  
  9588. setTimeout(() => {
  9589. if (document.hidden) {
  9590. document.addEventListener('visibilitychange', visibilitychangeHandler);
  9591. } else {
  9592. init();
  9593. }
  9594. }, 300);
  9595. })();