Giter Site home page Giter Site logo

stuhack's People

Contributors

isanchop avatar pradeep1409 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stuhack's Issues

Print to PDF is not working properly

While the preview of the document to be downloaded is displayed correctly in the new tab, printing to PDF does not render correctly.
One image plus one quarter of the next image are printed on the same page.
Eliminating the margins and increasing the scale to 120% gives an acceptable result.

can't download the documents

When I click to download doesn't open the other tab to ctrl+p save. It just pop up to upgrade studocu. I tried to remove and reinstall other browser but nothing

Bad print Pdf

Hi, sometimes ago i notice that all pdf i try to downlod present some imperfection like: word trasparent or part of html from the original document (like the Premium Banner ) inside the pdf. How i can fix that?
I would also say this tool is very useful, so good job guys @isanchop @Pradeep1409

Not an issue

Thank you for savin my life kind soul.
God bless!

STATUS_BREAKPOINT error for content heavy documents

Screenshot 2023-12-27 165308

I keep seeing this error when trying to print a 165 page document. I scroll down the whole way to the bottom of the page, I press download, and then I try to print using Ctrl+P. Then it crashes. Any ways to fix this?

White Screen

There's been a new update with Chrome, and whenever I try to open Studocu, the screen goes blank after a few seconds.

[Fix] Blur and AD Message #39 #40 #41

Fix for issue #39 #40 #41

To exchange the idea and for enlighten the discussion, I purpose a potential way to resolve this issue. I have no intention to infringe any rules. The blur effect is base on monitoring the CSS of page-content, in this way any change to the page-content style will lead to a overwrite to the style. However, there is no monitor of the sub-div. You may run the code in console to validate the effectiveness.

Before

image

After

image

If the document has multiple pages, remember to scroll all the way down before execute the code. Otherwise, due to the pages are loaded when you read them, the script will not be able to remove blur before it's loaded from server.

// Remove Blur
const blurNodes = document.querySelectorAll('.page-content');
for (let i = 0; i < blurNodes.length; i++) {
  if (blurNodes[i].hasChildNodes() && blurNodes[i].style["filter"] != "") {
    console.log("[Info] Processing Page", i+1, "...")
    myDiv = blurNodes[i].firstChild;
    if (myDiv.firstChild.nodeName == 'IMG') {
      console.log("[Failed] Page", i+1, "is an image.")
    } else {
      blurNodes[i].parentNode.append(myDiv);
      blurNodes[i].removeChild(blurNodes[i].firstChild);
      console.log("[Success] Removed Blur on Page", i)
    }
  }
}

// Remove Notices
const bannerNodesA = document.querySelectorAll('.banner-wrapper');
for (let i = 0; i < bannerNodesA.length; i++) {
    bannerNodesA[i].parentNode.removeChild(bannerNodesA[i]);
}

const bannerNodesB = document.querySelectorAll('._60e676a00207');
for (let i = 0; i < bannerNodesB.length; i++) {
    bannerNodesB[i].parentNode.removeChild(bannerNodesB[i]);
}

const blurNotice = document.querySelectorAll('._869f7c361ca9');
for (let i = 0; i < blurNotice.length; i++) {
    blurNotice[i].parentNode.removeChild(blurNotice[i]);
}

blur page

is there the possibility to unblur the page now that they add this new feature that we cant see some pages?

Manifest Unreadable Error

