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

Add An Option To Block Youtube Shorts In Desktop #43093

Open
1Me-Noob opened this issue Jan 3, 2025 · 2 comments
Open

Add An Option To Block Youtube Shorts In Desktop #43093

1Me-Noob opened this issue Jan 3, 2025 · 2 comments

Comments

@1Me-Noob
Copy link

1Me-Noob commented Jan 3, 2025

Platforms

Windows

Description

As i can see here #38059 . This Feature Is Only Available For Android. It Will be Great If You Guys Can Add It in Desktop Versions.

@1Me-Noob
Copy link
Author

1Me-Noob commented Jan 4, 2025

I am sorry but... do you even try to search for the settings?

you go to brave://settings/shields/filters and you find the 'Youtbue Anti-Shorts" list...

Also, in Nightly you can enable the developer mode and have your own scriptlets, that means you can easily implement anything you want without waiting for Brave to do it.

my bad bro, i searched but unable to find..
sorry bro for wasting your time

@asihd0as8hd8shad
Copy link

asihd0as8hd8shad commented Jan 4, 2025

The only thing the toggles in Android and iOS do are to enable the lists, but desktop have to manually enable the lists and the result will be the same, it's all about Lists or Scriptlets, and they are meant to work easily on both desktop and mobile.


BTW, if you want to make it better and redirect Shorts to normal videos, you can use use Nightly.

enable brave://flags/#brave-adblock-custom-scriptlets

now you will see a Developer mode in: brave://settings/shields/filters

create a scriptlet ytshortsredirect or whatever (the mode adds -user.js to any name you add when you save)

Then you can use https://greasyfork.org/en/scripts/472376-youtube-shorts-redirect/code

or what would be:

(function() {
  function redirect(url) {
    if (url.includes("shorts/")) {
      window.location.replace(url.replace("shorts/", "watch?v="));
    }
  }
 
  // Desktop YouTube
  window.addEventListener("yt-navigate-start", evt => {
    redirect(evt.target.baseURI);
  });
 
  // Mobile YouTube
  window.addEventListener("state-navigatestart", evt => {
    redirect(evt.detail.href);
  });
 
  redirect(window.location.href);
})();

then in custom adblock rules just add youtube.com##+js(ytshortsredirect-user)

Many of the userscripts will work without any modifications, so you can find many with MutationObserver it is not necessary.


Also if you want it on mobile, mobile doesn't offer Custom scriptlets yet, but you can always use rpnt scriptlet, currently only Adguard offers a 'create element' scriptlet that will be able to add the script tag with the content, instead of adding it to an existing one like rpnt does.

So that userscript is perfect because it includes both desktop and mobile ones

rpnt would function as

youtube.com##+js(rpnt, script, window.WIZ_global_data, `(function() { function redirect(url) { if (url.includes("shorts/")) { window.location.replace(url.replace("shorts/", "watch?v=")); } } window.addEventListener("yt-navigate-start", evt => { redirect(evt.target.baseURI); }); window.addEventListener("state-navigatestart", evt => { redirect(evt.detail.href); }); redirect(window.location.href); })(); window.WIZ_global_data`)

If not you use /^/ to match any script tag and then add the code there, if it doesn't work because the script tag is a script src one, you increase the sedCount until it works.

youtube.com##+js(rpnt, script, /^/, `(function() { function redirect(url) { if (url.includes("shorts/")) { window.location.replace(url.replace("shorts/", "watch?v=")); } } window.addEventListener("yt-navigate-start", evt => { redirect(evt.target.baseURI); }); window.addEventListener("state-navigatestart", evt => { redirect(evt.detail.href); }); redirect(window.location.href); })();`, sedCount, 1)

Also, the only thing you remove from the original code is the comments, because // Desktop YouTube and // Mobile YouTube are incompatible with 1 line code (for 1 line code it should be /* Mobile YouTube */) so, just remove, join lines and use it as rpnt, and ready and easy.

This is also the way you can do it on desktop, but custom scriptlets is an amazing new feature on Nightly, so if you use Stable, and want it, you can use the code and I am sure both mobile and desktop should match the same window.WIZ_global_data, so no reason for the /^/, and you enjoy avoiding Shorts completely, if someone gives you a link or something

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

No branches or pull requests

2 participants