Pagetual

Perpetual pages - powerful auto-pager script. Auto fetching next paginated web pages and inserting into current page for infinite scroll. Support thousands of web sites without any rule.

< Feedback on Pagetual

Review: Good - script works

§
Posted: 2022-11-05
Edited: 2022-11-05

這個站遇到問題

    {
        "name": "肉漫屋 - 閱讀 - action: 1",
        "example": "https://rouman5.com/books/354b56da-1ab9-4909-9330-743842c5a5bf/0",
        "url": "^https?://rouman[0-9]{1,2}\\.[a-z]{3}/books/[^/]+/",
        "action": 1,
        "nextLink": "//a[text()='下一頁']",
        "pageElement": "//div[div/img[@id]]",
        "replaceElement": "div[class^='id_pagination']"
    },
    {
        "name": "肉漫屋 - 閱讀 - action: 2",
        "example": "https://rouman5.com/books/354b56da-1ab9-4909-9330-743842c5a5bf/0",
        "url": "^https?://rouman[0-9]{1,2}\\.[a-z]{3}/books/[^/]+/",
        "action": 2,
        "nextLink": "//a[text()='下一頁']",
        "pageElement": "//div[div/img[@id]]",
        "replaceElement": "div[class^='id_pagination']",
        "pageAction": "function $x(xpath, context) {\r\nvar nodes = [];\r\ntry {\r\nvar doc = (context && context.ownerDocument) || window.document;\r\nvar results = doc.evaluate(xpath, context || doc, null, XPathResult.ANY_TYPE, null);\r\nvar node;\r\nwhile (node = results.iterateNext()) {\r\nnodes.push(node)\r\n}\r\n} catch (e) {\r\nthrow e;\r\n}\r\nreturn nodes\r\n}\r\nlet p = $x(\"//div[contains(@id,'pagetual_pageBar')]\");\r\nif (p.length > 1) {\r\n$x(\"//div[div/img[@id]]/preceding-sibling::*[not(contains(@class,'id_pagination'))]\").forEach(e => {\r\ne.remove()\r\n })\r\nif ($x('//div[div/img[@id]]').length > 0) {\r\n$x('//div[div/img[@id]]')[0].remove()\r\n}\r\n$x('//iframe')[0].remove();\r\ndocument.querySelector('.pagetual_pageBar').remove()\r\n}",
        "pageBarText": 1,
        "css": "inIframe:nav.navbar,#__next>div[class^='footer'],.row,div[class^='id_pagination']{display:none!important}.container{padding-right:0px!important;padding-left:0px!important;max-width: 700px!important;}"
    }

這個站比較特殊,他的圖片網址數據在__NEXT_DATA__.props.pageProps.images
但是圖片本身是亂的...,會再經過運行函數重新分割裁剪排列成正常的圖片。

action: 1模式下會沒有運行該有的函數就會插入,圖片載入不全部份圖片順序混亂。

規則添加這樣會等待不到完成
"waitElement": [
"",
"img[src*='loading']"
],

然後改用action: 2的情況
在上面提供的漫畫連結,翻2~5話正常,從第6話開始插入的iframe的style的height是0px;,導致看不到內容。


順便紀錄一下插入整章圖片的代碼
let imgs = __NEXT_DATA__.props.pageProps.images;
let _img = '';
for (let i = 0; i <= imgs.length-1; i++) {
_img += ``
};
document.querySelector('.row+div').innerHTML = _img;

hoothinAuthor
§
Posted: 2022-11-05

多謝反饋,第6話異常是因爲你把前面的iframe刪掉了,所以動態調整iframe高度的代碼就報錯了。已經修復了。
至於waitElement,其實是可以的,只是要等待很長一段時間。因爲這個站裏面的圖片是必須完整加載完成才會插入,而正常情況之下只需要加載視野内的一張所以快很多。

hoothinAuthor
§
Posted: 2022-11-05

另外這個站的圖片不是img,而是img裁切之後在canvas上面重繪的,所以單獨取img是會亂掉的

§
Posted: 2022-11-05

多謝反饋,第6話異常是因爲你把前面的iframe刪掉了,所以動態調整iframe高度的代碼就報錯了。已經修復了。
至於waitElement,其實是可以的,只是要等待很長一段時間。因爲這個站裏面的圖片是必須完整加載完成才會插入,而正常情況之下只需要加載視野内的一張所以快很多。

哈哈原來是我的錯,自動刪除是我一直想實現的功能,昨天才寫出我滿意的代碼,手機滑漫畫一直插入新內容,內容如果太長的話一些網站的浮動工具列會失效出不來,所以就想說維持3話左右的內容,再多就把前面的刪除,連續滑個上百話也沒問題。

最後感謝大大的修復

Post reply

Sign in to post a reply.