「コメントした記事」のロード遅延対策 

「Loading Time」で調べると、「コメントした記事」のリンクリストは、処理の遅いPC、通信混雑時などの条件が重なると、ロードタイミングがずいぶん遅くなる事が判りました。

(「フォローフィード」も同条件ですが、こちらは「MutationObserver」を使っているので、ロードの遅延があっても問題は生じません)

 

 

これまでは、単純に「2sec」を待ってスクリプトを実行していましたが、それだけでは足りない場合があり、要素のロード待機型のコードを導入しました。

 

「Aid AmbH」 ver. 2.8 615行~

//「コメントした記事」のリンクを直接「コメント欄を開く」仕様に変更
let retry=0;
let interval=setInterval(wait_target, 400);
function wait_target(){
    retry++;
    if(retry>20){ // 8sec まで観測
        clearInterval(interval); }
    let target=document.querySelector('.HomeBlogComment_Collection a');
    if(target){
        clearInterval(interval);
        add_hash_c();
        later(); }}

 

「.HomeBlogComment_Collection a」は「コメントした記事」のリンクリストで、これが取得されるまで 400msecごとに取得を試みます。 最大 8secまで待機しますが、これだけあれば通常は取得に成功するでしょう。

 

リンクリストのロードが確認されると、それを処理する2つの関数「add_hash_c()」「later()」を実行します。

 

以上の待機型コードの導入で「コメントした記事」の処理は、動作環境に影響されないと思います。

 

 

 

「Aid AmbH」の扱い方 

「Aid AmbH」は、「HOME」を起点とした各情報へのアクセスを向上させるツールです。 この機能や扱い方についてはマニュアルを参照ください。

 

 

 

 

「Aid AmbH」を利用するには 

このツールは、Chrome / Edge / Firefox版の拡張機能「Tampermonkey」上で動作します。

 

❶ 拡張機能「Tampermonkey」の導入

「Tampermonkey」は、使用しているブラウザに適した版を導入する必要があります。 既にこの拡張機能を導入している場合は、❶の手順は不要です。

 

 

❷「Aid AmbH」のインストール 

●「Tampermonkey」の「」マークの「新規スクリプト」タブを開きます。

 

 

 

●「新規スクリプト」には、最初からテンプレートが記入されています。 これは全て削除して、完全に空白の編集枠に 下のコードをコピー&ペーストします。

 

〔コピー方法〕 軽量シンプルなツール「PreBox Button   」を使うと

  コード枠内を「Ctrl+左Click」➔「Copy code 」を「左Click」

  の操作で、掲載コードのコピーが可能になります。

 

● 最後に「ファイル」メニューの「保存」を押すと、ツールが使用可能になります。

 

 

〔 Aid AmbH 〕ver. 2.8

 

// ==UserScript==
// @name         Aid AmbH
// @namespace    http://tampermonkey.net/
// @version      2.8
// @description  「HOME」「ブログ」のリンク動作を改善
// @author       Ameba blog User
// @match        https://ameblo.jp/*
// @match        https://www.ameba.jp/home
// @match        https://www.ameba.jp/notifications
// @match        https://blog.ameba.jp/ucs/comment/commentlist*
// @match        https://blog.ameba.jp/ucs/iine/*
// @match        https://msg.ameba.jp/*
// @noframes
// @grant        none
// ==/UserScript==


if(location.hostname=='ameblo.jp'){ // 通常のブログページ
    let once=0; // 表示操作の複数回動作を抑止するフラグ

    let target0=document.querySelector('head');
    let monitor0=new MutationObserver(main);
    monitor0.observe(target0, { childList: true });

    main();

    function main(){
        let amb_header=document.querySelector('#ambHeader');
        let icon=document.querySelectorAll('._2sLQpDcQ svg');
        if(icon.length=='3'){
            let svg0=
                '<svg width="26" height="26" viewBox="0 0 64 64">'+
                '<g transform="translate(0,64) scale(0.1,-0.1)">'+
                '<path d="M212 558 c-7 -7 -12 -35 -12 -64 0 -28 -7 -68 -15 -87 -8 '+
                '-20 -15 -66 -15 -104 0 -61 -3 -69 -27 -89 -32 -25 -27 -60 8 -49 14 '+
                '5 25 2 30 -6 8 -11 12 -10 24 5 15 20 15 20 15 -1 0 -11 -9 -28 -20 -38 '+
                '-31 -28 -8 -47 54 -43 44 3 51 6 54 25 4 30 20 30 24 1 3 -20 10 -23 54 '+
                '-26 62 -4 85 15 54 43 -11 10 -20 27 -20 38 0 21 0 21 15 1 12 -15 16 '+
                '-16 24 -5 5 8 16 11 30 6 35 -11 40 24 8 49 -25 20 -27 28 -27 91 -1 39 '+
                '-7 88 -15 110 -8 22 -15 61 -15 86 0 30 -6 51 -15 59 -13 11 -21 8 -48 '+
                '-18 -42 -41 -75 -41 -112 -2 -32 34 -36 35 -53 18z m38 -148 c0 -5 -4 '+
                '-10 -10 -10 -5 0 -10 5 -10 10 0 6 5 10 10 10 6 0 10 -4 10 -10z m150 '+
                '0 c0 -5 -4 -10 -10 -10 -5 0 -10 5 -10 10 0 6 5 10 10 10 6 0 10 -4 10 '+
                '-10z m-103 -28 c-19 -20 -7 -42 23 -42 30 0 42 22 23 42 -16 18 -16 18 '+
                '3 12 26 -9 64 -45 64 -60 0 -6 -7 -18 -16 -25 -14 -11 -21 -11 -45 3 -27 '+
                '16 -31 16 -58 0 -24 -14 -31 -14 -45 -3 -9 7 -16 19 -16 25 0 20 48 59 '+
                '79 65 2 1 -3 -7 -12 -17z m61 -128 c33 -23 27 -73 -10 -94 -25 -13 -31 '+
                '-13 -55 0 -38 21 -44 71 -11 94 12 9 29 16 38 16 9 0 26 -7 38 -16z"/>'+
                '</g></svg>';

            let svg1=
                '<svg width="26" height="26" viewBox="0 0 64 64">'+
                '<g transform="translate(0,64) scale(0.1,-0.1)">'+
                '<path d="M255 506 c-74 -33 -95 -88 -95 -256 0 -117 2 -132 20 -150 '+
                '24 -24 48 -25 78 -4 17 12 22 25 22 59 l0 44 35 -6 c105 -17 213 93 '+
                '191 194 -23 105 -148 164 -251 119z m119 -112 c20 -20 20 -43 0 -72 '+
                '-18 -26 -50 -28 -76 -5 -36 33 -13 93 37 93 13 0 31 -7 39 -16z"/>'+
                '</g></svg>';

            let svg2=
                '<svg width="26" height="26" viewBox="0 0 64 64">'+
                '<g transform="translate(0,64) scale(0.1,-0.1)">'+
                '<path d="M267 519 c-48 -28 -61 -116 -23 -154 87 -87 217 6 161 115 '+
                '-8 16 -24 34 -34 40 -25 13 -81 12 -104 -1z"/>'+
                '<path d="M255 291 c-51 -23 -101 -79 -116 -132 -20 -64 -7 -69 181 -69 '+
                '188 0 201 5 181 69 -15 53 -65 109 -116 132 -50 23 -80 23 -130 0z"/>'+
                '</g></svg>';

            set_svg(0, svg0);
            set_svg(1, svg1);
            set_svg(2, svg2);

            function set_svg(n, path){
                let svg_d=document.createElement('div');
                svg_d.id='svg_d'+n;
                svg_d.innerHTML=path;
                if(!amb_header.querySelector('#svg_d'+n)){
                    icon[n].parentNode.replaceChild(svg_d, icon[n]); }}}

        let aambh_style=
            '<style id="aambh_style">'+
            '._2sLQpDcQ { margin-top: 1px; } '+
            '._2sLQpDcQ svg { '+
            'border: 1px solid #aaa; border-radius: 4px; transition: .2s;'+
            'padding: 0; margin: 0 4px 0 15px; vertical-align: -9px; } '+
            '#svg_d0 svg { fill: #009688; } '+
            '#svg_d1 svg { fill: #ff9800; } '+
            '#svg_d2 svg { fill: #607d8b; } '+
            '._2sLQpDcQ svg { transition: .2s; } '+
            '._2sLQpDcQ:hover { opacity: 1; } '+
            '._2sLQpDcQ:hover svg { fill: #fff !important; background: #2196f3; }'+
            '</style>';

        if(!document.querySelector('#aambh_style')){
            document.documentElement.insertAdjacentHTML('beforeend', aambh_style); }


        let toHome=document.querySelector('._2sLQpDcQ:nth-child(2)');
        toHome.addEventListener('click', function(event){
            event.preventDefault();
            if(event.shiftKey){
                location.href='https://www.ameba.jp/'; }
            else{
                if(document.referrer=='https://www.ameba.jp/'){
                    window.close(); }
                else{
                    window.location.href='https://www.ameba.jp/'; }}});



        if(location.hash=='#cbox'){ // #cbox付きURLで開かれた場合
            let aid_comm=
                '<style id="aid_comm">'+
                'html { scroll-behavior: unset; } '+
                'body { zoom: unset !important; '+
                'transform: unset !important; width: unset !important; } '+
                '.comm_wrapp { '+
                'display: flex; flex-direction: column; '+
                'position: fixed !important; z-index: 1999 !important; '+
                'top: 60px; left: calc(50% - 360px); '+
                'width: 620px; margin: 0; padding:20px 60px 20px 40px !important; '+
                'max-height: 80vh; overflow-y: auto; color: #000; background: #fff; '+
                'border: 2px solid #aaa; box-shadow: 0 0 0 100vw rgb(0 0 0 / 25%); } '+
                '.comm_wrapp *:not([data-uranus-icon]) '+
                '{ font: 16px Meiryo; color: #000 !important; } '+
                '.comm_wrapp .clear_reset { '+
                'position: fixed; top: 83px; left: calc(50% + 300px); '+
                'height: 26px; width: 26px; padding: 0 5px; cursor: pointer; } '+

                // 新タイプスキン
                '.skin-bgQuiet { background: #f6f8f9; } '+
                '.skin-borderLoud, .skin-borderQuiet { border-color: #888; } '+
                '#commentsHeader { margin-top: 0; } '+
                '[data-uranus-component="mainWidgetFooter"] { '+
                'order: -1; padding: 0; } '+
                '[data-uranus-component="mainWidgetFooter"] button, '+
                '[data-uranus-component="mainWidgetFooter"] .commentWinOpenBtn { '+
                'background: #eceff1; height: 28px; border: 1px solid #777; '+
                'border-radius: 3px; } '+
                '[data-uranus-component="mainWidgetFooter"] span { '+
                'vertical-align: -9px; } '+

                // 旧タイプスキン
                '.skinStrongBgColor { background: #f6f8f9; } '+
                '.skinBorderHr, .skinBorderList li { border-color: #888; } '+
                '.skinBorderHr { flex-shrink: 0; } '+
                '.commentOpenArea.skinWeakColor { display: none; } '+
                '.commentBtnArea { order: -1; padding: 0; } '+
                '.commentBtnArea .commentWinOpenBtn { '+
                'background: #eceff1; height: 28px; border: 1px solid #777; '+
                'border-radius: 3px; } '+
                '.commentBtnArea span { padding: 3px 0 0; vertical-align: -4px; } '+

                //レトロタイプスキン
                '#comment_module p.list { display: none; } '+
                '#comment_module .commentWinOpenBtn { '+
                'order: -1; height: 28px; margin: 0 auto; } '+
                '</style>';

            if(!document.querySelector('#aid_comm') && once==0){
                document.documentElement.insertAdjacentHTML('beforeend', aid_comm); }


            if(once==0){
                let main=document.querySelector('#main');
                if(main){
                    main.scrollIntoView({ block: "end" }); }} // 本文末尾へスクロール

            setTimeout(()=>{
                let cbox=document.querySelector('#cbox');
                if(!cbox){
                    aid_comm_remove(); // 🔵
                    once=1; }
            }, 10000); // 10sec以降は「コメント欄」を表示する操作を停止 🔴


            let cbox=document.querySelector('#cbox');
            if(cbox){
                once=1; // コメント欄の取得でスクロール指示を停止
                // 新タイプスキン
                if(document.querySelector('[data-uranus-component="mainWidget"]')){
                    let cbox_wrapp=cbox.closest('[data-uranus-component="mainWidget"]');
                    cbox_wrapp.classList.add('comm_wrapp'); }
                // 旧タイプスキン
                else if(document.querySelector('.commentArea')){
                    document.querySelector('.commentArea').classList.add('comm_wrapp'); }
                // レトロタイプスキン
                else if(document.querySelector('#comment_module')){
                    document.querySelector('#comment_module').classList.add('comm_wrapp'); }}


            let commWrapp=document.querySelector('.comm_wrapp');
            if(commWrapp){
                if(!commWrapp.querySelector('.clear_reset')){
                    commWrapp.insertAdjacentHTML('beforeend',
                                                 '<input type="button" class="clear_reset" value="✖">'); }

                let clear_reset=commWrapp.querySelector('.clear_reset');
                if(clear_reset){
                    clear_reset.onclick=function(){
                        clear_reset.remove();
                        aid_comm_remove();
                        history.pushState('0', '0', location.href.replace(/#cbox/, '')); }} //「#cbox」削除


                let commMore=
                    document.querySelector('[data-uranus-component="commentsMoreButton"]');
                if(commMore){
                    commMore.click(); }


                let commMore_o=
                    document.querySelector('#commentListMoreLink');
                if(commMore_o){
                    commMore_o.click(); }}



            if(once==0){
                let mainWidget=document.querySelector('[data-uranus-component="mainWidget"]');
                if(mainWidget){
                    setTimeout(()=>{
                        let cbox=document.querySelector('#cbox');
                        if(!cbox){
                            aid_comm_remove(); // 🔵
                            once=1; }
                    }, 100); }} // 新タイプスキンで「コメント欄」が無い場合は操作を停止


            function aid_comm_remove(){
                let aid_comm=document.querySelector('#aid_comm');
                if(aid_comm){
                    aid_comm.remove(); }}

        } // #cbox付きURLで開かれた場合
    } // main()
} // 通常のブログページ等




if(location.href=='https://www.ameba.jp/home'){ //「HOME」画面の場合
    let clean_edit=0; // 表示・非表示設定 作業フラグ

    let target1=document.querySelector('head');
    let monitor1=new MutationObserver(main);
    monitor1.observe(target1, { childList: true });

    main();

    function main(){
        let blog_link=document.querySelector('.HomeBlogModule_BlogTitle_Link');
        if(blog_link){
            blog_link.setAttribute('target', '_blank'); }

        let lback=document.querySelector('.HomeBlogModule_LookBackEntry_Article');
        if(lback){
            lback.setAttribute('target', '_blank'); }

        let brank=document.querySelectorAll('.HomeBlogFeed_Article_BlogRanking_Link');
        for(let k=0; k<brank.length; k++){
            brank[k].setAttribute('target', '_blank'); }

        let trankt=document.querySelectorAll('.HomeBlogFeed_Article_TopicsRanking_Top3_Link');
        for(let k=0; k<trankt.length; k++){
            trankt[k].setAttribute('target', '_blank'); }

        let trank=document.querySelectorAll('.HomeBlogFeed_Article_TopicsRanking_Item_Link');
        for(let k=0; k<trank.length; k++){
            trank[k].setAttribute('target', '_blank'); }



        //「ブログ管理」のリンクが無い時に代りのボタンを表示
        setTimeout(()=>{
            Add_acc(); }, 2000);

        function Add_acc(){
            let HBT=document.querySelector('.HomeBlogModule_BlogTitle');
            let HAC=document.querySelector('.HomeBlogModule_Access_Container');
            if(HBT){
                if(!HAC){
                    let hac_h='<a class="HomeBlogModule_Access_Container Tap_Transparent extra" '+
                        'href="https://blog.ameba.jp/ucs/top.do">管理トップ画面を開く</a>'+
                        '<style>.HomeBlogModule_Access_Container.extra { position: relative; '+
                        'height: 3px; padding: 10px 40px 20px; text-align: right; text-decoration: none; } '+
                        '.HomeBlogModule_Access_Container.extra::before, '+
                        '.HomeBlogModule_Access_Container.extra::after { top: 6px !important; }</style>';

                    let extra=document.querySelector('.extra');
                    if(!extra){
                        HBT.insertAdjacentHTML('afterend', hac_h); }}}}



        // 「お知らせ」の表示をシンプルに見易くする
        notify();

        function notify(){
            let note_button=document.querySelectorAll('.HomeRedNotification_Item button');
            for(let k=0; k<note_button.length; k++){
                note_button[k].style.margin='2px 0';
                let n_span=note_button[k].querySelector('span');
                if(clean_edit==0){
                    ellipsis(n_span); }

                if(n_span){
                    if(n_span.textContent.includes('あなたのブログ記事に新しくいいね!')){
                        n_span.innerHTML=short_i(n_span); }
                    else if(n_span.textContent.includes('に承認待ちコメントがあります')){
                        n_span.innerHTML=short_c1(n_span); }
                    else if(n_span.textContent.includes('に承認待ちのコメントがつきました')){
                        n_span.innerHTML=short_c2(n_span); }
                    else if(n_span.textContent.includes('にコメントしました')){
                        n_span.innerHTML=short_c3(n_span); }
                    else if(n_span.textContent.includes('へのコメントが承認されました')){
                        n_span.innerHTML=short_c4(n_span); }
                    else if(n_span.textContent.includes('メッセージが届きました')){
                        n_span.innerHTML=short_m(n_span); }
                    else if(n_span.textContent.includes('というメッセージが届いています')){
                        n_span.innerHTML=short_m2(n_span); }
                    else if(n_span.textContent.includes('さんがフォロワーになりました')){
                        n_span.innerHTML=short_f(n_span); }
                    else if(n_span.textContent.includes('さんからフォロー申請が届いています')){
                        n_span.innerHTML=short_f1(n_span); }
                    else if(n_span.textContent.includes('さんがフォロー申請を承認しました')){
                        n_span.innerHTML=short_f2(n_span); }
                    else if(n_span.textContent.includes('さんからアメンバー申請が届いています')){
                        n_span.innerHTML=short_a(n_span); }
                    else if(n_span.textContent.includes('さんがアメンバー申請を承認しました')){
                        n_span.innerHTML=short_a1(n_span); }
                    else if(n_span.textContent.includes('マンガクーポンが')){
                        n_span.innerHTML=short_b(n_span); }
                }}


            function short_i(n_p){
                return 'いいね!<b style="color: #aaa">✤</b> ブログにいいね!がつきました'; }

            function short_c1(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('コメントがあります'));
                return 'コメント<b style="color: red">✤</b> '+ np; }

            function short_c2(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('のコメントがつきました'));
                return 'コメント<b style="color: red">✤</b> '+ np; }

            function short_c3(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('コメントしました'));
                return 'コメント<b style="color: red">✤</b> '+ np; }

            function short_c4(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('が承認されました'));
                return 'コメント承認済<b style="color: red">✤</b> '+ np; }

            function short_m(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('メッセージが届きました'));
                return 'メッセージ<b style="color: #ff9800">✤</b> '+ np +'着信'; }

            function short_m2(n_p){
                let np=n_p.textContent;
                let ans=np.match(/「.*?」というメッセージが届いています/)
                if(ans){
                    np=np.replace(ans, '');
                    return 'メッセージ<b style="color: #ff9800">✤</b> '+ np +'着信'; }}

            function short_f(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('がフォロワーになりました'));
                return 'フォロー<b style="color: #4caf50">✤</b> '+ np +'がフォロー'; }

            function short_f1(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('からフォロー申請が届いています'));
                return 'フォロー申請<b style="color: #4caf50">✤</b> '+ np +'が申請'; }

            function short_f2(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('がフォロー申請を承認しました'));
                return 'フォロー承認済<b style="color: #4caf50">✤</b> '+ np +'が承認'; }

            function short_a(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('からアメンバー申請が届いています'));
                return 'アメンバー申請<b style="color: #2196f3">✤</b> '+ np +'が申請'; }

            function short_a1(n_p){
                let np=n_p.textContent;
                np=np.substring(0, np.indexOf('がアメンバー申請を承認しました'));
                return 'アメンバー承認済<b style="color: #2196f3">✤</b> '+ np +'が承認'; }

            function short_b(n_p){
                let np=n_p.textContent;
                np=np.substring(np.indexOf('マンガクーポンが') + 8);
                np=np.substring(0, np.indexOf('あります。'));
                if(np.includes('件')){
                    np=np +'あります'; }
                else{
                    np='1件あります'; }
                return 'マンガクーポン <b style="color: #2196f3">▩</b> '+ np; }

            function ellipsis(n_p){
                n_p.style.cssText=
                    'display: block; width: 340px; padding-left: 5px; '+
                    'overflow: hidden; white-space: nowrap; text-overflow: ellipsis; '; }}



        cleaner();

        function cleaner(){
            let set_word; // ストレージ登録データ
            let d_word=[]; // 検索語の配列

            clear_disp(0);

            let HUPB_h3=document.querySelector('.HomeUserProfileBody h3');
            if(HUPB_h3){

                let SVG_ambh=
                    '<svg id="svg_ambh" viewBox="0 0 150 150" style="height: 16px; '+
                    'margin: 2px 10px -3px; fill: #2196f3; cursor: pointer;">'+
                    '<path d="M66 13C56 15 47 18 39 24C-12 60 18 146 82 137C92 135 '+
                    '102 131 110 126C162 90 128 4 66 13M68 25C131 17 145 117 81 125C16 '+
                    '133 3 34 68 25M69 40C61 41 39 58 58 61C66 63 73 47 82 57C84 60 '+
                    '83 62 81 65C77 70 52 90 76 89C82 89 82 84 86 81C92 76 98 74 100 66'+
                    'C105 48 84 37 69 40M70 94C58 99 66 118 78 112C90 107 82 89 70 94z">'+
                    '</path></svg>'+
                    '<style>'+
                    '.HomeUserProfileBody h3 { cursor: pointer; } '+
                    '.HomeUserProfileBody h3:hover { color: #fff; '+
                    'box-shadow: inset 0 21px 0 0 #237988, 0 -2px 0 2px #237988; }</style>';

                if(!document.querySelector('#svg_ambh')){
                    HUPB_h3.insertAdjacentHTML('afterend', SVG_ambh); }

                let help=document.querySelector('#svg_ambh');
                if(help){
                    help.onclick=function(){
                        let url='https://ameblo.jp/personwritep/entry-12736445680.html';
                        window.open(url, '_blank'); }}


                HUPB_h3.onclick=function(){
                    clean_edit=1;

                    let clean_box=
                        '<div id="clean_box">'+
                        '<input id="word_set" type="text"> '+
                        '<input id="clean_set" type="button" value="Set"> '+
                        '<input id="close" type="button" value="✖">'+
                        '</div>'+
                        '<style>'+
                        '#clean_box { position: fixed; top: 70px; left: calc(50% - 540px); '+
                        'font: normal 16px Meiryo; padding: 20px; background: #fff; '+
                        'border: 1px solid #aaa; box-shadow: 10px 20px 50px rgb(0 0 0 / 25%); } '+
                        '@media screen and (max-width: 1140px){ #clean_box { left: 20px; }} '+
                        '#word_set { width: 300px; padding: 4px 6px 2px; } '+
                        '#clean_set, #close { padding: 4px 4px 2px; }'+
                        '</style>';

                    if(!document.querySelector('#clean_box')){
                        document.body.insertAdjacentHTML('beforeend', clean_box); }
                    else{
                        clean_edit=0;
                        clear_disp(0);
                        document.querySelector('#clean_box').remove(); }

                    let word_set=document.querySelector('#clean_box #word_set');
                    let clean_set=document.querySelector('#clean_box #clean_set');
                    let close=document.querySelector('#clean_box #close');
                    if(word_set){

                        clear_disp(1);

                        word_set.value=set_word; // 初期値を表示
                        word_set.addEventListener('change', function(){
                            let input_word=word_set.value;
                            clean_set.onclick=function(){
                                let tmp_word=input_word.split(/[\x20\u3000]/);
                                tmp_word.forEach((val)=>{
                                    val=val.replace(/\s/g, ''); }) // 配列全要素から再度 空白文字を削除
                                tmp_word=tmp_word.filter(Boolean); // 空要素を削除
                                word_set.value=tmp_word.join(' ');
                                set_word=word_set.value;
                                let write_json=JSON.stringify(set_word);
                                localStorage.setItem('aid_ambh_set', write_json); // ローカルストレージ保存

                                clear_disp(1); }});

                        close.onclick=function(){
                            clean_edit=0;
                            clear_disp(0);
                            document.querySelector('#clean_box').remove(); }
                    }}}


            function clear_disp(n){
                let HUPB_h3=document.querySelector('.HomeUserProfileBody h3');

                let read_json=localStorage.getItem('aid_ambh_set'); // ローカルストレージ保存名
                set_word=JSON.parse(read_json);
                if(set_word==null){
                    set_word=''; }

                d_word=set_word.split(/\x20/);
                let reg_text=d_word.join('|');
                let regexp=new RegExp(reg_text);

                let count=0;
                let HRN_I=document.querySelectorAll('.HomeRedNotification_Item');
                for(let k=0; k<HRN_I.length; k++){
                    let text=HRN_I[k].textContent;
                    let button=HRN_I[k].querySelector('button');
                    let span=HRN_I[k].querySelector('span');
                    if(set_word!='' && regexp.test(text)){ // 設定した語がヒットする場合
                        count+=1;
                        if(n==0 && clean_edit==0){
                            HRN_I[k].style.display='none';
                            button.style.pointerEvents='auto';
                            button.style.userSelect='none';
                            span.style.whiteSpace='nowrap'; }
                        if(n==1){
                            HRN_I[k].style.display='list-item';
                            HRN_I[k].style.background='#e4ecf1';
                            button.style.pointerEvents='none';
                            button.style.userSelect='auto';
                            span.style.whiteSpace=''; }}
                    else{
                        if(n==0 && clean_edit==0){
                            HRN_I[k].style.display='list-item';
                            button.style.pointerEvents='auto';
                            button.style.userSelect='none';
                            span.style.whiteSpace='nowrap'; }
                        if(n==1){
                            HRN_I[k].style.display='list-item';
                            HRN_I[k].style.background='';
                            button.style.pointerEvents='none';
                            button.style.userSelect='auto';
                            span.style.whiteSpace=''; }}}

                let titlebadge=document.querySelector('.PcToggleModule_TitleBadge');
                if(titlebadge){
                    HRN_I.length - count
                    titlebadge.textContent=HRN_I.length - count;
                    if(count>0){
                        if(HUPB_h3){
                            let span_c=
                                '<span class="db" style="margin-left: 8px; padding: 0 6px; '+
                                'font-size: 1.4rem; color: #fff; background: #cfe1eb; '+
                                'border-radius: 30px; vertical-align: 2px;">'+ count +'</span>';

                            if(!HUPB_h3.querySelector('.db')){
                                HUPB_h3.insertAdjacentHTML('beforeend', span_c); }}}
                    else{
                        if(HUPB_h3.querySelector('.db')){
                            HUPB_h3.querySelector('.db').remove(); }}}
            } // clear_disp(n)
        } // cleaner()

    } // main()



    //「フォローフィード」のリンクを「Shift+Click」で直接「コメント欄を開く」
    let target2=document.querySelector('.HomeChecklist');
    let monitor2=new MutationObserver(add_hash_f);
    monitor2.observe(target2, {childList: true, subtree: true});

    add_hash_f();

    function add_hash_f(){
        let HCCI=document.querySelectorAll('.HomeChecklist_Collection_Item');
        for(let k=0; k<HCCI.length; k++){
            let HCA_link=HCCI[k].querySelector('a.HomeChecklist_Article_Link');
            if(HCA_link){
                HCA_link.onclick=function(event){
                    if(event.shiftKey){
                        event.preventDefault();
                        let href=HCA_link.getAttribute('href');
                        window.open(href+'#cbox', '_blank');
                        setTimeout(()=>{
                            all_item_bar(0);
                            all_item_bar_c(0)
                        }, 400); }}}}

        document.addEventListener('keydown', function(event){
            if(event.shiftKey){
                all_item_bar(1); }});

        document.addEventListener('keyup', function(event){
            if(!event.shiftKey){
                all_item_bar(0); }});

    } // add_hash_f()


    function all_item_bar(n){
        let HCCI=document.querySelectorAll('.HomeChecklist_Collection_Item');
        for(let k=0; k<HCCI.length; k++){
            if(n==0){
                HCCI[k].style.boxShadow=''; }
            else{
                let M_icon=HCCI[k].querySelector('.HomeChecklist_Article_Meta_Icon');
                if(M_icon){
                    HCCI[k].style.boxShadow='-8px 0 0 #cfd8dc'; }}}}



    //「コメントした記事」のリンクを直接「コメント欄を開く」仕様に変更
    let retry=0;
    let interval=setInterval(wait_target, 400);
    function wait_target(){
        retry++;
        if(retry>20){ // 8sec まで観測
            clearInterval(interval); }
        let target=document.querySelector('.HomeBlogComment_Collection a');
        if(target){
            clearInterval(interval);
            add_hash_c();
            later(); }}


    function later(){
        let more_c=document.querySelector('.HomeBlogComment .Collection_ReadMore_Button');
        if(more_c){
            more_c.onclick=function(){
                setTimeout(()=>{
                    add_hash_c(); }, 1000); }}} // later()


    function add_hash_c(){
        //「コメントした記事」のリンクを直接「コメント欄を開く」仕様に変更
        let HBCC_link=document.querySelectorAll('.HomeBlogComment_Collection a');
        for(let k=0; k<HBCC_link.length; k++){
            HBCC_link[k].onclick=function(event){
                if(event.shiftKey){
                    event.preventDefault();
                    let href=HBCC_link[k].getAttribute('href');
                    window.open(href+'#cbox', '_blank');
                    setTimeout(()=>{
                        all_item_bar_c(0);
                        all_item_bar(0)
                    }, 400); }}}

        document.addEventListener('keydown', function(event){
            if(event.shiftKey){
                all_item_bar_c(1); }});

        document.addEventListener('keyup', function(event){
            if(!event.shiftKey){
                all_item_bar_c(0); }});


        //「スタッフブログ」のリンクを「Shift+Click」で直接「コメント欄を開く」
        let stuff_link=document.querySelector('.PcModuleNotification_Link');
        if(stuff_link){
            stuff_link.onclick=function(event){
                if(event.shiftKey){
                    event.preventDefault();
                    let href=stuff_link.getAttribute('href');
                    if(!href.match(/#cbox/)){
                        window.open(href+'#cbox', '_blank'); }}}}

    } // add_hash_c()


    function all_item_bar_c(n){
        let HBCC_link=document.querySelectorAll('.HomeBlogComment_Collection a');
        for(let k=0; k<HBCC_link.length; k++){
            if(n==0){
                HBCC_link[k].style.boxShadow=''; }
            else{
                HBCC_link[k].style.boxShadow='-8px 0 0 #cfd8dc'; }}}


} //「HOME」画面の場合




