Skip to content

Instantly share code, notes, and snippets.

@ivancea
Last active March 5, 2024 18:35
Show Gist options
  • Save ivancea/b2679091db9429021f1296c63f3c0c1a to your computer and use it in GitHub Desktop.
Save ivancea/b2679091db9429021f1296c63f3c0c1a to your computer and use it in GitHub Desktop.
Studocu document downloader (Not working anymore, now it shows blurred images instead)
/*
1. Scroll down the full document. Let images load, if any
2. Execute this script: Open the console with F12, paste this script there, and press Enter
3. Print the document to PDF, with a scale of 115% (Maybe tweak it, depending on the document)
*/
(function doIt() {
const pageContainer = document.getElementById("page-container");
const pages = pageContainer.querySelectorAll(".pf > .page-content > .pc");
const root1 = document.createElement("div");
const root2 = document.createElement("div");
const root3 = document.createElement("div");
const root4 = document.createElement("div");
const container = document.createElement("div");
root1.classList.add("p2hv");
root1.style.width = "fit-content";
root1.style.position = "relative";
root2.id = "page-container";
root2.style.width = "fit-content";
root2.style.position = "relative";
root3.style.backgroundColor = "white";
root3.style.width = "fit-content";
root3.style.position = "relative";
root4.classList.add("pc");
root4.style.position = "relative";
root4.style.width = "fit-content";
container.style.width = "fit-content";
pages.forEach((page) => {
// All direct children but "bi" class
const children = page.querySelectorAll(":scope > :not(.bi)");
const pageContainer = document.createElement("div");
pageContainer.classList.add("w0", "h0");
pageContainer.style.position = "relative";
pageContainer.style.pageBreakAfter = "always";
children.forEach((child) => {
pageContainer.appendChild(child);
});
container.appendChild(pageContainer);
});
root4.appendChild(container);
root3.appendChild(root4);
root2.appendChild(root3);
root1.appendChild(root2);
document.body.innerHTML = "";
document.body.appendChild(root1);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment