Skip to content

Instantly share code, notes, and snippets.

@blueset
Last active July 23, 2024 04:42
Show Gist options
  • Save blueset/3034bcbd6167fd145cee915e36f5aab4 to your computer and use it in GitHub Desktop.
Save blueset/3034bcbd6167fd145cee915e36f5aab4 to your computer and use it in GitHub Desktop.
Download/Print StuDocu.com documents without watermark

Usage

Add StuDocu Extracter to your Browser favorites, and click on it after you open the StuDocu document.

How it works

javascript:(function(){var a = "", x = document.getElementsByTagName("svg"); for(var i = 0; i < x.length; i++){a += x[i].outerHTML;} document.getElementsByTagName("body")[0].innerHTML = a;var a = document.getElementsByTagName("svg");for (var i = 0; i < a.length; i++){a[i].style.width="99.8%";a[i].style.height="auto";a[i].style.position="inherit";a[i].style.display="block";a[i].style.boxShadow="0 3px 3px rgba(0,0,0,0.3)";a[i].style.padding="0";}})()

Extract out all SVG tags and arrange it for printing.

Known issues:

  • Only work with unified page size.
  • Only work with fully accessable document.
  • Need to turn on No border width option when printing.
@kinslayeruy
Copy link

kinslayeruy commented Mar 9, 2022

Managed to find a workaround for firefox

function getCSSSelector(el) {
    let selector = el.tagName.toLowerCase();
    const attrs = el.attributes
    for (var i = 0; i < attrs.length; i++) {
        let attr = attrs.item(i)
        if (attr.name === 'id') selector += `#${attr.value}`;
        if (attr.name === 'class') selector += attr.value.split(' ').map((c) => `.${c}`).join('');
        if (attr.name === 'name') selector += `[${attr.name}=${attr.value}]`;
    }
    return selector
}

function next(container) {
	let childs = container.childNodes;
	let child = childs[index];
  child.scrollIntoView();
  let selector = getCSSSelector(child);
  console.log(selector);
  console.log(`remaining ${childs.length - index}`);
  index++;
  return `:screenshot --file true --selector ${selector}`;  
}

let index = 0;
let pageContainer = document.getElementById("page-container");
//usage in firefox
// copy(next(pageContainer))
// paste command copied and hit enter

just paste the code in the developer console
I recommend using said console to remove all elements on the top, and the side, so the view area is bigger. also, you can zoom in (ctrl+scrollwheel) and then use the fit height button on the studocu navigator, so it will take screenshots with better quality

only works on public documents, it won't access any page you can't see by yourself

works by using the copy() helper to copy into clipboard and the :screenshot helper to take a screenshot of a node
it will spam your downloads folder with the screenshots, you can print them all later to pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment