(callback)
| 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; |
no test coverage detected