Dynasty Scans Preload + Long Strip (author: Nobody)
Overview:
I got annoyed by page load times recently and, being an engineer, spent a few hours making something to save a few minutes. I present: a bookmarklet that preloads an entire chapter. Just navigate to any page of a chapter, run the bookmarklet, and the single page shown in the reader will be replaced by a vertical scroll of every page in the chapter. (As a happy accident, this also stitches together longstrips.) Feel free to use and modify it as you please; also feel free to ask me questions, give me feedback, or let me know of any bugs you find.
How to use:
Create a bookmark, but where you would normally put a URL, instead put the "formatting-stripped bookmarklet URL" from below. Then, while on any page of any chapter on Dynasty, click the bookmark. Instead of navigating to a page, your browser will run the code you copied into the URL field.
When things go wrong:
-It will fail to load pages with a different page-to-filename relationship than the current one. For example, if the current page is "001" and "page001.png", it will fail to load a page of "credits" and "credits.png", as it will instead expect "pagecredits.png". (It will, however, try a few different file formats, so "1.png" and "2.jpg" will still work.)
-If Dynasty is in the middle of switching pages (you see "Loading..."), wait until it finishes. Running both scripts simultaneously may cause incorrect results.
-Any pages that fail to load will be displayed as text, so you can navigate to them normally in a different tab.
-Since all pages are loaded in parallel, it's possible for some pages to load completely before others even get sizing info. This can potentially cause page N and page N+2 to appear adjacent, visibly skipping page N+1 until it loads. Waiting until all visible pages are done loading makes it unlikely for this scenario to occur.
Nicely formatted code is hosted on pastebin
Formatting-stripped bookmarklet URL:
javascript:var%20pagesDiv=document.querySelector("#image");var%20starterImg=document.querySelector("#image>img");var%20pageName=encodeURIComponent(starterImg.alt);var%20pageIndex=starterImg.src.lastIndexOf(pageName,starterImg.src.lastIndexOf(".")-1);var%20genericSrc=starterImg.src.slice(0,pageIndex)+"#"+starterImg.src.slice(pageIndex+pageName.length);document.querySelectorAll("#image>.pages-list>.page").forEach((page)=>{var%20newImg=document.createElement("img");newImg.alt=page.innerText;newImg.src=genericSrc.replace("#",encodeURIComponent(page.innerText));newImg.retryFormats=[".png",".jpg",".jpeg",".gif"];newImg.onerror=()=>{if(newImg.retryFormats.length){newImg.src=newImg.src.slice(0,newImg.src.lastIndexOf("."))+newImg.retryFormats.shift();}};pagesDiv.appendChild(document.createElement("div")).appendChild(newImg);});document.querySelectorAll("#image>.left,#image>.right,#image>img,#image>.pages-list>.page").forEach((node)=>{node.parentNode.removeChild(node);});
last edited at Aug 5, 2022 5:56PM