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

Function checkIframe

DownloadAllContent/DownloadAllContent.user.js:1265–1346  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1263 inited = true;
1264 clearTimeout(loadtimeout);
1265 async function checkIframe() {
1266 try {
1267 let doc = iframe.contentDocument || iframe.contentWindow.document;
1268 if (!doc || !doc.body) {
1269 setTimeout(() => {
1270 checkIframe();
1271 }, 1000);
1272 return;
1273 }
1274 doc.body.scrollTop = 9999999;
1275 doc.documentElement.scrollTop = 9999999;
1276 if (!processFunc && validTimes++ > 5 && failedTimes++ < 2) {
1277 loadIframe(iframe.src);
1278 validTimes = 0;
1279 inited = false;
1280 return;
1281 }
1282 let base = doc.querySelector("base");
1283 let nextPages = !disableNextPage && !processFunc && await checkNextPage(doc, base ? base.href : aTag.href);
1284 if (nextPages) {
1285 if (!nextPages.length) nextPages = [nextPages];
1286 nextPages.forEach(nextPage => {
1287 var inArr=false;
1288 for(var ai=0;ai<aEles.length;ai++){
1289 if(aEles[ai].href==nextPage.href){
1290 inArr=true;
1291 break;
1292 }
1293 }
1294 if(!inArr){
1295 nextPage.innerText=aTag.innerText+"\t>>";
1296 aEles.push(nextPage);
1297 let targetIndex = curIndex;
1298 for(let a=0;a<insertSigns.length;a++){
1299 let signs=insertSigns[a],breakSign=false;
1300 if(signs){
1301 for(let b=0;b<signs.length;b++){
1302 let sign=signs[b];
1303 if(sign==curIndex){
1304 targetIndex=a;
1305 breakSign=true;
1306 break;
1307 }
1308 }
1309 }
1310 if(breakSign)break;
1311 }
1312 let insertSign = insertSigns[targetIndex];
1313 if(!insertSign)insertSigns[targetIndex] = [];
1314 insertSigns[targetIndex].push(aEles.length-1);
1315 }
1316 });
1317 }
1318 downIndex++;
1319 downNum++;
1320 let validData = processDoc(curIndex, aTag, doc, "", failedTimes < 2);
1321 if (!validData) {
1322 downIndex--;

Callers 1

requestFunction · 0.70

Calls 4

loadIframeFunction · 0.85
checkNextPageFunction · 0.85
processDocFunction · 0.85
downOnceFunction · 0.85

Tested by

no test coverage detected