Youtube subscriptions filter

Work with {xxzefgh/youtube-classic-extension}

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Advertisement:

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

Advertisement:

// ==UserScript==
// @name         Youtube subscriptions filter
// @namespace    https://github.com/FlandreDaisuki
// @version      0.2
// @description  Work with {xxzefgh/youtube-classic-extension}
// @author       FlandreDaisuki
// @match        https://www.youtube.com/*
// @require      https://unpkg.com/[email protected]/dist/sentinel.js
// @grant        none
// @noframes
// ==/UserScript==

/* global sentinel */

const $ = (s) => document.querySelector(s);
const $$ = (s) => [...document.querySelectorAll(s)];
const $el = (t, a = {}, c = () => {}) => {
  const e = document.createElement(t);
  Object.assign(e, a);
  c(e);
  return e;
};

const 過濾輸入 = $el('input', { id: '訂閱內容過濾', placeholder: 'RegExp with "ig" flag' });
const 過濾內容 = (s = '') => {
  let regex;
  try { regex = new RegExp(s, 'ig'); } catch(ex) { return; }

  $$('#guide-channels > li').forEach((li) => {
    const name = li.querySelector('.display-name').textContent.trim();

    if(regex.test(name)) {
      li.classList.remove('hidden');
    } else {
      li.classList.add('hidden');
    }
  });
};
const 自訂樣式 = $el('style', {
  id:'💜💙💚💛💖ㄟ🧛‍♀️ㄏ💖💛💚💙💜',
  textContent:`
#guide-subscriptions-section > h3:hover {
  cursor: pointer;
  font-size: 12px;
}
#訂閱內容過濾 {
  display: none;
  margin: 0 5px 4px;
  border: 1px solid gray;
}
.顯示過濾 + #訂閱內容過濾 {
  display: inline-block;
}
.hidden {
  display: none !important;
}`
});

sentinel.on('#guide-subscriptions-section > h3', (訂閱內容) => {
  sentinel.reset();

  訂閱內容.insertAdjacentElement('afterend', 過濾輸入);
  訂閱內容.addEventListener('click', (event) => {
    訂閱內容.classList.toggle('顯示過濾');
    if(!訂閱內容.classList.contains('顯示過濾')) {
      過濾輸入.value = '';
      過濾內容();
    }
  });
  過濾輸入.addEventListener('input', (event) => {
    過濾內容(過濾輸入.value.trim());
  });
  document.head.appendChild(自訂樣式);
});