()
| 13456 | } |
| 13457 | |
| 13458 | async function nextPage() { |
| 13459 | if (isPause || isLoading || forceState === 1) return; |
| 13460 | if (ruleParser.curSiteRule.delay) { |
| 13461 | try { |
| 13462 | let checkDelay = ((typeof ruleParser.curSiteRule.delay === 'function') ? ruleParser.curSiteRule.delay : Function('"use strict";' + ruleParser.curSiteRule.delay))(); |
| 13463 | if (!checkDelay) return; |
| 13464 | } catch(e) { |
| 13465 | debug(e); |
| 13466 | } |
| 13467 | } |
| 13468 | let nextLink = ruleParser.nextLinkHref; |
| 13469 | if (!nextLink) { |
| 13470 | isLoading = true; |
| 13471 | if (curPage === 1) { |
| 13472 | await ruleParser.getNextLink(document, true); |
| 13473 | nextLink = ruleParser.nextLinkHref; |
| 13474 | } |
| 13475 | if (!nextLink) { |
| 13476 | if (curPage === 1) { |
| 13477 | if (ruleParser.curSiteRule.pinUrl) { |
| 13478 | setTimeout(() => {isLoading = false;}, 500); |
| 13479 | } else if (tryTimes++ < 5) { |
| 13480 | setTimeout(() => {isLoading = false;}, 1000); |
| 13481 | } else { |
| 13482 | ruleParser.findNoNext(); |
| 13483 | } |
| 13484 | } else if (!showedLastPageTips) { |
| 13485 | ruleParser.reachedLastPage(); |
| 13486 | showedLastPageTips = true; |
| 13487 | } |
| 13488 | return; |
| 13489 | } |
| 13490 | isLoading = false; |
| 13491 | } |
| 13492 | showedLastPageTips = false; |
| 13493 | let pvGallery = document.querySelector("span.pv-gallery-container"); |
| 13494 | if (pvGallery && pvGallery.style.display !== "none") return; |
| 13495 | let insert = ruleParser.getInsert(); |
| 13496 | if (insert) { |
| 13497 | if (curPage === 1) { |
| 13498 | initView(); |
| 13499 | } |
| 13500 | /*if (curPage == 1) { |
| 13501 | window.postMessage({ |
| 13502 | command: 'pagetual.insert' |
| 13503 | }, '*'); |
| 13504 | }*/ |
| 13505 | let isJs = ruleParser.curSiteRule.action == 3 || ruleParser.hrefIsJs(nextLink); |
| 13506 | if (!isJs) { |
| 13507 | if (emuIframe) { |
| 13508 | if (emuIframe.parentNode) { |
| 13509 | emuIframe.parentNode.removeChild(emuIframe); |
| 13510 | } |
| 13511 | emuIframe = null; |
| 13512 | } |
| 13513 | lastActiveUrl = nextLink; |
| 13514 | if (location.protocol === "https:" && /^http:/.test(nextLink)) { |
| 13515 | nextLink = nextLink.replace(/^http/, "https"); |
no test coverage detected