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

Method initPage

Pagetual/pagetual.user.js:7482–7634  ·  view source on GitHub ↗
(callback)

Source from the content-addressed store, hash-verified

7480 }
7481
7482 initPage(callback) {
7483 let self = this;
7484 if (self.initing) return;
7485 self.initing = true;
7486 setTimeout(() => {
7487 self.initing = false;
7488 }, 100);
7489 curPage = 1;
7490 urlChanged = false;
7491 tryTimes = 0;
7492 this.clearAddedElements();
7493 this.insert = null;
7494 this.visibilityItems = [];
7495 this.visibleIndex = -1;
7496 this.pageDoc = document;
7497 this.nextLinkHref = null;
7498 this.curUrl = location.href;
7499 this.oldUrl = "";
7500 this.initUrl = location.href;
7501 this.historyUrl = "";
7502 this.possibleCheck = 0;
7503 let base = document.querySelector("base");
7504 this.basePath = (base && base.href) || location.href;
7505 this.getRule(async () => {
7506 if (self.curSiteRule.sideController === true || (self.curSiteRule.sideController !== false && rulesData.sideController)) {
7507 isPause = manualPause;
7508 }
7509 hidePageBar = rulesData.opacity == 0 || self.curSiteRule.pageBar === 0;
7510 if (typeof(self.curSiteRule.rate) !== "undefined") {
7511 rate = self.curSiteRule.rate;
7512 }
7513 if (self.curSiteRule.enable == 0) {
7514 debug("Stop as rule disable");
7515 isPause = true;
7516 _GM_registerMenuCommand(i18n("enable"), () => {
7517 showTips(i18n("enableSiteTips"));
7518 if(!self.customRules) {
7519 self.customRules = [];
7520 }
7521 for (let i in self.customRules) {
7522 if (self.customRules[i].url == self.curSiteRule.url) {
7523 self.customRules.splice(i, 1);
7524 break;
7525 }
7526 }
7527 self.curSiteRule.enable = 1;
7528 self.customRules.unshift(self.curSiteRule);
7529 storage.setItem("customRules", self.customRules);
7530 location.reload();
7531 });
7532 return;
7533 }
7534 if (rulesData.sideControllerAlways) {
7535 sideController.setup();
7536 }
7537 //若是再亂匹配就不緩存wedata,或者只在找完本地規則之後再考慮wedata的緩存
7538 if (self.curSiteRule.smart) {
7539 delete self.curSiteRule.pageElement;

Callers 3

checkPossibleMethod · 0.80
initPageFunction · 0.80
initListenerFunction · 0.80

Calls 15

clearAddedElementsMethod · 0.95
getRuleMethod · 0.95
debugFunction · 0.85
showTipsFunction · 0.85
getElementFunction · 0.85
clickActionFunction · 0.85
enterActionFunction · 0.85
inputActionFunction · 0.85
nextPageFunction · 0.85
setupMethod · 0.80
addToHpRulesMethod · 0.80
getNextLinkMethod · 0.80

Tested by

no test coverage detected