Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

premium banner not going away. do i need to renew the extension? #55

Open
nadinelynch2600 opened this issue Dec 31, 2023 · 39 comments
Open

Comments

@nadinelynch2600
Copy link

i have been getting this:
do i need to update the version?

image

@nadinelynch2600
Copy link
Author

image
with the updated version, still the same. my browser settings hasn't changed since i have been using this app.

@KXTOD
Copy link

KXTOD commented Jan 1, 2024

Studocu has indeed changed their banner code. Open the studocu chrome extension folder -> Open remove-banner.js -> remove all code -> add this code:

window.addEventListener('load', function(){
	var banner = document.querySelectorAll('._95f5f1767857')[0]
	banner.remove()
	
	if (window.innerWidth <= 990){
		var pages = document.getElementById('page-container').childNodes;
		if(pages != null){
			for(i=0; i<pages.length; i++) {
				if(pages[i].id == ''){
					pages[i].parentNode.removeChild(pages[i]);
				}
			}
		}
	}
	
});

This will remove the banner for now. You can use this until the creator release a new update.

@imanol-af
Copy link

Hi, the upper fix helps to get rid of the banner and generate the preview, but the banner is still seen in the preview (for me):

image

@CLARC237
Copy link

CLARC237 commented Jan 8, 2024

same

Hi, the upper fix helps to get rid of the banner and generate the preview, but the banner is still seen in the preview (for me):

image

@KXTOD
Copy link

KXTOD commented Jan 11, 2024

@CLARC237 @imanol-af
Firstly, please add the document url you're trying to download, so I can try to fix it :)

Next: open doc-viewer.js in the stuhack folder
Remove these lines of code:

for(i=0; i<pages.length; i++){
	pages[i].childNodes[0].style = "display: block;";
}

Replace them with these:

for(i=0; i<pages.length; i++){
	var elm_id = pages[i].getAttribute('id')
	if (elm_id != null && elm_id.includes('pf')) {
		pages[i].childNodes[0].style = "display: block;";
	}
}

Let me know if it worked

@AppelSappie123
Copy link

Please add the document url you're trying to download, so I can try to fix it :)

https://www.studeersnel.nl/nl/document/middelbare-school-nederland/nederlands/nn6-3vwo-antwoorden/20482762
can you try to download this one please? its the Dutch version of Studocu,
thanks

@KXTOD
Copy link

KXTOD commented Jan 11, 2024

Please add the document url you're trying to download, so I can try to fix it :)

https://www.studeersnel.nl/nl/document/middelbare-school-nederland/nederlands/nn6-3vwo-antwoorden/20482762 can you try to download this one please? its the Dutch version of Studocu, thanks

The current version of the extension lets you download the files. Are you experiencing any problems with downloading?

@nadinelynch2600
Copy link
Author

image
the web page for what i am trying to view (this is just an example) https://www.studocu.com/en-us/document/university-of-the-people/calculus/graded-quiz-unit-6/11495948

@KXTOD
Copy link

KXTOD commented Jan 11, 2024

image

the web page for what i am trying to view (this is just an example) https://www.studocu.com/en-us/document/university-of-the-people/calculus/graded-quiz-unit-6/11495948

Did you add the code from this reply:

#55 (comment)

It works fine on my end

@nadinelynch2600
Copy link
Author

i did as best as i could.

@nadinelynch2600
Copy link
Author

image after all the codes and closing the browser and restarting it.

@nadinelynch2600
Copy link
Author

but if i split screen meaning that i drag the browser to the edge of my computer screen to make the screen in half it somehow works, but when i make to fill the screen it doesn't work

@KXTOD
Copy link

KXTOD commented Jan 11, 2024

Weird. I'm not familiar with Edge. Does this occur when you use Chrome? The code I have provided works for other users, so my guess it's something on your end.

@nadinelynch2600
Copy link
Author

@KXTOD yes and edge is a chromium based browser

@KXTOD
Copy link

KXTOD commented Jan 11, 2024

Can you show the file remove-banner.js?

@nadinelynch2600
Copy link
Author

nadinelynch2600 commented Jan 11, 2024 via email

@nadinelynch2600
Copy link
Author

image

@KXTOD
Copy link

KXTOD commented Jan 11, 2024

File seems good. Follow these steps:

  1. Open your document link
  2. Open devtools and open console
  3. Paste this in console:
var banner = document.querySelectorAll('._95f5f1767857')[0]
banner.remove()

Does this remove the banner?

@nadinelynch2600
Copy link
Author

where exactly is that?

@nadinelynch2600
Copy link
Author

nvm i know
i just forgot

@nadinelynch2600
Copy link
Author

image

@KXTOD
Copy link

KXTOD commented Jan 11, 2024

You need to paste them in one after another. Like this

var banner = document.querySelectorAll('._95f5f1767857')[0]

Press ENTER

banner.remove()

@nadinelynch2600
Copy link
Author

image

@nadinelynch2600
Copy link
Author

image
forgot the brackets

@KXTOD
Copy link

KXTOD commented Jan 11, 2024

Refresh the page and try again. I'm literally trying it on the document you are using and it works fine. Try using chrome and if that doesn't work I don't have a clue.

@nadinelynch2600
Copy link
Author

image

@nadinelynch2600
Copy link
Author

after a few tries i managed to get it working but it looks like may have to do that with every document, but i got it to work, i looked at the codes you gave me and i looked at mine and i have noticed that i made several errors in my typing which i tried and tried again until i got it to work.

image

@nadinelynch2600
Copy link
Author

i think i fixed it now! i made those codes in a js file and when i clicked on refresh on the extension, I tried it on a different document and it works

@nadinelynch2600
Copy link
Author

image
without typing the codes into devtools

@nadinelynch2600
Copy link
Author

image
my file that i created and added it to the same extension pack as before. and it works wonders.

@nadinelynch2600
Copy link
Author

@KXTOD thank you for the help, i enjoyed this troubleshooting session here, lol. oddly enough, i learnt something from you today lol thank you again.

i am going to keep this thread open for others to use.

@KXTOD
Copy link

KXTOD commented Jan 11, 2024

@KXTOD thank you for the help, i enjoyed this troubleshooting session here, lol. oddly enough, i learnt something from you today lol thank you again.

i am going to keep this thread open for others to use.

No problem! Glad I could help and don't hesitate to ask any more questions. Cool to hear you learned something :)

@imanol-af
Copy link

@KXTOD

So I just tried the suggestions you gave Nadine and still can't get it to work.
The Banner appears inside the preview even if it isn't present in the main window.

The URL I'm trying is: https://www.studocu.com/de/document/technische-universitat-munchen/adaptive-and-array-signal-processing/aasp-lecture-notes/23502408

Contents of:
-------------doc-viewer.js-------------------------------
function downloadDoc(){
var head = document.getElementsByTagName("head")[0].innerHTML;
var tit = document.getElementsByTagName("h1")[0].innerHTML;
var pages = document.getElementById('page-container').childNodes;

width = pages[0].offsetWidth;
height = pages[0].offsetHeight;

if (width > height){
	print_opt = "{@page {size: A5 landscape;} body {zoom: 90%;}";
}else{
	print_opt = "{@page {size: A5 portrait;}";
}

for(i=0; i<pages.length; i++){
    var elm_id = pages[i].getAttribute('id')
    if (elm_id != null && elm_id.includes('pf')) {
        pages[i].childNodes[0].style = "display: block;";
    }
}   

var pdf = pages[0].parentNode.parentNode.parentNode.innerHTML;

newWindow = window.open("", "Document", "height=865,width=625,status=yes,toolbar=no,menubar=no");  
newWindow.document.getElementsByTagName("head")[0].innerHTML = head + "<style> .nofilter{filter: none !important;} </style>" + "<style> @media print " + print_opt + "</style>";
newWindow.document.title = tit;
newWindow.document.getElementsByTagName("body")[0].innerHTML = pdf;
newWindow.document.getElementsByTagName("body")[0].childNodes[0].style = "";

}

function addButtons(){
button1 = document.createElement("button");
button1.classList.add("download-button-1");
button1.innerHTML = 'Download';

let prev_buttons = document.getElementsByClassName("fa-cloud-arrow-down");
let i = 0;
buttons = [];
while(prev_buttons.length > 0){
	if(prev_buttons[0].parentNode.parentNode.firstChild.classList.contains("download-button-1")){
		prev_buttons[0].parentNode.remove();
	}else{
		buttons.push(button1.cloneNode(true, true));
		buttons[i].onclick = function() {downloadDoc()};
		prev_buttons[0].parentNode.parentNode.prepend(buttons[i]);
		prev_buttons[0].parentNode.remove();
		i++;
	}
	prev_buttons = document.getElementsByClassName("fa-cloud-arrow-down");
}

}

var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
addButtons();
});
});

window.addEventListener('load', function(){
const prev_buttons = document.getElementsByClassName("fa-cloud-arrow-down");
if(prev_buttons.length > 0) {
try{
addButtons();
}catch(err){
console.log(err);
}finally{
let element = document.getElementById("viewer-wrapper");
observer.observe(element, { attributes: true, childList: true, subtree: true});
}
}
});

-------------remove-banner.js-------------------------------
window.addEventListener('load', function(){
var banner = document.querySelectorAll('._95f5f1767857')[0]
banner.remove()

if (window.innerWidth <= 990){
	var pages = document.getElementById('page-container').childNodes;
	if(pages != null){
		for(i=0; i<pages.length; i++) {
			if(pages[i].id == ''){
				pages[i].parentNode.removeChild(pages[i]);
			}
		}
	}
}

});

Thanks again for the help!

@imanol-af
Copy link

Sorry for the weird formatting.

@chrisfeldkircher
Copy link

chrisfeldkircher commented Jan 15, 2024

This code worked for me

window.addEventListener('load', function() {
    var banners = document.querySelectorAll('div.banner-wrapper');
    banners.forEach(function(banner) {
        banner.remove();
    });

    if (window.innerWidth <= 990) {
        var pages = document.getElementById('page-container').childNodes;
        if (pages != null) {
            for (var i = 0; i < pages.length; i++) {
                if (pages[i].nodeType === Node.ELEMENT_NODE && pages[i].id === '') {
                    pages[i].parentNode.removeChild(pages[i]);
                }
            }
        }
    }
});

@lol98lol98x
Copy link

 var elementToRemove = document.querySelector('#document-wrapper > div:nth-child(2) > div._95f5f1767857._0838fb325c04');
    if (elementToRemove) {
        elementToRemove.parentNode.removeChild(elementToRemove);
    }

i added that into remove-banner.js after it gets the document-wrapper id
fixed it for me

@imanol-af
Copy link

 var elementToRemove = document.querySelector('#document-wrapper > div:nth-child(2) > div._95f5f1767857._0838fb325c04');
    if (elementToRemove) {
        elementToRemove.parentNode.removeChild(elementToRemove);
    }

i added that into remove-banner.js after it gets the document-wrapper id fixed it for me

This worked perfectly; thank you very much!

@danieltyukov
Copy link

https://github.com/danieltyukov/studocuhack
checkout the most latest version of a better extension to solve this problem.

@Lucozadeenergy
Copy link

 var elementToRemove = document.querySelector('#document-wrapper > div:nth-child(2) > div._95f5f1767857._0838fb325c04');
    if (elementToRemove) {
        elementToRemove.parentNode.removeChild(elementToRemove);
    }

i added that into remove-banner.js after it gets the document-wrapper id fixed it for me

This worked perfectly; thank you very much!

where exactly did you add the second code? ive managed to get the banner off the main page but not the preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants