您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Livetube配信での目障りな緑コテによるコメントの表示/非表示設定機能を提供する
当前为
// ==UserScript== // @name Livetube Handle Cleaner // @namespace https://greasyfork.org/ja/users/8279-nistim // @version 0.1 // @description Livetube配信での目障りな緑コテによるコメントの表示/非表示設定機能を提供する // @author nistim // @match http://livetube.cc/*/* // @match http://h.livetube.cc/*/* // @grant none // ==/UserScript== $(function(){ // コメント数 var commentLength = 0; // ライブフラグ var liveFlag = false; // 配信画面へコテ選択セレクトボックスとボタンを追加する $("#comment_form").after("緑コテ名<select id='handleList'><option value='invalid'>コテ選択</option></select><button id='toggleVisible' disabled='disabled'>コテ選択</button>"); // 配信がライブ状態の場合 if($("#breadcrumbs .xright").html().indexOf("Live") != -1) { // ライブフラグを立てる liveFlag = true; } // コテ選択セレクトボックスの選択時処理 $("#handleList").change(function(){ // 表示状態コテ選択の場合 if($("#handleList option:selected").val() == "visible") { // ボタンのテキストを「非表示」に設定し、有効化する $("#toggleVisible").text("非表示").removeAttr("disabled"); } // 非表示状態コテ選択の場合 else if($("#handleList option:selected").val() == "invisible") { // ボタンのテキストを「表示」に設定し、有効化する $("#toggleVisible").text("表示").removeAttr("disabled"); } // その他の場合 else { // ボタンのテキストを「コテ選択」に設定し、無効化する $("#toggleVisible").text("コテ選択").attr("disabled", "disabled"); } }); // コテ選択ボタンのクリック時処理 $("#toggleVisible").click(function(){ // 選択中コテが表示状態の場合 if($("#handleList option:selected").val() == "visible") { // オプションの値を「非表示」、文字色を「赤色」に設定する $("#handleList option:selected").val("invisible").css("color", "red"); // ボタンのテキストを「表示」に設定する $("#toggleVisible").text("表示"); } // 選択中コテが非表示状態の場合 else { // オプションの値を「表示」、文字色を「緑色」に設定する $("#handleList option:selected").val("visible").css("color", "green"); // ボタンのテキストを「表示」に設定する $("#toggleVisible").text("非表示"); } // コテの表示状態を変更する changeVisible($("#handleList option:selected").text(), null); }); // #comments直下div要素からのコテ取得 // target:コテ文字列 function getHandle(target) { // Liveの場合 if(liveFlag === true) { // 取得したコテを返す return(target.children("div:first").children("a:first").text()); } // 録画の場合 else { // 取得したコテを返す return(target.children("div:first").children("span:first").children("a:first").text()); } } // コテの表示/非表示状態変更処理 // handle:コテ文字列 // target:#comments直下のdiv要素 function changeVisible(handle, target) { // 一時取得用コテ var tmpHandle = null; // 表示状態値(「継承」) var displayValue = "inherit"; // コテ選択セレクトボックス内のオプション要素分のループ処理 $("#handleList option").each(function(index){ // テキストとコテが一致する場合 if($(this).text() == handle) { // 表示状態が非表示の場合 if($(this).val() == "invisible") { // 表示状態値を「非表示」に設定する displayValue = "none"; } // 引数に対象が設定されている場合 if(target) { // 対象の表示状態を設定する target.css("display", displayValue); } // 引数に対象が設定されていない場合 else { // #comments直下のdiv要素分のループ処理 $("#comments div").each(function(index){ // コメントのdiv要素からコテを取得する tmpHandle = getHandle($(this)); // コテが一致する場合 if(handle == tmpHandle) { // 一致したdiv要素の表示状態を設定する $(this).children("div").css("display", displayValue); } }); } // ループ処理を終了する return false; } }); } // メインループ処理 function mainLoop() { // 現在のコメント数 var currentLength = 0; // コメントオブジェクト var commentOBJ = null; // コテ var handle = ""; // #commentsのオブジェクトを取得する commentOBJ = $("#comments"); // 現在のコメント数を取得する currentLength = commentOBJ.children().length; // コメント数が前回のループ処理時から増加した場合 if(commentLength < currentLength) { // 増加したコメント数分のループ処理 for(var i = commentLength; i < currentLength; i++) { // コテの登録有無 var handleExist = false; // コメントからコテを取得する handle = getHandle(commentOBJ.children().eq(i)); // コメントにコテが含まれている場合 if(handle) { // コテ選択セレクトボックス内のオプション要素分のループ処理 $("#handleList option").each(function(index){ // コテ選択セレクトボックスにコテが登録済みの場合 if($(this).text() == handle) { // コテ登録有りに設定する handleExist = true; // ループ処理を終了する return false; } }); // コテ選択セレクトボックスにコテが登録されていない場合 if(handleExist === false) { // コテ選択セレクトボックスにコテを登録する $("#handleList").append($("<option>").val("visible").html(handle).css("color", "green")); } // コテの表示状態を変更する changeVisible(handle, commentOBJ.children().eq(i).children("div")); } } // コメント数を現在のコメント数で更新する commentLength = currentLength; } // 1秒後に再度メインループ処理を実行する setTimeout(mainLoop, 1000); } // メインループ処理を実行する mainLoop(); });