Skip to content

Instantly share code, notes, and snippets.

@misaalanshori
Last active June 28, 2025 10:37
Show Gist options
  • Save misaalanshori/f4e3f4b1b753ff3de026bfec0ce56d6f to your computer and use it in GitHub Desktop.
Save misaalanshori/f4e3f4b1b753ff3de026bfec0ce56d6f to your computer and use it in GitHub Desktop.
Download All The Things!

Download All The Things!

Random scripts I've made to scrape stuff from websites, meant to be run from the dev console. I was storing this somewhere else and it was a mess.

(these may or may not need cors override, just try it and see it it fails)
(these may or may not work, since websites change and stuff, so no guarantees, you're on your own)

Directory

// Manga Park
// Uhhh, there's a lot of mangapark websites, I don't remember which one I made this one for. I made this a long time ago
function loadScript(src) {
return new Promise((resolve, reject) => {
// Check if the script is already loaded
const existingScript = document.querySelector(`script[src="${src}"]`);
if (existingScript) {
// Script already loaded, resolve immediately
resolve();
return;
}
// Create a script element and set the src
const script = document.createElement('script');
script.src = src;
script.async = true; // Ensure it loads asynchronously
// Resolve when the script is successfully loaded
script.onload = () => resolve();
// Reject the promise if there's an error loading the script
script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
// Append the script to the document head to start loading
document.head.appendChild(script);
});
}
async function main() {
await loadScript('https://cdn.jsdelivr.net/npm/[email protected]/dist/jszip.min.js');
const JSZip = window.JSZip;
const title = document.querySelector("div.comic-detail > h3 > a").innerText;
const chapter = document.querySelector("div.comic-detail > h6 > a").innerText;
// Example function to create a ZIP file of JPGs
async function createZipOfJPGs(jpgBlobs) {
const zip = new JSZip();
// Loop through the blobs and add them to the ZIP archive
jpgBlobs.forEach((blob, index) => {
// Get the file extension based on the blob's type
const fileType = blob.type.split("/")[1]; // Extracting the type (e.g., "jpeg" from "image/jpeg")
const fileExtension = fileType === "jpeg" ? "jpg" : fileType; // Default to jpg for jpeg
const fileName = page${index + 1}.${fileExtension}; // Naming the files with detected extension
zip.file(fileName, blob);
});
// Generate the ZIP file as a blob
const zipBlob = await zip.generateAsync({ type: "blob" });
// Create a download link to save the ZIP file
const downloadLink = document.createElement("a");
downloadLink.href = URL.createObjectURL(zipBlob);
downloadLink.download = `${title} - ${chapter}.zip`;
downloadLink.click();
}
const imgs = [...document.querySelectorAll("div.cursor-pointer > img.w-full.h-full")]
const imgblobs = await Promise.all(imgs.map(async v => {
const response = await fetch(v.src);
return await response.blob()
}))
await createZipOfJPGs(imgblobs)
// if (document.querySelectorAll("a.btn.btn-sm.btn-outline.btn-primary")[1]) {
// window.location.href = document.querySelectorAll("a.btn.btn-sm.btn-outline.btn-primary")[1].href
// }
}
main()
// Manga Plus by Shueisha
// https://mangaplus.shueisha.co.jp
// Note: You will have to scroll down all the way first to make sure everything is loaded
async function main() {
function loadScript(src) {
return new Promise((resolve, reject) => {
// Check if the script is already loaded
const existingScript = document.querySelector(`script[src="${src}"]`);
if (existingScript) {
// Script already loaded, resolve immediately
resolve();
return;
}
// Create a script element and set the src
const script = document.createElement('script');
script.src = src;
script.async = true; // Ensure it loads asynchronously
// Resolve when the script is successfully loaded
script.onload = () => resolve();
// Reject the promise if there's an error loading the script
script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
// Append the script to the document head to start loading
document.head.appendChild(script);
});
}
await loadScript('https://cdn.jsdelivr.net/npm/[email protected]/dist/jszip.min.js');
const JSZip = window.JSZip;
function canvasToBlob(canvas, type = 'image/jpeg', quality = 1) {
return new Promise((resolve, reject) => {
canvas.toBlob((blob) => {
blob ? resolve(blob) : reject(new Error('Canvas toBlob() failed'));
}, type, quality);
});
}
async function imageToBlob(image, type = 'image/jpeg', quality = 1) {
const canvas = document.createElement('canvas');
canvas.width = image.naturalWidth;
canvas.height = image.naturalHeight;
const ctx = canvas.getContext('2d');
ctx.drawImage(image, 0, 0);
return canvasToBlob(canvas, type, quality);
}
async function createZipOfJPGs(jpgBlobs, name = "file") {
const zip = new JSZip();
// Loop through the blobs and add them to the ZIP archive
jpgBlobs.forEach((blob, index) => {
// Get the file extension based on the blob's type
const fileType = blob.type.split("/")[1]; // Extracting the type (e.g., "jpeg" from "image/jpeg")
const fileExtension = fileType === "jpeg" ? "jpg" : fileType; // Default to jpg for jpeg
const fileName = `page${index + 1}.${fileExtension}`; // Naming the files with detected extension
zip.file(fileName, blob);
});
// Generate the ZIP file as a blob
const zipBlob = await zip.generateAsync({ type: "blob" });
// Create a download link to save the ZIP file
const downloadLink = document.createElement("a");
downloadLink.href = URL.createObjectURL(zipBlob);
downloadLink.download = `${name}.zip`;
downloadLink.click();
}
const title = document.querySelector(":has(a > h1) > a").innerText;
const chapter = document.querySelector(":has(a > h1) > div > p").innerText;
const imageElements = [...document.querySelectorAll(".zao-image")]
const imageBlobs = await Promise.all(imageElements.map(imageToBlob))
await createZipOfJPGs(imageBlobs, `${title} - ${chapter}`)
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment