-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
could you make scrollbar on the right hidden as it's a bit distracting when watching videos and a video web page is not that long to need it. [youtube classic] #106
Comments
Can you disable the script, then screenshot what you mean? |
Hey @mhwgoo when I refresh it stays square, what browser and userscript manager are you using? Also do you think it should hide Shorts? |
I've been using qutebrowser recently, and I put your script under I dont' know about others, but I never watch Shorts, and I'd like it to be hidden. BTW, it'd be great if ad nodes could be deleted and not rendered (instead of hidden). I wrote a little something: window.addEventListener('animationstart', function() {
'use strict';
var ads = document.getElementsByTagName("ytd-ad-slot-renderer");
for (var i = 0; i < ads.length; i++) {
ads[i].parentNode.parentNode.remove();
}
}); It sometimes works, sometimes doesn't. I don't know why. Could you add this kind of feature? I'm not familiar with javascript and the workings of youtube. Thanks! |
It looks like it works when there is this css style: ytd-ad-slot-renderer {
display: none;
} |
Thanks for the info @mhwgoo I updated userscript so Shorts sections are now hidden Re: qutebrowser refresh bug, I downloaded the Windows installer from https://github.com/qutebrowser/qutebrowser/releases but BitDefender alerted me to malware... ...so I'm not comfortable testing it unfortunately
Do you wanna be a contributor by adding it to the CSS? (or I could do it for you if too lazy) |
ytd-ad-slot-renderer {
display: none;
} This only hides the node with a black block still there. But with this portion of css, the following javascript achieves my intention of making ads disappear: window.addEventListener('animationstart', function() {
'use strict';
var ads = document.getElementsByTagName("ytd-ad-slot-renderer");
for (var i = 0; i < ads.length; i++) {
ads[i].parentNode.parentNode.remove();
}
}); I'm not sure it's the right way from your expert opinion, afterall I never write javascript and css projects before. I mean, I think the above code is a bit weird, it trys to delete nodes, why does it need the support of the node being |
Ok I understand now, for the removal the shortest command is: document.querySelectorAll('ytd-ad-slot-renderer').forEach(ad => ad.parentNode.parentNode.remove()) ... and are you saying, when you added the remover using event listener, sometimes it removed, sometimes it did not, but when you also add teh CSS, it always removed? (if so that is quite strange since CSS does not affect whether listener timing was correct so would still show the black boxes) |
NVM I understand what you're saying, "with this portion of css" you meant the selector in the remover, but still it doesn't always remove. Let me figure out the best way brb |
Yeah, you got what I meant. Together "with this portion of css", the above javascript makes the whole youtube web page appear about right (deleted the ad nodes and thus not displaying them). Maybe because the eventlistener's chosen trigger type is |
Ok I figured it out, it kept re-adding so a mutation observer is the best solution, can you update to the latest version 2024.10.28.3 and test it out in qutebrowser |
One thing I noticed, now when scrolling and lazy loading finishes, new ads are re-added but instantly removed, so the grid of videos compresses to fill in blank space and all the thumbnails move. Before when hiding only, this phenomenon does not occur, but there are ugly gaps. Which way is worse? Also what do you think about an option to hide or remove so user picks their poison? |
Actually I just tested without the script, YouTube already jars the user by scrolling up instead of staying in place, so I think they will be used to this disorientation already and your ad removal idea is best |
NVM jsut fixed it also the grid no longer rearranges either |
After my last comment, I found youtube is so gross that it keeps refreshes itself with new ads. Just when I was figuring it out, your message came. Just in time. I will test it and think about your question after dinner. Thanks! |
Btw Google employees closely follow my git activity, and recently YouTube notoriously warns accounts for running ad blocker, also Chrome team just stirred great controversy by banning popular AdBlock extension, so out activity here might draw scrutiny towards this script (but they dont control my publishing so no fear of Chrome Store punishment, just they could add code to block this script in the future) |
Hi @adamlui, I tested the latest version, and it seemed that the page didn't appear as intended. It had this same appearance as soon as the page was first rendered, scrolled down and scrolled back up. Youtube's patterned ad spots were still there. (In fact I had thought about deleting nodes according to this pattern but given up this way as pattern could easily vary in the future) |
I did a little thought experiment after I found yt's refreshment activity with the probably non-idiomatic ugly repetitive js code below in a standalone userscript together with a global var ads = document.getElementsByTagName("ytd-ad-slot-renderer");
window.addEventListener('animationstart', function() {
if (ads) {
for (var i = 0; i < ads.length; i++ ) {
ads[i].parentNode.parentNode.remove();
}
}
ads = document.getElementsByTagName("ytd-ad-slot-renderer");
});
window.addEventListener('animationend', function() {
if (ads) {
for (var i = 0; i < ads.length; i++ ) {
ads[i].parentNode.parentNode.remove();
}
}
ads = document.getElementsByTagName("ytd-ad-slot-renderer");
});
window.addEventListener('load', function() {
if (ads) {
for (var i = 0; i < ads.length; i++ ) {
ads[i].parentNode.parentNode.remove();
}
}
ads = document.getElementsByTagName("ytd-ad-slot-renderer");
}); |
In fact I had been using Brave browser for several years until a few days ago. Brave did some awesome special treatments with yt, making it look like there were no ad at all in all pages as well as within each video. Don't know how Brave achieves that. So I couldn't imagine yt has become like this. If it wanted to counter ad blocks, it'd better take on some big players like Brave Browser first. |
Actually Google triggered a ton of users to switch to Brave after the banning alert. But I will fix it to work in qutebrowser but tomorrow because I was up all night doing something so I have to sleep all day now |
Ironically Brave originally lured users using crypto as reward for their push ads (and it still spams you but the pay is pennies compared to the golden days) |
ok can you reset by replacing script with the latest version, and then Ctrl+F for |
… [auto-sync from `adamlui/youtube-classic`]
ok can you install the latest version is there still observer error |
Tab two doesn't show the custom logo so script didn't load for some reason (custom logo is indicator of script looad now since i replaced |
I got (with the custom logo shown):
|
Actually screenshot is more readable, but can you change the latest version document-start to document-end again, and if new tab doesn't load logo screenshot console |
What about when you refresh second tab? Also you could try installing another userscript, then open new tab and see if phenomenon occurs (if so this is qutebrowser bug worthy of reporting to him) because second console shows no user.js errors |
You could create a userscript that matches YouTube, then see if second tab your script loads |
Does it happen with document-end vs. document-start |
I reused your greasemonkey starting syntax, and changed to document-start: // ==UserScript==
// @name YouTube™ Classic 📺 — (Remove rounded design + Return YouTube dislikes)
// @version 2024.10.30.3
// @author Adam Lui, Magma_Craft, Anarios, JRWR, Fuim & hoothin
// @namespace https://github.com/adamlui
// @description Reverts YouTube to its classic design (before all the rounded corners & hidden dislikes) + redirects YouTube Shorts
// @license MIT
// @icon https://media.ytclassic.com/images/icon48.png
// @icon64 https://media.ytclassic.com/images/icon64.png
// @compatible chrome
// @compatible firefox
// @compatible opera
// @compatible safari
// @compatible edge
// @match *://*.youtube.com/*
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_getValue
// @grant GM_setValue
// @run-at document-start
// @downloadURL https://update.greasyfork.org/scripts/456132/youtube-classic.user.js
// @updateURL https://update.greasyfork.org/scripts/456132/youtube-classic.meta.js
// @homepageURL https://www.ytclassic.com
// @supportURL https://support.ytclassic.com
// ==/UserScript==
console.log("this is kate")
var ads = document.getElementsByTagName("ytd-ad-slot-renderer");
window.addEventListener('animationstart', function() {
if (ads) {
for (var i = 0; i < ads.length; i++ ) {
ads[i].parentNode.parentNode.remove();
}
}
console.log("animationstart done")
ads = document.getElementsByTagName("ytd-ad-slot-renderer");
});
window.addEventListener('animationend', function() {
if (ads) {
for (var i = 0; i < ads.length; i++ ) {
ads[i].parentNode.parentNode.remove();
}
}
console.log("animationend done")
ads = document.getElementsByTagName("ytd-ad-slot-renderer");
});
window.addEventListener('load', function() {
if (ads) {
for (var i = 0; i < ads.length; i++ ) {
ads[i].parentNode.parentNode.remove();
}
}
console.log("load done")
ads = document.getElementsByTagName("ytd-ad-slot-renderer");
}); |
And what happened? Also you should test every possible value from https://wiki.greasespot.net/Metadata_Block#@run-at for both our scripts, also without |
...and the ones that cause script to not load in 2nd tab, you should report to qutebrowser |
I had moved your userscript out before I tested this one to avoid collisions. It worked all good except occasional transient blank boxes for 1-2 seconds as I mentioned this code two days ago. |
I think I may stay with this little script for a while. After I get acquainted with js, I may utilize it or contribute on your project, thanks a lot for your time and big support. |
Yes please learn js it is the best language used in so many things. Chatgpt made me very powerful at it in really short time. Also by little script you mean the one you pasted so ads go away but not round corners works in 2nd tab? |
Yeah that little script only does the job of cleaning ads on the fly, works on second tab, without all of your awesome features, though. It makes do, after all it's only a few lines of code. |
Javascript is powerful, but I have to say I don't like it:) It makes doing creepy and evil activities extremely easy for people without good intentions, websites not as good as before. I think that may be one reason you call your project "youtube classic", and revert to the good old appearance. |
But from chatting with you, I got to learn that js actually has an observe() method, attached to 3 observer classes. Really good to know. |
When I first made the script I just cobbled together code from co-authors listed in the meta because I was not superpowerful at it as now. But thousands of users started growing, and the CSS needs constant maintaining to keep up with the UI changes. But I have COVID so am hesitant to clean up the script using my new powers, because then it will become a beast I am obligated to feed. But if you learn js you could co-maintain it especially if you use YouTube a lot so can keep up with the changes |
I might only learn the amount enough to tweak a script to solve a specific problem I face in satisfying some needs. No more. I wouldn't like to put too much time in js, not a big fan of it, or hate it, to exaggerate a bit, because to some extent it is js that makes my web surfing experience a lot bitter. |
But it is js that can fix it |
One might know how to solve a problem from universal programming mindset, the rest is just copying some syntax. No need to especially learn this language which has already gone in the weirder and weirder direction, in my opinion. |
Ok understood |
My browser has this feature, but this script overrides it, thanks!
The text was updated successfully, but these errors were encountered: