|
10 | 10 | // @name:it Pagetual |
11 | 11 | // @name:ko 東方永頁機 |
12 | 12 | // @namespace hoothin |
13 | | -// @version 1.9.26.6 |
| 13 | +// @version 1.9.26.7 |
14 | 14 | // @description Perpetual pages - Most powerful Auto Pager script. Auto loading next paginated web pages and inserting into current page. |
15 | 15 | // @description:zh-CN 自动翻页脚本 - 自动加载并拼接下一分页内容,无需规则驱动支持任意网页 |
16 | 16 | // @description:zh-TW 自動翻頁脚本 - 自動加載並拼接下一分頁內容,無需規則驅動支持任意網頁 |
|
1171 | 1171 | } |
1172 | 1172 | } |
1173 | 1173 | }else{ |
1174 | | - return url.replace(/.*[&\/\?](p=|page[=\/_-]?)(\d+).*/i, "$2").replace(/.*[_-](\d+)\..*/i, "$1"); |
| 1174 | + let pageNum=url.replace(/.*[&\/\?](p=|page[=\/_-]?)(\d+).*/i, "$2"); |
| 1175 | + return pageNum==url?curPage:pageNum; |
1175 | 1176 | } |
1176 | 1177 | return curPage; |
1177 | 1178 | } |
|
3329 | 3330 | if(pageEle.length > 1){ |
3330 | 3331 | targetElement = targetElement.parentNode; |
3331 | 3332 | } |
| 3333 | + if(parseInt(iframe.style.height)==targetElement.scrollHeight) return; |
3332 | 3334 | iframe.style.height=targetElement.scrollHeight+"px"; |
3333 | 3335 | frameDoc.documentElement.scrollTop = 0; |
3334 | 3336 | frameDoc.documentElement.scrollLeft = 0; |
|
3351 | 3353 |
|
3352 | 3354 | function forceIframe(url, callback){ |
3353 | 3355 | url=url.replace(/#[^#]*/,""); |
3354 | | - let curIframe = document.createElement('iframe'),iframeDoc; |
3355 | | - let setPosition = ()=>{ |
| 3356 | + let curIframe = document.createElement('iframe'),iframeDoc,isloaded=false,inAction=true; |
| 3357 | + let loadedHandler = ()=>{ |
| 3358 | + inAction=false; |
| 3359 | + if(isloaded)return; |
| 3360 | + isloaded=true; |
| 3361 | + ruleParser.insertPage(iframeDoc, [], url, null, true); |
| 3362 | + callback(curIframe, true); |
3356 | 3363 | let getIframe = () => { |
3357 | 3364 | return curIframe; |
3358 | 3365 | }; |
|
3386 | 3393 | callback(false, false); |
3387 | 3394 | return; |
3388 | 3395 | } |
3389 | | - ruleParser.insertPage(iframeDoc, [], url, null, true); |
3390 | | - callback(curIframe, true); |
3391 | 3396 | let css=ruleParser.curSiteRule.css; |
3392 | 3397 | if(css){ |
3393 | 3398 | let styleEle=iframeDoc.createElement("style"); |
3394 | 3399 | styleEle.innerHTML=css; |
3395 | 3400 | iframeDoc.head.appendChild(styleEle); |
3396 | 3401 | } |
3397 | | - setPosition(); |
| 3402 | + loadedHandler(); |
3398 | 3403 | let code=ruleParser.curSiteRule.init; |
3399 | 3404 | if(code){ |
3400 | 3405 | try{ |
|
3404 | 3409 | } |
3405 | 3410 | } |
3406 | 3411 | }); |
3407 | | - let inAction=false,checkTimes=0; |
| 3412 | + let checkTimes=0; |
3408 | 3413 | let forceRefresh=e=>{ |
3409 | 3414 | if(inAction || !iframeDoc)return; |
3410 | 3415 | inAction=true; |
|
3418 | 3423 | ruleParser.getNextLink(iframeDoc); |
3419 | 3424 | if(ruleParser.nextLinkHref){ |
3420 | 3425 | foundNext(); |
| 3426 | + }else if(checkTimes>=5){ |
| 3427 | + let pageElement = ruleParser.getPageElement(iframeDoc,iframeDoc.defaultView); |
| 3428 | + if (!pageElement){ |
| 3429 | + inAction=true; |
| 3430 | + curIframe.contentWindow.location.reload(); |
| 3431 | + } |
3421 | 3432 | }else if(checkTimes>=10){ |
3422 | 3433 | foundNext(); |
3423 | 3434 | } |
|
0 commit comments