Blocking YouTube Shorts Notifications
An Android solution using Tasker and AutoNotification
![Blocking YouTube Shorts Notifications](/content/images/size/w2000/2024/07/Screenshot_20240630-114449.png)
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](https://niraj.blog/content/images/2024/07/share_4078966536727234456.png)
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](https://niraj.blog/content/images/2024/07/share_4925663853212014749.png)
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:
![](https://niraj.blog/content/images/2024/07/share_2901295080666337988.png)
Make sure to scroll down and select to "Continue Task After Error" so it doesn't break if something unexpected comes through.
![](https://niraj.blog/content/images/2024/07/share_226498568579863983.png)
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 🤷♂️
![](https://niraj.blog/content/images/2024/07/share_1783988354493264025.png)
If
statement, showing the condition is checking that %animages1
is setNow 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.
![](https://niraj.blog/content/images/2024/07/share_1194135113012994403.png)
![](https://niraj.blog/content/images/2024/07/share_2626921081551138281.png)
![](https://niraj.blog/content/images/2024/07/share_4473678477027686874.png)
Finally, we want to conditionally cancel the incoming notification when we detect that there was an image that was taller than the width.
![](https://niraj.blog/content/images/2024/07/share_5466106504662930060.png)
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!