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

Method verifyNext

Pagetual/pagetual.user.js:6590–6621  ·  view source on GitHub ↗
(next, doc, isJs)

Source from the content-addressed store, hash-verified

6588 }
6589
6590 verifyNext(next, doc, isJs) {
6591 if (!next) return null;
6592 if (!isJs) {
6593 let href = next.getAttribute("href");
6594 if (href && !/\d/.test(next.getAttribute("href"))) {
6595 return null;
6596 }
6597 }
6598 if (next.previousElementSibling && compareNodeName(next.previousElementSibling, ["br"])) return null;
6599 let eles = [];
6600 if (next.innerText && next.innerText.indexOf("\n") === -1) {
6601 eles = getAllElements(`//${next.nodeName}[text()='${next.innerText}']`, doc);
6602 }
6603 if (eles.length >= 2 && eles[0].href !== eles[1].href) {
6604 next = null;
6605 } else if (doc === document && next.offsetParent) {
6606 let left = getElementLeft(next);
6607 if (left < 20 || (document.documentElement.scrollWidth > 500 && left < 250)) {
6608 next = null;
6609 } else {
6610 let top = getElementTop(next);
6611 if (top < 20 || (left < window.innerWidth / 3 && top < window.innerHeight / 3)) {
6612 next = null;
6613 } else {
6614 let bottom = top + next.offsetHeight || 0;
6615 let scrollH = Math.max(document.documentElement.scrollHeight, getBody(document).scrollHeight);
6616 if (scrollH - bottom < 10) next = null;
6617 }
6618 }
6619 }
6620 return next;
6621 }
6622
6623 canonicalUri(src) {
6624 if (!src) {

Callers 1

getPageMethod · 0.95

Calls 5

compareNodeNameFunction · 0.85
getAllElementsFunction · 0.85
getElementLeftFunction · 0.85
getElementTopFunction · 0.85
getBodyFunction · 0.70

Tested by

no test coverage detected