Last active
March 16, 2022 09:34
-
-
Save vensires/a2cf961195334db94bfa43e562e945cc to your computer and use it in GitHub Desktop.
Provides a function to turn Youtube into a whitelist-only mode. This function depends on the BlockTube extension for Chrome/Firefox and should be used in its "Advanced blocking" option. The example values used below will only allow videos coming from the "Om Nom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The following function will make BlockTube act in a whitelist-only mode. | |
* | |
* Any videos coming from channels other that those you have set in the | |
* "allowedChannels" variable will get hidden from display. | |
*/ | |
(video, objectType) => { | |
/* | |
* Add here the channel IDs you want to be displayed. | |
*/ | |
let allowedChannels = [ | |
'UCQm7lPfyFeVL8CBGDtT1ARQ' | |
]; | |
/* | |
* Comment out the following line to find channel IDs. | |
*/ | |
// console.debug(video); | |
/* | |
* Add here the titles of the videos you want disallowed. | |
*/ | |
let notAllowedNames = [ | |
"Om Nom Stories", | |
"Halloween", | |
"Super-Noms' Funny & Epic Adventures" | |
] | |
/* | |
* Add here any objectType values you want displayed. | |
*/ | |
let allowedObjectTypes = [ | |
'args', | |
'c4TabbedHeaderRenderer', | |
/* 'channelRenderer', */ | |
'compactVideoRenderer', | |
'endScreenVideoRenderer', | |
'gridPlaylistRenderer', | |
'gridVideoRenderer', | |
'guideEntryRenderer', | |
'playerOverlayAutoplayRenderer', | |
'playlistRenderer', | |
'shelfRenderer', | |
'videoDetails', | |
'videoPrimaryInfoRenderer', | |
'videoRenderer', | |
'videoSecondaryInfoRenderer' | |
]; | |
/** | |
* ===================== | |
* Don't modify anything below this line (unless you know what you're doing). | |
* =========================================================================== | |
*/ | |
if (allowedObjectTypes.indexOf(objectType) === -1) { | |
console.debug(objectType); | |
return true; | |
} | |
if (video.channelId) { | |
if (allowedChannels.indexOf(video.channelId) !== -1) { | |
// Since the channel ID is allowed, it should be displayed. | |
if (video.title) { | |
for (let i = 0; i < notAllowedNames.length; i++) { | |
// console.debug(video.title, notAllowedNames[i], video.title.match(notAllowedNames[i])); | |
if (video.title.indexOf(notAllowedNames[i]) !== -1) { | |
// Hide videos matching the notAllowedNames values. | |
return true; | |
} | |
} | |
} | |
return false; | |
} | |
// Channel not allowed. | |
return true; | |
} | |
// Media doesn't have a channel ID. Let's display it! | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment