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

Method checkStopSign

Pagetual/pagetual.user.js:7040–7119  ·  view source on GitHub ↗
(nextLink, doc)

Source from the content-addressed store, hash-verified

7038 }
7039
7040 checkStopSign(nextLink, doc) {
7041 if (this.curSiteRule.stopSign) {
7042 let typeArray = Array && Array.isArray && Array.isArray(this.curSiteRule.stopSign);
7043 let typeObject = !typeArray && (this.curSiteRule.stopSign.include || this.curSiteRule.stopSign.exclude || this.curSiteRule.stopSign.pageNum);
7044 if (typeArray || typeObject) {
7045 let includeSel, excludeSel, curSign, maxSign;
7046 if (typeArray) {
7047 includeSel = this.curSiteRule.stopSign[0];
7048 excludeSel = this.curSiteRule.stopSign[1];
7049 curSign = this.curSiteRule.stopSign[2];
7050 maxSign = this.curSiteRule.stopSign[3];
7051 if (Array && Array.isArray && Array.isArray(includeSel) && !curSign) {
7052 curSign = includeSel;
7053 includeSel = false;
7054 }
7055 if (excludeSel && Array && Array.isArray && Array.isArray(excludeSel) && !maxSign) {
7056 maxSign = excludeSel;
7057 excludeSel = false;
7058 }
7059 } else {
7060 includeSel = this.curSiteRule.stopSign.include;
7061 excludeSel = this.curSiteRule.stopSign.exclude;
7062 curSign = this.curSiteRule.stopSign.pageNum;
7063 }
7064 if (includeSel) {
7065 includeSel = includeSel.trim();
7066 if (!getElement(includeSel, doc)) {
7067 isPause = true;
7068 this.nextLinkHref = false;
7069 return false;
7070 }
7071 }
7072 if (excludeSel) {
7073 excludeSel = excludeSel.trim();
7074 if (getElement(excludeSel, doc)) {
7075 isPause = true;
7076 this.nextLinkHref = false;
7077 return false;
7078 }
7079 }
7080 if (curSign) {
7081 if (!maxSign) maxSign = curSign.slice(2);
7082 let currentEle = getElement(curSign[0], doc);
7083 let maxEle = getElement(maxSign[0], doc);
7084 if (currentEle && maxEle) {
7085 let currentSignNum, maxSignNum;
7086 if (/\(.*\)/.test(curSign[1])) {
7087 currentSignNum = currentEle.innerText.match(new RegExp(curSign[1]));
7088 if (currentSignNum) currentSignNum = currentSignNum[1];
7089 } else if (currentEle.getAttribute) {
7090 currentSignNum = currentEle.getAttribute(curSign[1]);
7091 }
7092 if (/\(.*\)/.test(maxSign[1])) {
7093 maxSignNum = maxEle.innerText.match(new RegExp(maxSign[1]));
7094 if (maxSignNum) maxSignNum = maxSignNum[1];
7095 } else if (maxEle.getAttribute) {
7096 maxSignNum = maxEle.getAttribute(maxSign[1]);
7097 }

Callers 2

getNextLinkMethod · 0.95
checkPageFunction · 0.80

Calls 2

getElementFunction · 0.85
debugFunction · 0.85

Tested by

no test coverage detected