Skip to content

Instantly share code, notes, and snippets.

@davidhq
Last active February 17, 2024 22:00
Show Gist options
  • Save davidhq/8e5ab88e59a2bc27c07bf75977f5eac2 to your computer and use it in GitHub Desktop.
Save davidhq/8e5ab88e59a2bc27c07bf75977f5eac2 to your computer and use it in GitHub Desktop.
YouTube Blacklist
const DISABLE_CHANNELS = ['JMMates', 'Kotte Animation', 'Oddly Viral', 'Mr. Chaliche', 'Like Nastya', 'Like Nastya Show', 'Pear Vlogs', 'Smile Family', 'HowToBasic', 'MrBeast', 'Decija Zona', 'Ha Hack', 'Vlad un Niki', 'Little Panda', 'ReactingToGaming', 'Teen-Z', 'Troom Troom PT', 'Master Thunder', 'LankyBox', 'AnythingAlexia', 'Omco'];
const FORBIDDEN_WORDS = [
'!!!',
'\?\?\?',
'$',
'€',
'ë',
'ö',
'r\.i\.p',
'TikTok',
'Tik Tok',
'Shorts',
'pregnant',
'gravida',
'birth',
'embarazada',
'fertility',
'pregnancy',
'Junya',
'Nastya',
'Nikita',
'Vlad',
'Mochi',
'Diana and Roma',
'kids roma',
'turkish',
'miley cyrus',
'luka basi',
'nutella',
'live',
'kidz',
'magnus',
'zumba',
'cake',
'\sAI\s',
'Saito',
'Sagawa',
'iShowSpeed',
'Nerf',
'Polkka',
'vocavoca',
'Mix',
'Battle',
'Crash',
'Chucky',
'Fall',
'fail',
'quran',
'bible',
'akbar',
'bitcoin',
'barbie',
'expensive',
'beast',
'pitbull',
'bifrina3',
'Crazy',
'craziest',
'insane',
'challenge',
'craziness',
'Bugs',
'Spider',
'Hindi',
'indonesia',
'Kitteh',
'escap',
'hack',
'mods',
'noise',
'jail',
'shot',
'Worms',
'omg',
'skibidi',
'Siren Head',
'million',
'rich',
'broke',
'bankrupt',
'ladybug',
'monster',
'bad idea',
'surgery',
'evil',
'Peppa',
'wrong heads',
'dead',
'sniper',
'stupid',
'dababy',
'kick',
'annoying orange',
'muhammad',
'amazing',
'matilda',
'speedrunner',
'talking tom',
'gato tom',
'unboxing',
'prank',
'blow your mind',
'sound variation',
'head', // !! just remove all head stuff ! doh
'ASMR',
'Tiles',
'Hop',
'real life',
'Armas',
'Gun',
'AK47',
'Rifle',
'Choo Charles',
'wow',
'Horror',
'pennywise',
'coffin',
'Mutant',
'darkness',
'Bloody',
'Scream',
'squid',
'body',
'Scary',
'Scare',
'creepy',
'Warzone',
'Weapon',
'Godzilla',
'Obunga',
'Psycho',
'Doritos',
'Among Us',
'bubble gum',
'Attack',
'Food Challenge',
'Spicy Hot',
'Meme',
'Halloween',
'stickman',
'Zombie',
'skibidi',
'toilet',
'annoying orange',
'sandwich runner',
'peppa',
'zombie',
'Wierd',
'Chase',
'Weird',
'Roblox',
'minecraft',
'Bully',
'Savage',
'shredded',
'destroy',
'mukbang',
'suicide',
'control',
'mean',
'must try',
'DAME TU COSITA',
'ME KEMASTE'
];
const REFRESH_RATE = 500;
function shouldSkip({ title = '', channel = '' } = {}) {
const str = `${title} ${channel}`.toLowerCase();
const JAP = /[\u4e00-\u9faf]|[\u3400-\u4dbf]|[さいとう]/g;
// ARABIC
const arabic = /[\u0600-\u06FF]/;
// THAI
const THAI = /[ๅภถุึคตจขชๆไำพะัีรนยบลฃฟหกดเ้่าสวงผปแอิืทมใฝ๑๒๓๔ู฿๕๖๗๘๙๐ฎฑธํ๊ณฯญฐฅฤฆฏโฌ็๋ษศซฉฮฺ์ฒฬฦ]/g;
// KOREAN
const KOREAN = /[어몽어스안녕하세요맛있는음식이가득한공삼테이블입니다]/g; // not complete but working
// HINDI
const HINDI = /[अआइईउऊएऐओऔअंअःकखगघङचछजझञटठडढणतथदधनपफबभमयरलवसषशह]/g; // not complete, perhaps.. but ok
// CYRILLIC
const CYRILLIC = /[\u0400-\u04FF]/g;
// BENGALI
const bengali = /[ড়ঢ়ঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফববভমমযরলশষসহািীুূৃৄেৈোৌ্ৎড়ঢ়য়]/g;
// VIETNAMESE
const vietnam =
/[ÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠàáâãèéêìíòóôõùúăđĩũơƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂẾưăạảấầẩẫậắằẳẵặẹẻẽềềểếỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪễệỉịọỏốồổỗộớờởỡợụủứừỬỮỰỲỴÝỶỸửữựỳỵỷỹ]/g; //⚠️ it includes normal accented as sell... but great! the more the better
const skip =
JAP.test(str) ||
arabic.test(str) ||
THAI.test(str) ||
KOREAN.test(str) ||
HINDI.test(str) ||
CYRILLIC.test(str) ||
bengali.test(str) ||
vietnam.test(str) ||
FORBIDDEN_WORDS.find(w => str.toLowerCase().indexOf(w.toLowerCase()) > -1) ||
DISABLE_CHANNELS.find(c => c.toLowerCase() == channel.toLowerCase());
if (skip) {
console.log(`Skipping video ${title} (channel: ${channel})`);
return true;
}
}
function extractInfo(e) {
const title = e.querySelector('#video-title')?.innerText;
const channel = e.querySelector('yt-formatted-string.ytd-channel-name')?.innerText;
return { title, channel };
}
function removeMain() {
for (const e of document.querySelectorAll('ytd-rich-item-renderer')) {
if (shouldSkip(extractInfo(e))) {
e.remove();
}
}
}
function removeSponsored() {
for (const e of document.querySelectorAll('ytd-ad-slot-renderer')) {
e.remove();
}
for (const e of document.querySelectorAll('ytd-display-ad-renderer')) {
e.remove();
}
}
function removeSidebar() {
for (const e of document.querySelectorAll('ytd-compact-video-renderer')) {
if (shouldSkip(extractInfo(e))) {
e.remove();
}
}
}
function removeLive() {
// home
for (const e of document.querySelectorAll('ytd-rich-item-renderer')) {
for (const el of e.querySelectorAll('.badge span.ytd-badge-supported-renderer')) {
if (el.innerText == 'LIVE') {
e.remove();
}
}
}
// sidebar
for (const e of document.querySelectorAll('ytd-compact-video-renderer')) {
for (const el of e.querySelectorAll('.badge span.ytd-badge-supported-renderer')) {
if (el.innerText == 'LIVE') {
e.remove();
}
}
}
}
function hideShorts() {
document.querySelector('[title="Shorts"]')?.remove(); // link to shorts on yt main page
document.querySelector('ytd-rich-shelf-renderer')?.remove(); // shorts section on main yt page
document.querySelector('ytd-reel-shelf-renderer')?.remove(); // shorts section on channel pages
}
function __loop() {
removeMain();
removeSponsored();
removeSidebar();
removeLive();
hideShorts();
setTimeout(__loop, REFRESH_RATE);
}
__loop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment