-
Notifications
You must be signed in to change notification settings - Fork 69
Advanced Blocking
Advanced blocking lets you to write a JavaScript function to block videos in
more detail than the regular filters can provide.
To enable advanced blocking, check the Enable advanced blocking box and add
your rules to the Custom blocking function box underneath.
The rest of this file expects some form of JavaScript knowledge.
All rules must be contained in an anonymous function that receives two arguments:
-
video
object -
objectType
string
The initial contents of the box will have a template for this.
This function should return a boolean value, where true
means the video will be blocked,
and false
will leave the video up.
- Be especially careful with the function syntax. If you are not using an arrow function, you might need to wrap your function declaration in parentheses.
- If your function has a syntax error/runtime exception it will be catched and logged to the developer console
- If any of the regular filters matched a video and blocked it, it will not reach your function
(video, objectType) => {
// Add custom conditions below
// Don't touch recommendations on video pages
if (objectType === 'compactVideoRenderer') {
return false;
}
// If video title contains "something"
// and If the channel name contains "otherthing"
if (video.title.match("something") && video.channelName.match("otherthing")) {
// Block the video
return true;
}
// ... more conditions ...
// Custom conditions did not match, do not block
return false;
}
It might be a wise idea to check if these keys exist before using them, as
certain parts of YouTube might omit certain data.
In case this documentation is outdated, const filterRules
in inject.js can
be used as a more up-to-date reference.
-
channelId
andchannelName
: ID and name of the video uploader -
publishTimeText
: "Human friendly" publish time text. (1 year ago, 5 days ago, etc.) please note this value changes according to your YouTube interface language -
title
: Title of the video -
videoId
: ID of the video -
vidLength
: Length of the video, in seconds -
viewCount
: Count of views the video has -
channelBadges
: Badges next to the channel name. The current values are:-
verified
: The classic checkmark -
artist
: The music note
-
-
badges
: Badges under the video. The current values are:-
live
: Live stream indicator
-
-
channelId
andchannelName
: ID and name of the commenter -
comment
: Text of the comment
objectType is a string coming from YouTube themselves that represent the type of object being filtered (e.g. A recommended video in the homepage, a comment)
There are many possible values for this argument, you can view all of them in the extension code under filterRules
object keys
As of today, there is no full description for each one, but most of them are self explanatory