if(location.href=='https://www.ameba.jp/notifications'){ //「お知らせ」画面の場合
    let pc_logo=document.querySelector('h1.PcHeader_Logo');
    if(pc_logo){
        pc_logo.title="◀ HOME";
        pc_logo.onclick=function(e){
            e.preventDefault();
            window.location.href='https://www.ameba.jp/home'; }}


    let target3=document.querySelector('head');
    let monitor3=new MutationObserver(add_hash_n);
    monitor3.observe(target3, { childList: true });

    add_hash_n();

    function add_hash_n(){
        let notifi_link=document.querySelectorAll('.NotificationListItem');
        for(let k=0; k<notifi_link.length; k++){
            let href=notifi_link[k].getAttribute('href');
            if(href.match(/comment-/) && !href.match(/#cbox/)){ //「コメント承認」のお知らせ
                notifi_link[k].setAttribute('href', href+'#cbox');
                notifi_link[k].setAttribute('target', '_blank');
                notifi_link[k].style.boxShadow='inset 8px 0 0 #cfd8dc'; }}


        let mannga_count=0;
        for(let k=0; k<notifi_link.length; k++){
            let href=notifi_link[k].getAttribute('href');
            if(href.match(/dokusho-ojikan.jp/)){ //「マンガクーポン」のお知らせ
                mannga_count+=1;
                if(mannga_count>1){
                    notifi_link[k].remove(); }}}

        let unei_count=0;
        for(let k=0; k<notifi_link.length; k++){
            let message=notifi_link[k].querySelector('.NotificationListItem_Message');
            if(message.textContent.includes('アメーバ運営局からメッセージが')){ //「運営メッセージ」のお知らせ
                unei_count+=1;
                if(unei_count>1){
                    notifi_link[k].remove(); }}}
    } //  add_hash_n()
} //「お知らせ」画面の場合




if(location.pathname.startsWith('/ucs/comment/commentlist')){ //「コメント管理」画面の場合
    let UL_link=document.querySelectorAll('.userList__titleLink');
    for(let k=0; k<UL_link.length; k++){
        UL_link[k].onclick=function(event){
            if(event.shiftKey){
                event.preventDefault();
                let href=UL_link[k].getAttribute('href');
                window.open(href+'#cbox', null, '_blank');
                setTimeout(()=>{
                    all_item_rest();
                }, 1000); }}}


    document.onkeydown=function(event){
        if(event.shiftKey){
            let ULI=document.querySelectorAll('.userList__item');
            for(let k=0; k<ULI.length; k++){
                ULI[k].style.boxShadow='-1px 0 #fff, -8px 0 #cfd8dc'; }}}


    document.onkeyup=function(event){
        if(!event.shiftKey){
            all_item_rest(); }}


    function all_item_rest(){
        let ULI=document.querySelectorAll('.userList__item');
        for(let k=0; k<ULI.length; k++){
            ULI[k].style.boxShadow=''; }}
} //「コメント管理」画面の場合




if(location.pathname=='/ucs/iine/list.html'){ //「いいね!履歴」ページで有効
    if(document.referrer=='https://www.ameba.jp/'){
        window.location.href='https://blog.ameba.jp/ucs/top.do'; }}




if(location.hostname=='msg.ameba.jp'){ //「メッセージ」ページで有効
    let profile=document.querySelector('.ucsSubenu-item a[title="プロフィール"]');
    if(profile){
        profile.textContent='管理トップ';
        profile.title='管理トップ';
        profile.target='_self';
        profile.href='https://blog.ameba.jp/ucs/top.do';
        let css=
            '<style>'+
            '#ucsSubMenu li:nth-child(2) a:before { content: "\\EA31" !important; '+
            'font-size: 23px !important; position: absolute; }</style>'
        profile.insertAdjacentHTML('afterend', css); }}

 

 

 

「Aid AmbH」最新版について 

旧いバージョンの JavaScriptツールは、アメーバのページ構成の変更で動作しない場合があり、導入する場合は最新バージョンをお勧めします。

 

●「Aid AmbH」の最新バージョンへのリンクは、以下のページのリンクリストから探せます。