https://gist.githack.com/sounisi5011/e5ae88df32495447850ca2995a7ca02b/raw/index.html
Last active
October 12, 2023 18:49
-
-
Save sounisi5011/e5ae88df32495447850ca2995a7ca02b 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
<!DOCTYPE html> | |
<html lang=ja> | |
<meta charset=utf-8> | |
<meta name=viewport content="width=device-width,initial-scale=1"> | |
<meta name=format-detection content="telephone=no,email=no,address=no"> | |
<title>YouTubeのコメント欄にあるハートボタンを半透明にするブックマークレット</title> | |
<h1>YouTubeのコメント欄にあるハートボタンを半透明にするブックマークレット</h1> | |
<p>コメントを読む時に邪魔になるコメント欄内のハートボタンを半透明にするブックマークレットです。ブックマークに登録し、ブックマークバーからクリックして実行してください。</p> | |
<p>注意:ブックマークバー(お気に入りバー)からクリックしないと実行されない場合があるため、起動する時にはブックマークバーを表示させてそこからクリックしてください。</p> | |
<p> | |
↓↓↓このリンクをブックマークバーにドラッグして追加する↓↓↓<br> | |
<a href='javascript:if(/(?:^|\.)youtube\.com$/i.test(location.host)){let e,t,o="1.0.0",n=[document.getElementById("chatframe")?.contentDocument,document.getElementById("chat-messages")].map(((e,t)=>[e,t])).find((([e])=>e));n?(e=n[0].querySelector("#reaction-control-panel"),e?(e.style.opacity=.5,setTimeout((()=>alert("ハートボタンを半透明にしました")),9)):t=`チャット欄内にハートボタンが見つかりません\nチャット欄の種別:${n[1]}`):t="チャット欄が見つかりません",t&&alert(`YouTubeの仕様変更によりブックマークレット(バージョン${o})が機能しなくなりました:\n${t}`)}else alert("このページはYouTubeではありません")'> | |
YouTubeのコメント欄にあるハートボタンを半透明にする | |
</a> | |
</p> | |
<footer> | |
<h2>Gist</h2> | |
<p><a href="https://gist.github.com/sounisi5011/e5ae88df32495447850ca2995a7ca02b">gist.github.com<wbr>/sounisi5011<wbr>/e5ae88df32495447850ca2995a7ca02b</a> | |
</footer> |
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
if (!/(?:^|\.)youtube\.com$/i.test(location.host)) { | |
alert('このページはYouTubeではありません'); | |
} else { | |
let VERSION = '1.0.0'; | |
let chatArea = [ | |
document.getElementById('chatframe')?.contentDocument, | |
document.getElementById('chat-messages'), | |
] | |
.map((elem, type) => [elem, type]) | |
.find(([elem]) => elem); | |
let heartButtonElem; | |
let errorMessage; | |
if (!chatArea) { | |
errorMessage = `チャット欄が見つかりません`; | |
} else { | |
heartButtonElem = chatArea[0].querySelector('#reaction-control-panel'); | |
if (!heartButtonElem) { | |
errorMessage = `チャット欄内にハートボタンが見つかりません\nチャット欄の種別:${chatArea[1]}`; | |
} else { | |
heartButtonElem.style.opacity = 0.5; | |
setTimeout(() => alert('ハートボタンを半透明にしました'), 9); | |
} | |
} | |
if (errorMessage) { | |
alert(`YouTubeの仕様変更によりブックマークレット(バージョン${VERSION})が機能しなくなりました:\n${errorMessage}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment