🙄

Youtube Live Chatの「上位チャット」を許さないUser Script。

2022/08/31に公開

概要

youtube の チャット欄の 上位チャット がしつこウザいので。ポーリングして、マウスの代わりに チャット (すべてのメッセージ) を選択してくれる簡単なUserScriptを作った。2^64番煎じなスクリプト。

要点

動作対象のURL

iframeで表示されているチャット用の以下のURLに限定。

  • 配信中: https://youtube.com/live_chat?*

  • 配信中: https://*.youtube.com/live_chat?*

  • アーカイブ: https://youtube.com/live_chat_replay?*

  • アーカイブ: https://*.youtube.com/live_chat_replay?*

一応サブドメインも対象にする感じで。

※ 配信者用のチャットは調査が出来ていないので、間に合っているかわからない。

実行間隔

1秒間隔で処理を実行 (後述)。
※ URLを限定しているため、間隔は短め。

メイン処理

チャット欄のプルダウンの 2つ目の選択肢.iron-selected クラスを持っておらず、まだ選択されていなかったときクリックを実行 する。

image.png

※ 再クリックしてしまうと再読されてしまい良くないため、選択済みかの判定を行っている。

要点部分.js
document.querySelector('span#view-selector yt-dropdown-menu tp-yt-iron-dropdown tp-yt-paper-listbox a:nth-child(2):not(.iron-selected)')?.click();

上記の実行をポーリングさせただけな感じ。
一応誤作動防止のため、チャット欄のセレクターはしつこいめ。

作成環境

UserScript

Tampermonkeyを使っているひとは、以下をそのまま利用できる加藤。

導入・利用・スクリプトの実行などなどはご自身の自己責任でお願いオナシャス。

必要があればポーリングの間隔を5秒とか10秒にしても良いかも。

UserScript.js
// ==UserScript==
// @name         no youtube live top chat.
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://youtube.com/live_chat?*
// @match        https://*.youtube.com/live_chat?*
// @match        https://youtube.com/live_chat_replay?*
// @match        https://*.youtube.com/live_chat_replay?*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    setInterval(function() {
        document.querySelector('span#view-selector yt-dropdown-menu tp-yt-iron-dropdown tp-yt-paper-listbox a:nth-child(2):not(.iron-selected)')?.click();
    }, 1000);
})();

効果

ウィンドウ サイズを変えたりしても、自動で チャット (すべてのメッセージ) を選択してくれるので、安心して投げ銭に集中出来る💣💣💣

余談

あぁ、UserScript増えていく。。。
image.png

そもそも上位チャットって

誰得?🤔🤔🤔

Discussion

ログインするとコメントできます