Blocking YouTube Shorts Notifications
I've been using YouTube for consuming long-form content for many years now, and I was never interested in YouTube Shorts, which seem to be the brand's answer to TikTok with short-form, vertical content and fast cuts. It was easy enough to avoid the feature all together for a while, especially with modifications like YouTube Revanced on mobile (essentially a patched version of the official YouTube app with optional tweaks like hiding the Shorts section completely), and SmartTube on Chromecast/AndroidTV devices. Diving into the benefits of those tools and how to set them up is a topic I plan to follow-up on in separate posts.
However, lately YouTube seems to be pushing Shorts a lot harder, so even the long-form creators I follow have succumbed to chopping up their content and surfacing it in there as a way to keep building their audience, adding views and subscribers, etc. However, the big issue with this is YouTube (surely intentionally) gives you no way to subscribe to a channel but only get notified about new videos and not shorts.
This was driving me crazy and I am definitely not alone, but nobody seemed to have found a workable solution. This is partly because there is nothing obvious you can use to differentiate between shorts notifications and normal video notifications...they come through the same notification channel and the title/body of the notification doesn't have anything you can filter on with something like the excellent BuzzKill app.
However, eventually I realized the notification does include an image thumbnail, and for shorts this is always a portrait image since they're all vertical videos, while any normal video notification has a thumbnail in landscape orientation. So I figured it should be possible to use Tasker with the AutoNotification plugin to detect notifications from YouTube, check if they had an image attached, check the orientation of the image, and discard notifications where the image height is greater than the width (portrait orientation).
Without further ado, here's the Tasker profile and task configurations which you should be able to import directly into Tasker (obviously you need both Tasker and AutoNotification installed, and I believe both of those are paid apps but well worth the cost). I was targeting YouTube Revanced, but it should be easy enough to switch to target vanilla YouTube if needed.
Feel free to stop reading here! But just in case those don't work or you want more detailed information on how it works, continue on:
You can see the profile below. It just uses the Notification trigger and in my case instead of the YouTube app, I'm using YouTube Revanced.
As for the task that gets called, here's the structure:
To break that down, Step 1 is using the AutoNotification Query
action to intercept notifications from YouTube Revanced and capture the notification data into variables we can use in subsequent steps:
Make sure to scroll down and select to "Continue Task After Error" so it doesn't break if something unexpected comes through.
That's it for that action! Next, Step 2 of the task uses an If
statement to see if we found an image attached to the notification. There's an %animages
array that we get from the previous step, and we only care about the first image. I think there's some more reasonable syntax that can be used here like %animages(1)
or something, but I got this from somewhere and it works, so 🤷♂️
Now for the fun part that took all kinds of trial and error...Tasker lets you run javascript through the javascriptlet
action, or Java code through the Java Function
action. I was having a hard time getting some sample javascriptlet
s working, but the Java functions method worked, so that's what I ended up with. It basically makes three Java calls. One to actually create a Bitmap from the image in memory, one to store the height of that Bitmap into a variable, and one to store the width.
Finally, we want to conditionally cancel the incoming notification when we detect that there was an image that was taller than the width.
I skipped over Step 3 in the task, which is disabled. But basically I was using that for debugging to verify this flow worked as expected, generating a notification that could include fields I wanted to inspect and to verify that I correctly detected when a notification had an image attached.
I've been using this for several days now and it's been working great! It's amusing to see that if I visit the notifications tab in the YouTube app, I see several shorts that I never saw a push notification for, so I know it's working. And I haven't missed any notifications for the regular videos that I do want to hear about, so I call this a major success!