Created
March 18, 2018 09:11
-
-
Save abcang/84e701d3895b0435b14a3b2f34850826 to your computer and use it in GitHub Desktop.
YouTubeのコメントから時間リンク付きのものだけを表示するボタンを付けるやつ
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
// ==UserScript== | |
// @name YouTube time comment filter | |
// @namespace https://abcang.net/ | |
// @version 0.1 | |
// @description YouTubeのコメントから時間リンク付きのものだけを表示するボタンを付けるやつ | |
// @author abcang | |
// @match https://www.youtube.com/watch?v=* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let filterd = false; | |
function handleToggle() { | |
for (const comment of Array.from(document.querySelectorAll('ytd-comment-thread-renderer'))) { | |
if (filterd) { | |
comment.style.display = ''; | |
} else { | |
if (!comment.querySelector('#content-text a.yt-simple-endpoint.style-scope.yt-formatted-string[href^="/watch?v="][href*="&t="]')) { | |
comment.style.display = 'none'; | |
} | |
} | |
} | |
filterd = !filterd; | |
} | |
const interval = setInterval(() => { | |
const commentHeader = document.querySelector('#comments #title'); | |
if (commentHeader) { | |
const button = document.createElement('button'); | |
button.innerText = 'フィルタ切り替え'; | |
button.addEventListener('click', handleToggle); | |
commentHeader.appendChild(button); | |
clearInterval(interval); | |
} | |
}, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment