Blocking YouTube Shorts Notifications

An Android solution using Tasker and AutoNotification

Blocking YouTube Shorts Notifications
A custom notification showing a YouTube Shorts notification was detected and removed 🙅‍♂️

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.

Screenshot of the profile in Tasker showing a Notification trigger that calls a task for deleting YouTube Shorts notifications

As for the task that gets called, here's the structure:

Screenshot of the steps inside of the configured task, explained in further detail in the rest of this blog post

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:

The configuration is quite simple...just pick YouTube as the app and capture all fields. You can see it captures a ton of information, but we only need a couple of these fields.

Make sure to scroll down and select to "Continue Task After Error" so it doesn't break if something unexpected comes through.

Both "Structure Output" and "Continue Task After Error" should be checked

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 🤷‍♂️

The details of the If statement, showing the condition is checking that %animages1 is set

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 javascriptlets 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.

Make sure to enter the variable name on the first line. For the next two lines ("Class Or Object" and "Function") you might be able to just type it in but I selected those values by tapping the magnifying glass and choosing them from a list of acceptable values. For the "Param (Bitmap)" line, type in IBUFFER as that won't be in the list.
The second Java function for getting the height of the image. Enter the first two values manually, then select the getHeight function from the magnifying glass list.
Do the same thing to capture the width of the image

Finally, we want to conditionally cancel the incoming notification when we detect that there was an image that was taller than the width.

The details of the AutoNotification Cancel action. The top highlighted section shows the 3 variables we have from the original Query, which we pass through so AutoNotification has the info it needs to cancel the correct notification. These fields (ID, Package, and Tag) are required by the Cancel action. Then, in the If section at the bottom, we check if the height and width we set earlier meet the conditions to indicate this was an image in portrait orientation.

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!