Advertisement
Guest User

Dynasty Scans Preload + Long Strip Bookmarklet (Sequential)

a guest
Aug 13th, 2023
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.50 KB | Source Code | 0 0
  1. javascript:
  2. (async () => {
  3.     let imageDiv = document.querySelector("#image");
  4.  
  5.     let linksDiv = imageDiv.appendChild(document.createElement("div"));
  6.     linksDiv.appendChild(document.querySelector("#image>.pages-list>#prev_link"));
  7.     linksDiv.appendChild(document.createTextNode("\xa0".repeat(40)));
  8.     linksDiv.appendChild(document.querySelector("#image>.pages-list>#next_link"));
  9.  
  10.     let pagesDiv = imageDiv.appendChild(document.createElement("div"));
  11.  
  12.     let numLoaded = 0;
  13.     let numLoadedDiv = imageDiv.appendChild(document.createElement("div"));
  14.     numLoadedDiv.textContent = `Loaded 0/${pages.length}`;
  15.  
  16.     let topButton = imageDiv.appendChild(document.createElement("div")).appendChild(document.createElement("button"));
  17.     topButton.textContent = "Scroll to Top";
  18.     topButton.onclick = () => {
  19.         window.scrollTo({top: 0, behavior: "smooth"});
  20.     };
  21.  
  22.     for (const node of document.querySelectorAll("#image>.pages-list, #image>.left, #image>.right, #image>img")) {
  23.         node.parentNode.removeChild(node);
  24.     }
  25.  
  26.     for (const page of pages) {
  27.         let newImg = document.createElement("img");
  28.         let imgDone = new Promise((resolve) => {
  29.             newImg.onload = newImg.onerror = resolve;
  30.         });
  31.         newImg.alt = page.name;
  32.         newImg.src = page.image;
  33.         pagesDiv.appendChild(document.createElement("div")).appendChild(newImg);
  34.         await imgDone;
  35.         numLoadedDiv.textContent = `Loaded ${++numLoaded}/${pages.length}`;
  36.     }
  37. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement