MCPcopy Index your code
hub / github.com/hoothin/UserScripts / nextPage

Function nextPage

Pagetual/pagetual.user.js:13458–13620  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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");

Callers 9

initPageMethod · 0.85
initMethod · 0.85
initMethod · 0.85
initPageFunction · 0.85
checkScrollReachFunction · 0.85
initListenerFunction · 0.85
checkIframeFunction · 0.85
loadPageOverFunction · 0.85
checkAutoLoadNumFunction · 0.85

Calls 15

debugFunction · 0.85
initViewFunction · 0.85
forceIframeFunction · 0.85
loadPageOverFunction · 0.85
createPageBarFunction · 0.85
checkAutoLoadNumFunction · 0.85
requestFromIframeFunction · 0.85
emuPageFunction · 0.85
getNextLinkMethod · 0.80
findNoNextMethod · 0.80
reachedLastPageMethod · 0.80
getInsertMethod · 0.80

Tested by

no test coverage detected