Useless Chrome Extensions for YouTube
Wynter Jones
Posted on March 18, 2019
Hello Dev.to community!
I'd like to share with you some useless code for creating a variety of Chrome Extensions that play around with YouTube.
The idea was mostly to see how I could inject CSS and JavaScript onto a page using a chrome extension. Very basic and simple.
Only problem, what do I do with that power?
Idea #1 - Hide YouTube Comments
First, here's the basic manifest.json
file for injecting CSS.
{
"name": "Replace YouTube Comments",
"version": "0.0.1",
"manifest_version": 2,
"description": "",
"homepage_url": "http://www.monetizedesign.com",
"default_locale": "en",
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"css": [
"inject.css"
]
}
],
"permissions": [
"tabs", "http://*/*", "https://*/*"
]
}
For a chrome extension you basically need the manifest.json
, locales/en/messages.json
and extra files for what you plan to do with your extension.
For this first example here's the CSS that will hide the YouTube comments.
ytd-comments {
display: none !important
}
Amazing!
Fairly boring, although 318,626 users might think otherwise and praise this very simple chrome extension (or argue about features in the comments) as seen here on the Hide YouTube Comments extension.
This next one might sound silly and when I showed other people this idea they initially thought I was being a troll... That's up to you to decide.
Idea #2 - Auto Dislike YouTube Videos
If you're like me and watch way too much YouTube videos that you might think this is useless and it is.
Personally, I rarely like, comment or subscribe any YouTube video, however since 90% of YouTube videos ask you to Like and Subscribe; I thought why not auto-dislike every video I'm watching?
Here's the manifest.json
to inject JavaScript onto the page.
{
"name": "Auto Dislike YouTube Videos",
"version": "0.0.1",
"manifest_version": 2,
"description": "",
"homepage_url": "http://www.monetizedesign.com",
"default_locale": "en",
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["jquery.js", "inject.js"],
"run_at":"document_end"
}
],
"permissions": [
"activeTab"
]
}
Yes, I included jQuery, mostly because I am lazy. Feel free to rewrite the code with vanilla JS, which I would do if I were to actually release this extension.
Here's the code that is always checking and ready to dislike any YouTube video at a moments notice:
function checkAndDislike() {
setTimeout(checkAndDislike, 5000)
if ($('ytd-app[is-watch-page]').length) {
if (!$('#menu ytd-toggle-button-renderer').eq(1).hasClass('style-default-active')) {
$('#menu ytd-toggle-button-renderer').eq(1).trigger('click')
}
}
}
setTimeout(checkAndDislike, 5000);
Now this may seem cruel and unusual.
This is nothing compared to my next idea in terms of uselessness...
Idea #3 - Auto Like and Subscribe YouTube Videos
This might be a bit more social commentary than the rest of these useless chrome extensions, however the goal of this one which includes the same manifest.json
is to do the opposite.
Auto Like and Subscribe to every YouTube video you watch!
Here's the code:
function checkAndSubscribe() {
setTimeout(checkAndSubscribe, 5000)
if ($('ytd-app[is-watch-page]').length) {
const likeButton = $('#menu ytd-toggle-button-renderer').first()
if (!likeButton.hasClass('style-default-active')) {
likeButton.trigger('click')
}
const subscribeButton = $('#subscribe-button paper-button.ytd-subscribe-button-renderer')
if (!subscribeButton[0].hasAttribute("subscribed")) {
subscribeButton.first().trigger('click')
}
}
}
setTimeout(checkAndSubscribe, 5000);
It's pretty evil, isn't it?
No, I'm not talking about the need to inject jQuery to use it only to use .first()
or .eq()
...
Basically every 5 seconds it checks the page to Like and Subscribe the video you are watching.
How incredibly useless.
Either way -- the code is not useless just the function.
Do You Have Useless Chrome Extension Ideas?
Let me know in the comments some random and silly ideas that serve no real purpose.
Posted on March 18, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.