I installed the extension with the zip file following the instructions in the readme.md
1) Git clone or download file and unzip on a folder 2) Go to the extensions tab on google chrome (chrome://extensions/) 3) Enable "Developer mode" on the top right of the tab 4) Press on "Load unpacked" new feature that appeared on top left corner 5) Browse the path you downloaded the extension and choose select 6) Enjoy :)

After clicking developer mode and clicking 'Load unpack' i got this error message,

Failed to load extension
File
~\Downloads\stuhack
Error
Manifest file is missing or unreadable
Could not load manifest`

I've tried deleting and redownloading the zip file but to no avail, any idea what could be happening?

Question

After I downloaded the extension on chrome, how do I use it to download the documents? I still have the premium blocks on my web. I can't click on the chrome extension on the document viewing page.

Download button doesn't work

The download button is not working. I found it's because the array prev_buttons in the file doc-viewer.js has only 2 elements and the code is accessing position 2 and 3, so it crashes.

image

Removing this two lines solves the issue:

prev_buttons[2].parentNode.parentNode.prepend(button2);
prev_buttons[3].parentNode.parentNode.removeChild(prev_buttons[3].parentNode);

I guess there's only two buttons now.

Large "preview banner" being printed on some pages

Seems like Studocu has figured out how to place a large banner when printing files to PDF.

Fortunately the notes are still visible on the web, but the PDF will have a large banner on some (but not all) of the pages. I have attached a 3-page document as an example. The banner is on pg. 3.

A larger document it starts at pg. 3 and then shows up on alternating pages.
Procedural Fairness.pdf

Greyed out document text

Hello, appreciate all your hard work.

Just wanted to note, that the text has now become greyed out by default instead of the original black font colour when saving documents.

Error can't use extension

Hi i got an error and the extension is greyed out

Uncaught TypeError: Cannot read properties of undefined (reading 'parentNode')

Stack Trace
version-check.js:13 (anonymous function)

This line was highlighted in chrome:
up_buttons[0].parentNode.parentNode.insertBefore(button_cv, up_buttons[0].parentNode.parentElement.children[3]);

Stack Trace
remove-banner.js:10 (anonymous function)

This line was also highlighted:
premiumButton.parentNode.removeChild(premiumButton);

Doesn't download...

Good morning, first of all thanks for your work! However i have a problem. When i'm on studocu and i click to "download" it redirects me on the website that ask me to have a Premium Account. Why? Thanks!

Print not working properly

Hi guys, i happen to bump into some issues i'd like to talk about:

  1. Viewing document after pressing download works just fine, but in the print preview, some parts of the document went blank, after downloading the document has those same blank spaces too.
  2. Some part of the document is repeated

(notably the errors occur mostly at the end of some pages)

I hope you guys can fix this soon. Thank you !

Button download don't work

Hi,

Thank you for you work, i love your extension, but with the version 0.4.5 the button download don't work.

I see all the document without blur, but i can't download it.

I hope you will fix it,

Thank you!

Version for Userscript

Hello, thanks for doing this project. Can you write a userscript version? Thank you very much

Error printing document, only first page appears

Hello
I am attempting to print a 8-page document, but when I try print to PDF it only prints the first page and the other 7 pages are blank.
In the preview I am able to see all the other pages and the text just not print them with the text.

Please help :(

Needs update

Chrome cannot identify the working files in the extensions tab. Please update.

Download button not working

Hey, when I press on the download button nothing happens, no popup at all.
Using the 0.4.5 Version under chrome

How do I actually download the document?

I got a 241 page document and when i click download a new page pops up with the document. However i dont know if theres a way to download the document or do I have to download all 241 pages one at a time?

Question

Hi,

Stuhack is one of the best things a student can have and I'm really grateful for it! There is no problem and everything is working perfectly. I just had a question and I didn't know how to contact you. I'm from Belgium and although Studocu is also a big platform here, we mainly use another website called stuvia.be . The way the website works is a bit different than Studocu, you pay per item you want to download instead of a fixed price per month. I was wondering if you would be interested in making a similar tool as Stuhack for stuvia.be. If you are interested, please let me know so we can look into this. I would also have no problem paying you for it! Hope to hear from you soon.

Cant Download

Hi

Just installed this, when i click download there's a popup saying ''Download this document?
Upload your study materials to download all documents.'' "Upload to unlock documents''

So not sure what to do, thought the extension removes the popup

Manifest file error

Hello! Thanks for your work.
But I have a problem, when I add the extension to chrome there is an error about manifest and it doesn't work. It says "Manifest version 2 is deprecated, and support will be removed in 2023."
Is there anything you can do about this?

[Fix] Python script to download documents that are using blurred images

Some documents implement blurred images (https://d3tvd1u91rr79.cloudfront.net/a2aa9a4720ce8e5692f963a70e3cfcc9/html/pages/blurred/page3.webp...). This can be bypassed simply by removing the /blurred/ from the Cloudfront URL.

This means that the StuHack extension does not work for these documents, since StuHack currently relies on client-side blurring with the CSS style filter: blur(2px) and simply undoing that blurring. I wrote a Python script that when given a URL, it will save the document as a PDF by identifying the Cloudfront CDN URL and constructing a non-blurred URL path.

from typing import List, Tuple

import requests
from PIL import Image
from io import BytesIO
import re

def get_total_pages(document_link: str) -> int:
    r = requests.get(document_link, headers={"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9"})
    regex = r'data-page-no=\\\"([0-9a-f]+)\\\"'
    matches = re.findall(regex, r.text, re.IGNORECASE)
    total_pages = max(int(match, 16) for match in matches)
    return total_pages

def get_image_info(document_link: str) -> Tuple[str, str, str]:
    r = requests.get(document_link, headers={"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9"})
    regex = r'src="https://(?P<subdomain>[\w.-]+)\.cloudfront\.net/(?P<identifier>[\w.-]+)/html/bg1\.png\?Policy=(?P<policy>[^"]+)"'
    matches = re.search(regex, r.text, re.IGNORECASE)
    if matches:
        subdomain = matches.group("subdomain")
        identifier = matches.group("identifier")
        policy = matches.group("policy").replace("&amp;", "&")
        return subdomain, identifier, policy
    else:
        raise ValueError("Image information not found in the document link.")

def download_images(subdomain: str, identifier: str, policy: str, total_pages: int) -> List[Image.Image]:
    images = []
    for i in range(1, total_pages + 1):
        url = f"https://{subdomain}.cloudfront.net/{identifier}/html/pages/page{i}.webp?Policy={policy}"
        r = requests.get(url, allow_redirects=True)
        try:
            images.append(Image.open(BytesIO(r.content)))
        except Exception as e:
            raise ValueError(f"Failed to download page {i}. Looks like this document is using client-side blurring-- try using the StuHack Chrome extension instead.")
        print(f"[~] Downloaded page {i} of {total_pages}")
    return images

def save_document(output_file: str, images: List[Image.Image]) -> None:
    if images:
        images[0].save(output_file, save_all=True, append_images=images[1:])
        print(f"[+] Document saved to {output_file}")
    else:
        raise ValueError("No images found.")

def main() -> None:
    document_link = input("Enter the link to the document: ")
    if "studocu" not in document_link:
        print("Invalid link")
        return

    output_file = input("Enter the output file name (e.g., output.pdf): ")

    try:
        total_pages = get_total_pages(document_link)
        print(f"[+] Identified {total_pages} pages in the document.")
        subdomain, identifier, policy = get_image_info(document_link)
        images = download_images(subdomain, identifier, policy, total_pages)
        save_document(output_file, images)

    except Exception as e:
        print(f"[-] An error occurred: {e}")

if __name__ == "__main__":
    main()

You'll need to install requests, Pillow, and typing.
pip install requests pillow typing

Thought I would leave this here for whoever needs it, since I know there are a few issues open regarding the extension not working.

TL;DR

  • Some documents utilize image blurring on the backend rather than the client-side filter: blur(2px)
  • Try the StuHack extension first. If it doesn't work, the document is probably using blurred images
  • If the extension doesn't work, try this Python script

I was thinking of making a PR to help integrate this into StuHack, but my Javascript knowledge is pretty lacking. I also don't know my way around a lot of the Web API stuff and noticed there's some things StuDocu does like if the filter: blur(2px) gets removed, it gets added back. Figured some folks smarter than me could implement my logic into the extension to make it support both types of documents.

Chrome PDF export landscape orientation missing

I tried printing a document in landscape mode, but chrome didn't provide the option.
I found this thread suggesting using the style

@page {
        size: auto;
    }

The option for the landscape mode shows up when applied as described in the linked post.


Here you are using the style

@page {
        size: A5;
    }

, which currently doesn't work.
Should I open a pull request or is there a reason for A5 being used as size?

Download does not work

Top right Download button is inactive and gives an error in Chrome extensions

up_buttons[0].parentNode.parentNode.insertBefore(button_cv, up_buttons[0].parentNode.parentElement.children[3]);

Download Content blocked out

Hey,
I downloaded the latest version, installed it in Chrome and unfortunately it doesn't work. (In print menu only headings no content visible).
I have read through the old discussions and examined the code after the adjustments and could not find any error.
So I tried the add-on while I was logged in and even if not.
Is there any other source of error I could investigate or is the site more up to date than the add-on?

Thank you very much for your effort!
Screenshot

Crash "Out of memory" after CTRL+P, cannot save files as pdf

As the title says, I cannot save the files as pdf after opening them on the page after clicking on download.
The page opens, continues in an endless loading and then crashes in "out of memory" error page, I have tried on different computers but get the same result.
The problem that was present in 0.4.6 that only displayed the first page has disappeared.
Excellent work, keep going!

Cannot download PDF file

Hello I cannot download PDF file, it opens on a separate window which allows me to view the document but when i hit print, I cannot scale to full page PDF.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.