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

Method scrollToShow

Pagetual/pagetual.user.js:5162–5188  ·  view source on GitHub ↗
(sel, doc)

Source from the content-addressed store, hash-verified

5160 }
5161
5162 scrollToShow(sel, doc) {
5163 let exclude = getElement(sel, doc);
5164 if (exclude) {
5165 var actualTop = exclude.offsetTop;
5166 var current = exclude.offsetParent;
5167 while (current !== null) {
5168 actualTop += current.offsetTop;
5169 current = current.offsetParent;
5170 }
5171 getBody(doc).scrollTop = 0;
5172 doc.documentElement.scrollTop = 0;
5173 let maxHeight = Math.max(getBody(doc).scrollHeight, doc.documentElement.scrollHeight);
5174 getBody(doc).scrollTop = actualTop - 10;
5175 doc.documentElement.scrollTop = actualTop - 10;
5176 setTimeout(() => {
5177 if (actualTop < maxHeight) {
5178 actualTop += 200;
5179 getBody(doc).scrollTop = actualTop;
5180 doc.documentElement.scrollTop = actualTop;
5181 getBody(doc).scrollTop = maxHeight;
5182 doc.documentElement.scrollTop = maxHeight;
5183 }
5184 }, 0);
5185 return false;
5186 }
5187 return true;
5188 }
5189
5190 waitElement(doc, selArr) {
5191 if (!selArr) selArr = this.curSiteRule.waitElement;

Callers 1

waitElementMethod · 0.95

Calls 2

getElementFunction · 0.85
getBodyFunction · 0.70

Tested by

no test coverage detected