Youtube Search Filter

Remove garbage videos from Youtube search result page.

  1. /* cspell:disable pixelmon */
  2.  
  3. // ==UserScript==
  4. // @version 1.2.2
  5. // @name Youtube Search Filter
  6. // @name:zh-CN Youtube 搜索过滤
  7. // @namespace https://tools.unoiou.com
  8. // @author Mingshi
  9. // @description Remove garbage videos from Youtube search result page.
  10. // @description:zh-CN 从 Youtube 搜索页面移除特定用户上传的视频结果
  11. // @copyright 2020, Mingshi
  12. // @license MIT
  13.  
  14. // @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js
  15. // @require https://gf.qytechs.cn/scripts/374849-library-onelementready-es6/code/Library%20%7C%20onElementReady%20ES6.js?version=649483
  16.  
  17. // @match https://www.youtube.com/results?*
  18. // @match https://www.youtube.com
  19. // ==/UserScript==
  20. // jshint esversion:6
  21. /* global onElementReady */
  22.  
  23. // read blocklist keywords
  24. const configName = 'ytd-search-block-list';
  25. GM_config.init({
  26. 'id': configName,
  27. 'title': 'Youtube Search Filtr Setting',
  28. 'fields': {
  29. 'blocklist': {
  30. 'label': 'Block List',
  31. 'type': 'textarea',
  32. 'default': '',
  33. 'title': 'Each line represents a keyword of block list.'
  34. }
  35. },
  36. 'css': [
  37. '#ytd-search-block-list_field_blocklist {min-height: 400px;}'
  38. ]
  39. })
  40. // add config btn
  41. var button = document.createElement('button');
  42. button.innerHTML = "Search Filter";
  43. button.style = "bottom:1em;right:1em;position:fixed;z-index: 9999;background:red;";
  44. button.setAttribute('type', 'button');
  45. button.addEventListener('click', function () {
  46. GM_config.open();
  47. }, false);
  48. document.body.appendChild(button);
  49.  
  50. const keywords = GM_config.get('blocklist').split('\n').filter(e => e.length > 0);
  51.  
  52. // for easy debug
  53. unsafeWindow.onElementReady = onElementReady;
  54.  
  55. // runs on each time `ytd-video-renderer` loaded.
  56. onElementReady('ytd-video-renderer', false, (el) => {
  57. keywords.forEach((keyword) => {
  58. if (el.querySelector('ytd-channel-name').textContent.toLowerCase().includes(keyword)) {
  59. el.remove();
  60. console.log('removed', keyword);
  61. }
  62. });
  63. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址