Last active
September 29, 2024 11:34
-
-
Save cmsax/2942af63fbb1e664120af617683483f5 to your computer and use it in GitHub Desktop.
UserScript for filtering youtube search result.
This file contains 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
stone记 | |
rfi | |
bbc news中文 | |
熱點互動 | |
热点互动 | |
美国之音 | |
老外看中国 | |
唐浩 | |
江峰 | |
李蘭斯 | |
leonard | |
自由亚洲 | |
孙文 | |
看中国 | |
石涛 | |
冷眼看世界 | |
ntdtv | |
新聞第一現場 | |
視角 | |
新聞:綜合頻道 | |
memehongkong | |
中國時局 | |
睿眼看世界 | |
天亮時分 | |
陳破空 | |
大纪元 | |
大紀元 | |
新聞拍案驚奇 | |
新唐人 | |
ntd | |
公子沈 | |
wen zhao | |
财经冷眼 |
This file contains 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
/* cspell:disable pixelmon */ | |
// ==UserScript== | |
// @version 1.2.0 | |
// @name Youtube Search Filter | |
// @name:zh-CN Youtube 搜索过滤 | |
// @namespace https://tools.unoiou.com | |
// @author Mingshi | |
// @description Remove garbage videos from Youtube search result page. | |
// @description:zh-CN 从 Youtube 搜索页面移除特定用户上传的视频结果 | |
// @copyright 2020, Mingshi | |
// @license MIT | |
// @downloadURL https://gist.githubusercontent.com/cmsax/2942af63fbb1e664120af617683483f5/raw/youtube-search-filter.js | |
// @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js | |
// @require https://greasyfork.org/scripts/374849-library-onelementready-es6/code/Library%20%7C%20onElementReady%20ES6.js?version=649483 | |
// @match https://www.youtube.com/results?* | |
// @match https://www.youtube.com | |
// ==/UserScript== | |
// jshint esversion:6 | |
/* global onElementReady */ | |
// read blocklist keywords | |
const configName = 'ytd-search-block-list'; | |
GM_config.init({ | |
'id': configName, | |
'title': 'Youtube Search Filtr Setting', | |
'fields': { | |
'blocklist': { | |
'label': 'Block List', | |
'type': 'textarea', | |
'default': '', | |
'title': 'Each line represents a keyword of block list.' | |
} | |
} | |
}) | |
// add config btn | |
var button = document.createElement('button'); | |
button.innerHTML = "Search Filter"; | |
button.style = "bottom:1em;right:1em;position:fixed;z-index: 9999;background:red;"; | |
button.setAttribute('type', 'button'); | |
button.addEventListener('click', function () { | |
GM_config.open(); | |
}, false); | |
document.body.appendChild(button); | |
const keywords = GM_config.get('blocklist').split('\n').filter(e => e.length > 0); | |
// for easy debug | |
unsafeWindow.onElementReady = onElementReady; | |
// runs on each time `ytd-video-renderer` loaded. | |
onElementReady('ytd-video-renderer', false, (el) => { | |
keywords.forEach((keyword) => { | |
if (el.querySelector('ytd-channel-name').textContent.toLowerCase().includes(keyword)) { | |
el.remove(); | |
console.log('removed', keyword); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment