「お知らせ」画面で増殖する「いいね!」の件

以前のページで書きましたが、「いいねが付きました」の履歴が「お知らせ」画面で増殖する件ですが、「3月14日」に始まっていて、今日は「3月15日」以前が削除されたので、ちょうど 1ヵ月の保存という設定の様です。

 

 

上記ページで、これを纏める機能を追加しましたが、今後は安心して使えます。

 

 

 

 「コメント管理」から ブログのコメント欄にジャンプ

私は、「コメント管理画面」で返信を書く場合が多いのですが、書いた返事がブログページのコメント欄で変でないか、時々気になって見に行きます。 先日もそんな事があり、自分のコメント欄がすぐに表示できないので、ここでも「Aid AmbH」を使える様にする事にしました。

 

下は、早速コードを作のテストしている所です。

 

「Aid AmbH」は、通常のページを開くボタン(リンク要素)が並んだ画面に対して「Shift」キーを押した場合に、リンク先ページに「コメント」がある場合は、そのコメント欄を直接に開く機能があります。

 

このキー操作は「Shift」キー押下に統一して覚え易くしていますが、コメント欄へのリンクが用意された事を示す「グレー色の縦バー」を表示する様にしています。 今回の「コメント管理」ページでも、このデザインを統一しました。

 

下は、「コメント管理」ページで「Shift」キーを押した状態です。

 

 

赤矢印の部分が、縦バーの表示です。 この画面では、全ての項目にマークが付きますが、この状態はどのリンク(記事のタイトル部)をクリックしても、それぞれの記事のコメント欄が開きます。

 

頻繁に使う事はないと思いますが、なにげに便利な時があると思います。

 

 

 

「Aid AmbH」の扱い方 

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

 

 

 

 

「Aid AmbH」を利用するには 

 

❶ 拡張機能「Tampermonkey」の導入

「Tampermonkey」の導入手順は、以下のページを参照ください。

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

 

 

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

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

 

 

 

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

 

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

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

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

 

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

 

 

〔 Aid AmbH 〕ver. 1.3

 

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


if(location.hostname!='www.ameba.jp' && location.hostname!='blog.ameba.jp'){ // 通常のブログページ等
    let once=0; // 処理の複数回動作を抑止

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

    main();

    function main(){
        let amember=
            document.querySelector('[data-uranus-component="amemberLabel"]');

        let toHome;
        if(!amember){
            toHome=document.querySelector('._2sLQpDcQ:nth-child(2)'); }
        else if(amember){
            toHome=document.querySelector('.-ameblo-cmnhf-mypage a'); }


        let css;
        if(!amember){
            let amb_header=document.querySelector('#ambHeader');
            let icon=document.querySelectorAll('._2sLQpDcQ svg');
            if(icon.length=='3'){
                let svg0=
                    '<svg width="24" height="24" 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="24" height="24" 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="24" height="24" 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]); }}}

            css=
                '._2sLQpDcQ svg { '+
                'border: 1px solid #aaa; border-radius: 4px; transition: .2s;'+
                'padding: 0 2px; 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; }'; }


        else if(amember){
            css=
                '#ambHeader a:hover { text-decoration: none; } '+
                '#ambHeader .-ameblo-cmnhf-icon { '+
                'width: auto !important; height: 17px !important; '+
                'margin: 0 4px 0 15px !important; padding: 2px 1px 3px 1px !important; '+
                'border: 1px solid #aaa; border-radius: 4px; '+
                'vertical-align: -8px !important; background-image: none !important; } '+
                '#ambHeader .-ameblo-cmnhf-icon:before { '+
                'font: 24px/19px ameba-symbols; transition: .2s; } '+
                '.-ameblo-cmnhf-mypage .-ameblo-cmnhf-icon:before { '+
                'content: "\\EA1e"; color: #009688; } '+
                '.-ameblo-cmnhf-mypage:hover .-ameblo-cmnhf-icon { '+
                'background: #2196f3 !important; } '+
                '.-ameblo-cmnhf-mypage:hover .-ameblo-cmnhf-icon:before { '+
                'color: #fff !important; } '+
                '.-ameblo-cmnhf-pigg .-ameblo-cmnhf-icon:before { '+
                'content: "\\EA3b"; color: #ff9800; } '+
                '.-ameblo-cmnhf-pigg:hover .-ameblo-cmnhf-icon { '+
                'background: #2196f3 !important; } '+
                '.-ameblo-cmnhf-pigg:hover .-ameblo-cmnhf-icon:before { '+
                'color: #fff !important; } '+
                '.-ameblo-cmnhf-blog .-ameblo-cmnhf-icon:before { '+
                'content: "\\EA31"; color: #607d8b; } '+
                '.-ameblo-cmnhf-blog:hover .-ameblo-cmnhf-icon { '+
                'background: #2196f3 !important; } '+
                '.-ameblo-cmnhf-blog:hover .-ameblo-cmnhf-icon:before { '+
                'color: #fff !important; }'; }

        let base=document.querySelector('body');
        let style=document.createElement('style'); // ambHeader のアレンジ
        style.setAttribute("id", "aambh_style");
        style.innerHTML=css;
        if(!base.querySelector('#aambh_style')){
            base.appendChild(style); }


        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で開かれた場合
            if(!document.querySelector('#aid_comm')){
                document.documentElement.insertAdjacentHTML(
                    'beforeend',
                    '<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: 100 !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: absolute; top: 20px; right: 15px; '+
                    '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(once==0){
                let body_height=document.body.scrollHeight;
                window.scrollTo(0, body_height);
                once=1; }


            let cbox=document.querySelector('#cbox');
            if(cbox){
                // 新タイプスキン
                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();

                        let aid_comm=document.querySelector('#aid_comm');
                        if(aid_comm){
                            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(); }}

        } // #cbox付きURLで開かれた場合

    } // main()
} // 通常のブログページ等



if(location.href=='https://www.ameba.jp/home'){ //「HOME」画面の場合

    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'); }


        //「コメントした記事」のリンクを直接「コメント欄を開く」仕様に変更
        add_hash_c();

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

        function add_hash_c(){
            let comm_link=document.querySelectorAll('.HomeBlogComment_Collection a');
            for(let k=0; k<comm_link.length; k++){
                let href=comm_link[k].getAttribute('href');
                if(!href.match(/#cbox/)){
                    comm_link[k].setAttribute('href', href+'#cbox'); }}}


        //「スタッフブログ」のリンクを「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', null, '_blank'); }}}}

    } // main()


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

    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', null, '_blank');
                        setTimeout(()=>{
                            all_item_rest();
                        }, 1000); }}}}


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


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


        function all_item_rest(){
            let HCCI=document.querySelectorAll('.HomeChecklist_Collection_Item');
            for(let k=0; k<HCCI.length; k++){
                HCCI[k].style.boxShadow=''; }}

    } // add_hash_f()

} //「HOME」画面の場合



if(location.href=='https://www.ameba.jp/notifications'){ //「お知らせ」画面の場合
    let iine_max=0;

    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 total='<p>最近の「いいね!」の履歴</p>';
        let iine_count=0;
        for(let k=0; k<notifi_link.length; k++){
            let href=notifi_link[k].getAttribute('href');
            if(href.match(/iine\/list.html/)){ //「いいね!がつきました」のお知らせ
                iine_count+=1;
                if(iine_count<10){
                    let time=notifi_link[k].querySelector('.NotificationListItem_Date');
                    if(time){
                        total+='<p><span class="time_text">'+ time.textContent +'</span>'+
                            time.getAttribute('datetime').replace("T", " ").replace("Z", ""); +'</p>'; }}

                if(iine_count>1){
                    notifi_link[k].remove(); }}}

        if(iine_max<iine_count){
            iine_max=iine_count;

            let list=document.querySelector('.PageNotifications');
            let disp='<div id="iine_disp">'+
                '<div class="NotificationListItem_Image">'+
                '<img src="https://api.amebame.com/graph/5164757434/picture"'+
                'width="36" height="36"></div>'+
                '<div id="iine_total">'+ total +'</div>'+
                '<style>#iine_disp { display: flex; padding: 15px 0; margin: 0 16px; '+
                'border-top: 1px solid #e2e2e2; } #iine_total { margin: 0 17px; } '+
                '.time_text { display: inline-block; width: 65px; font-size: 1.2rem; '+
                'color: #005cd2; }</style>';

            if(list.querySelector('#iine_disp')){
                list.querySelector('#iine_disp').remove(); }
            list.insertAdjacentHTML('beforeend', disp); }}

} //「お知らせ」画面の場合



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=''; }}

} //「コメント管理」画面の場合

 

 

 

「Aid AmbH」最新版について 

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

 

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