「ミュート」機能のトリガーコードを更新しました
「ミュート」を適用する「CM」の判定コードを刷新しました。 これまでの判定コードは ver.0.2 から同じでしたが、「アメーバニュース」のイレギュラーなコンテンツ切換えにも対応できる様に、大幅に改善しました。
以下は、新しく採用したトリガー要素です。
選択チャンネルの表示
チャンネルのコンテンツの切換えが行われると、「チャンネルセレクター」の「選択チャンネルの表示」は必ず更新されます。 この更新を監視して、更新があれば「ミュート」を「OFF」にする様にしました。
これは2つの効果があり、1つは「カウントダウン画面」から新しいコンテンツへの切換わり時に、ミュートを確実に素早く「OFF」にできます。 もう1つの効果は、ユーザーのチャンネル変更時のミュート「OFF」が、これで兼用できる事です。
チャンネルタイトルの表示
「タイトル」の表示の有無を監視して、タイトル表示が有る場合にミュート「OFF」にする様にしました。 これは、ニュースチャンネルで生じるミュートの誤適用を回復します。
「タイトル」はコンテンツが切換わって数秒後に表示される(遅い)場合があり、トリガーとしては使い難いものです。 しかし、誤適用時に回復するためのトリガーとしては有効でした。「CM」以外のメインコンテンツは必ず「タイトル」が表示されるので、判定が遅れる場合がありますが誤適用を救ってくれます。
以上のトリガーコードの更新で、ほぼ満足できる「ミュート」機能の動作を得る事ができました。
「 AmbTV OnAir」
このツールは「 AmbTV Comfy」のサブツールで、両方を同時に併用できます。
「ミュート」機能の設定方法は、以下のページを参照ください。
「 AmbTV OnAir」を利用するには
このツールは Chrome / Edge / Firefox版の拡張機能「Tampermonkey」上で動作します。 以下に、このツールの導入手順を簡単に説明します。
❶「Tampermonkey」を導入します
◎ 使用しているブラウザに拡張機能「Tampermonkey」を導入する事が必要です。
既に「Tampermonkey」を導入している場合は、この手順 ❶ は不要です。
拡張機能の導入については、以下のページに簡単な説明があるので参照ください。
❷「Tampermonkey」にスクリプトを登録します
◎「Tampermonkey」の「+」マークの「新規スクリプト」タブを開きます。
◎「新規スクリプト」には、最初からテンプレートが記入されています。 これは全て削除して、完全に空白の編集枠に 下のコードをコピー&ペーストします。
〔コピー方法〕 軽量シンプルなツール「PreBox Button 」を使うと
コード枠内を「Ctrl+左Click」➔「Copy code 」を「左Click」
の操作で、掲載コードのコピーが可能になります。
◎ 最後に「ファイル」メニューの「保存」を押すと、ツールが使用可能になります。
〔 AmbTV OnAir 〕 ver. 0.6
// ==UserScript== // @name AmbTV OnAir // @namespace http://tampermonkey.net/ // @version 0.6 // @description AbemaTV ユーティリティ // @author Ameba User // @match https://abema.tv/* // @icon https://www.google.com/s2/favicons?sz=64&domain=abema.tv // @grant none // ==/UserScript== let oa_mute; let oa_size; let oa_opac; let target=document.querySelector('head > title'); let monitor0=new MutationObserver(tv_player_env); monitor0.observe(target, { childList: true }); tv_player_env(); function tv_player_env(){ let retry=0; let interval=setInterval(wait_target, 20); function wait_target(){ retry++; if(retry>100){ // リトライ制限 100回 2secまで clearInterval(interval); } let TP=document.querySelector('.com-tv-TVScreen__player'); if(TP){ clearInterval(interval); player_vol(TP); }} } // tv_player_env() function player_vol(TP){ let monitor1=new MutationObserver(con_vol); monitor1.observe( TP, { childList: true }); con_vol(); function con_vol(){ let LF=document.querySelector('.com-tv-LinearFooter__feed-super'); if(TP.querySelector('.com-tv-TVScreen__eyecatch')){ v_vol(1); } else{ if(!LF.textContent){ v_vol(0); }}} let LF=document.querySelector('.com-tv-LinearFooter__feed-super'); let monitor2=new MutationObserver(con_vol2); monitor2.observe( LF, { childList: true }); function con_vol2(){ // イレギュラー時の補償 if(LF.textContent){ v_vol(1); }} setTimeout(()=>{ let LCLI=document.querySelector('.com-tv-LinearChannelListItem--active a'); if(LCLI){ let monitor3=new MutationObserver(con_vol3); monitor3.observe( LCLI, { attributes: true }); con_vol3(); function con_vol3(){ v_vol(1); }} }, 200 ); setTimeout(()=>{ let side=document.querySelector('.com-tv-FeedSidePanel__close-button'); if(side){ side.click(); } }, 600); setTimeout(()=>{ let HM=document.querySelector('.com-m-HeaderMenu'); let SNc=document.querySelector('.c-application-SideNavigation--collapsed'); if(HM && !SNc){ HM.click(); } }, 700); check_cookie(); cm_setting(); } // player_vol(TP) function v_vol(n){ // 0: ミュート 1: 通常 oa_mute=get_cookie('oa_mute'); let button=document.querySelector('.com-playback-Volume__icon-button'); if(button){ let label=button.getAttribute('aria-label'); if(n==0 && label=='音声をオフにする'){ if(oa_mute==0){ button.click(); }} else if(n==1 && label=='音声をオンにする'){ button.click(); } setTimeout(()=>{ let label_=button.getAttribute('aria-label'); if(label_=='音声をオフにする'){ // 音声ON view(1); } else{ view(0); } }, 20); function view(n){ // 0: ミュート 1: 通常 oa_opac=get_cookie('oa_opac'); oa_size=get_cookie('oa_size'); let TVS=document.querySelector('.com-tv-TVScreen__player-container'); if(TVS){ if(n==0){ TVS.style.transition='all .5s'; if(oa_opac==0){ TVS.style.opacity='0.5'; } else if(oa_opac==1){ TVS.style.opacity='0'; } else{ TVS.style.opacity='1'; } if(oa_size==0){ TVS.style.transform='scale(0.5)'; } else{ TVS.style.transform='scale(1)'; }} else{ TVS.style.transition=''; TVS.style.opacity='1'; TVS.style.transform='scale(1)'; }}} } // button } // v_vol() function get_cookie(name){ let cookie_req=document.cookie.split('; ').find(row=>row.startsWith(name)); if(cookie_req){ if(cookie_req.split('=')[1]==null){ return 0; } else{ return cookie_req.split('=')[1]; }} if(!cookie_req){ return 0; }} function check_cookie(){ oa_mute=get_cookie('oa_mute'); if(oa_mute!=1){ oa_mute=0; } document.cookie='oa_mute='+oa_mute+'; Max-Age=2592000'; oa_size=get_cookie('oa_size'); if(oa_size!=1){ oa_size=0; } document.cookie='oa_size='+oa_size+'; Max-Age=2592000'; oa_opac=get_cookie('oa_opac'); if(oa_opac!=0 && oa_opac!=1 && oa_opac!=2){ oa_opac=0; } document.cookie='oa_opac='+oa_opac+'; Max-Age=2592000'; } // check_cookie() function cm_setting(){ let TVS=document.querySelector('.com-tv-TVScreen__player-container'); if(TVS){ TVS.onclick=function(event){ if(event.ctrlKey){ let panel= '<div id="amboa">'+ '<div id="oa_head">コマーシャルの表示設定 '+ '<input type="button" id="oa_close" value="×"></div>'+ '<div> 音声:'+ '<input name="mute" type="radio" id="m0">ミュート '+ '<input name="mute" type="radio" id="m1">通常'+ '</div>'+ '<div> 画面:'+ '<input name="size" type="radio" id="s0">縮小 '+ '<input name="size" type="radio" id="s1">通常'+ '</div>'+ '<div> 明度:'+ '<input name="opacity" type="radio" id="o0">0 '+ '<input name="opacity" type="radio" id="o1">50 '+ '<input name="opacity" type="radio" id="o2">100'+ '</div>'+ '<div></div>'+ '<style>#amboa { position: fixed; z-index: 100; top: 60px; left: 40%; '+ 'font: 16px/24px Meiryo; color: #000; padding: 8px 10px 6px; '+ 'border: 1px solid #aaa; border-radius: 6px; background: #fff; } '+ '#oa_head { margin: 0 0 10px; padding: 5px 8px 3px 15px; '+ 'font-weight: bold; color: #fff; background: #2196f3; text-align: center; } '+ '#oa_close { padding: 0 2px; height: 20px; line-height: 16px; } '+ 'input[type="radio"]{ margin: 0 .2em; }'+ '</style>'+ '</div>'; if(!document.querySelector('#amboa')){ document.body.insertAdjacentHTML('beforeend', panel); } set_radio(); function set_radio(){ oa_mute=get_cookie('oa_mute'); let m0=document.querySelector('#m0'); let m1=document.querySelector('#m1'); if(oa_mute==0){ m0.checked=true; mute(0); } else{ oa_mute=1; m1.checked=true; mute(1); } document.cookie='oa_mute='+oa_mute+'; Max-Age=2592000'; m0.onchange=function(){ mute(0); document.cookie='oa_mute=0; Max-Age=2592000'; } m1.onchange=function(){ mute(1); document.cookie='oa_mute=1; Max-Age=2592000'; } oa_size=get_cookie('oa_size'); let s0=document.querySelector('#s0'); let s1=document.querySelector('#s1'); if(oa_size==0){ s0.checked=true; } else{ oa_size=1; s1.checked=true; } document.cookie='oa_size='+oa_size+'; Max-Age=2592000'; s0.onchange=function(){ document.cookie='oa_size=0; Max-Age=2592000'; } s1.onchange=function(){ document.cookie='oa_size=1; Max-Age=2592000'; } oa_opac=get_cookie('oa_opac'); let o0=document.querySelector('#o0'); let o1=document.querySelector('#o1'); let o2=document.querySelector('#o2'); if(oa_opac==0){ o1.checked=true; } else if(oa_opac==1){ o0.checked=true; } else{ oa_opac=2; o2.checked=true; } document.cookie='oa_opac='+oa_opac+'; Max-Age=2592000'; o0.onchange=function(){ document.cookie='oa_opac=1; Max-Age=2592000'; } o1.onchange=function(){ document.cookie='oa_opac=0; Max-Age=2592000'; } o2.onchange=function(){ document.cookie='oa_opac=2; Max-Age=2592000'; } function mute(n){ let s0=document.querySelector('#s0'); let s1=document.querySelector('#s1'); let o0=document.querySelector('#o0'); let o1=document.querySelector('#o1'); let o2=document.querySelector('#o2'); if(n==0){ s0.disabled=false; s1.disabled=false; o0.disabled=false; o1.disabled=false; o2.disabled=false; } else{ s0.disabled=true; s1.disabled=true; o0.disabled=true; o1.disabled=true; o2.disabled=true; }} } // set_radio() let amboa=document.querySelector('#amboa'); let oa_close=document.querySelector('#oa_close'); if(amboa && oa_close){ oa_close.onclick=function(event){ event.preventDefault(); amboa.remove(); }} }}} } // cm_setting()
「AmbTV OnAir」最新版について
旧いバージョンの JavaScriptツールは、アメーバのページ構成の変更で動作しない場合があり、導入する場合は最新バージョンをお勧めします。
●「AmbTV OnAir 」の最新バージョンへのリンクは、以下のページのリンクリストから探せます。