MCPcopy
hub / github.com/hoothin/UserScripts / waitElement

Method waitElement

Pagetual/pagetual.user.js:5190–5224  ·  view source on GitHub ↗
(doc, selArr)

Source from the content-addressed store, hash-verified

5188 }
5189
5190 waitElement(doc, selArr) {
5191 if (!selArr) selArr = this.curSiteRule.waitElement;
5192 if (!Array.isArray(selArr)) {
5193 selArr = [selArr];
5194 }
5195 let includeSel = selArr[0].trim(), excludeSel;
5196 if (selArr.length === 2) {
5197 excludeSel = selArr[1].trim().replace(/^!/, '');
5198 } else if (includeSel.indexOf('!') === 0) {
5199 excludeSel = includeSel.replace(/^!/, '');
5200 includeSel = '';
5201 }
5202 if (includeSel) {
5203 let include = getElement(includeSel, doc);
5204 if (!include) {
5205 if (doc !== document) {
5206 getBody(doc).scrollTop = 9999999;
5207 if (doc.documentElement) {
5208 doc.documentElement.scrollTop = 9999999;
5209 }
5210 }
5211 return false;
5212 }
5213 }
5214 if (doc === document) return true;
5215 if (excludeSel) {
5216 if (!this.scrollToShow(excludeSel, doc)) {
5217 if (!loadingDiv.offsetParent && this.insert.parentNode) {
5218 this.insertElement(loadingDiv);
5219 }
5220 return false;
5221 }
5222 }
5223 return true;
5224 }
5225
5226 runPageBar(pageBar) {
5227 if (this.curSiteRule.pageBar && this.curSiteRule.pageBar !== 0) {

Callers 2

runWaitMethod · 0.95
checkReadyMethod · 0.80

Calls 4

scrollToShowMethod · 0.95
insertElementMethod · 0.95
getElementFunction · 0.85
getBodyFunction · 0.70

Tested by

no test coverage detected