記事タイトルの右クリックで起動

「Edit At Once Am」は、任意のアメーバブログページで、その記事タイトルを右クリックして起動します。 右クリックで以下の4個の編集メニューが表示されます。

 

Edit At Once Amブログ編集メニュー

 

➀「再編集」

▪自分のブログを開いている場合、開いている記事を編集画面に開きます。

▪他のブログで押した場合、一旦空白の編集画面が開き、元の画面に戻る。

 

②「新規作成」

 開いているブログとは無関係に、新規の記事の編集画面を開きます。

 

③「リブログ」

 開いているブログのリブログ記事作成の編集画面を開きます。

 

➃「リスト表示」

▪自分のブログを開いている場合、記事の編集・削除の画面を開きます。

 更にリストを検索して、➃を押した記事の欄に赤枠を表示します。

▪他のブログで押した場合、一旦記事の編集・削除の画面を開き、元の画面に戻る。

 

このツールは、現在開いている記事を、直接に再編集をしたり、複製や削除をしたりすることが出来る、とても便利な環境を提供します。 またアメンバー記事でも、その再編集が直接可能です。

 

 

 

 「元画面を遷移する」「元画面を残す」を「Ctrl」キーで選択

ver. 0.7 では、メニューを選択してクリックした場合に、基本的に元のブログ画面を遷移させて実行する様にしていました。(リブログのみ別タブで実行)

 

ところが実運用では、元の画面を残したい場合が多い事が判って来ました。 元画面を残したいので、ついメニュー項目を右クリックしてみるのですが、普通のリンクの様に「新しいタブで開く」といったコンテキストは表示されません。

 

この仕様は不便なので、メニュー項目は全て「元画面を残し別タブで実行」する様にしました。 その代わり「Ctrl」キーを押しながらクリックは「遷移して実行」とし、別タブを開かない事も選択可能にしています。

 

また、「Ctrl」キーを押すと動作が変わる事を示すために、ポインターの乗ったメニューの反転色をグレーにする様にしました。「Shift」や「Ctrl」キーを使い機能拡張する場合が多く、この場合は「Ctrl」が有効な事を判り易くしています。

 

Edit At Once Am: Ctrlキーでメニュー操作

 

 

「Ctrl」キー押下でホバー反転色を変えるコード 

「Ctrl」キーを押すとホバー反転色を変えるのは、CSSとスクリプトの合わせ技で実現しています。

 

<style>
    #eao_menu span:hover { color: #fff; background: #2196f3; }
    #eao_menu.c_active span:hover { background: #90a4ae; }
</style>

 

上は、このツールがページのHTMLに書込む「styleタグ」とCSS内容です。

「#eao_menu」は、右クリックで表示されるメニュー全体です。

「#eao_menu span」は、4個のメニュー項目に相当します。 3行目が今回に追加した指定で、「#eao_menu」に「c_active」のクラスが付与された場合は、メニュー項目のホバー時背景色を「#90a4ae」(グレー)にするという内容です。

 

このCSSを設定した上で、以下のスクリプトコードを実行しています。

 

document.body.addEventListener('keydown', function(event){
    if(event.ctrlKey==true){
        menu.classList.add('c_active');
        document.body.addEventListener('keyup', function(event){
            menu.classList.remove('c_active'); });}});

 

開いたページ上で「Ctrl」キーを押すと、nemu(#eao_menu)に「c_active」のクラスを追加し、キーが戻された時は「c_active」クラスを削除するコードです。

 

以上の2つのコードの機能は、ホバー時の反転背景色を「Ctrl」キー操作で変更するだけのものです。「Ctrl」キーを押しながらメニューをクリックした時の実行動作は、全く別のところで設定しています。

 

 

 

「Edit At Once Am」の導入手順

 

❶「Tampermonkey」を導入します

使用しているブラウザに拡張機能「Tampermonkey」を導入する事が必要です。 以下のページに簡単な導入の説明をしていますから参照ください。

 

   ⭕「Tampermonkey」の導入時の設定とテスト

 

●「Edit At Once Am」は、Chrome / 新Edge / Firefox の「Tampermonkey」で動作を確認しています。 他のブラウザ環境での動作に関しては、成否を問わずコメントいただければ幸いです。

 

❷「Tampermonkey」にスクリプトを登録します

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

 

Tampermonkey新規スクリプトテンプレート

 

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

 

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

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

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

 

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

 

● 旧バージョンはOFFにするか削除をして、新旧の同時ONは避けてください。

  なお、同系統のツール「Edit At Once ⭐」とは同時ONでの使用ができます。

 

 

〔 Edit At Once Am 〕 ver. 0.81

 

// ==UserScript==
// @name         Edit At Once Am
// @namespace    http://tampermonkey.net/
// @version      0.81
// @description  Edit Entry_ID Page
// @author       Ameba Blog User
// @match        https://ameblo.jp/*
// @match        https://secret.ameba.jp/*
// @match        https://blog.ameba.jp/ucs/entry/srventry*
// @grant         none
// ==/UserScript==

icon_click();

let target=document.querySelector('head');
let monitor=new MutationObserver(icon_click);
monitor.observe(target, { childList: true });

function icon_click(){

    if(!document.querySelector('#entryListEdit') && !document.querySelector('.l-body')){
        //「記事の編集・削除」「編集画面」でない場合

        let menu=document.createElement('div');
        menu.innerHTML=
            '<span id="retouch">再編集</span> '+
            '<span id="newwork">新規作成</span> '+
            '<span id="reblog">リブログ</span>'+
            '<span id="file">リスト表示</span>'+
            '<style>#eao_menu { position: absolute; z-index: 20; font: normal 14px Meiryo; '+
            'padding: 3px 10px 1px; border: 1px solid #dadce0; color: #333; background: #fff; '+
            'box-shadow: 4px 4px 2px -2px rgba(0, 0, 0, 0.48); cursor: default; } '+
            '#eao_menu span { padding: 1px 4px 0; } '+
            '#eao_menu span:hover { color: #fff; background: #2196f3; } '+
            '#eao_menu.c_active span:hover { background: #90a4ae; }</style>';
        menu.setAttribute("id", 'eao_menu');
        menu.style.display='none';
        if(!document.getElementById('eao_menu')){
            document.querySelector('body').appendChild(menu); }

        let article=document.querySelector('.js-entryWrapper'); //記事全体
        let title_h; // タイトル部
        let title; // 記事タイトル

        if(article){
            if(article.querySelector('h1')){
                title_h=article.querySelector('h1');
                title=title_h.querySelector('a'); }
            else if(article.querySelector('h2')){
                title_h=article.querySelector('h2');
                title=title_h.querySelector('a'); }
            else if(article.querySelector('h3')){
                title_h=article.querySelector('h3');
                title=title_h.querySelector('a'); }

            if(title){
                title_h.setAttribute("onContextmenu", 'return false;');

                title.addEventListener('contextmenu', function(e){
                    document.getElementById('eao_menu').style.display="block";
                    document.getElementById('eao_menu').style.left=e.pageX+"px";
                    document.getElementById('eao_menu').style.top=e.pageY+"px"; }); }}


        document.body.addEventListener('click', function (e){
            document.getElementById('eao_menu').style.display="none"; });


        document.body.addEventListener('keydown', function(event){
            if(event.ctrlKey==true){
                menu.classList.add('c_active');
                document.body.addEventListener('keyup', function(event){
                    menu.classList.remove('c_active'); });}});


        let retouch=document.getElementById('retouch');
        retouch.onclick=function(event){
            let article=document.querySelector('.js-entryWrapper');
            let entry_id=article.getAttribute('data-unique-entry-id');
            if(entry_id){
                let path=
                    'https://blog.ameba.jp/ucs/entry/srventryupdateinput.do?id='+entry_id;
                if(event.ctrlKey!=true){
                    window.open(path, "_blank"); }
                else{
                    window.location.href=path; }}}


        let newwork=document.getElementById('newwork');
        newwork.onclick=function(){
            let path='https://blog.ameba.jp/ucs/entry/srventryinsertinput.do';
            if(event.ctrlKey!=true){
                window.open(path, "_blank"); }
            else{
                window.location.href=path; }}


        let reblog=document.getElementById('reblog');
        reblog.onclick=function(){
            let article=document.querySelector('.js-entryWrapper');
            let user=article.getAttribute('data-unique-ameba-id');
            let titil_str=article.getAttribute('data-unique-entry-title');
            let entry_id=article.getAttribute('data-unique-entry-id');
            if(user && entry_id){
                let path=
                    'https://blog.ameba.jp/ucs/entry/srventryinsertinput.do?'+
                    'reblog_ameba_id='+user+'&reblog_entry_id='+entry_id+
                    '&entry_title='+titil_str;
                if(event.ctrlKey!=true){
                    window.open(path, "_blank"); }
                else{
                    window.location.href=path; }}}


        let file=document.getElementById('file');
        file.onclick=function(){
            let article=document.querySelector('.js-entryWrapper');
            let user=article.getAttribute('data-unique-ameba-id');
            let entry_id=article.getAttribute('data-unique-entry-id');

            let date=document.querySelector('time').getAttribute('datetime');
            let entry_ym=date.slice(0, 4) + date.slice(5, 7);
            let path=
                'https://blog.ameba.jp/ucs/entry/srventrylist.do?pageID='+
                '1&entry_ym='+entry_ym+'&user='+user+'&entry_id='+entry_id;
            if(event.ctrlKey!=true){
                window.open(path, "_blank"); }
            else{
                window.location.href=path; }}

    } //「記事の編集・削除」「編集画面」でない場合


    if(document.querySelector('#entryListEdit')){ //「記事の編集・削除」の場合
        let arg = new Object;
        let pair=location.search.substring(1).split('&');
        for(let i=0; pair[i]; i++){
            let key=pair[i].split('=');
            arg[key[0]]=key[1]; } // key[0]がkey, key[1]がvalue

        let entry_ym=arg.entry_ym;
        let pageID=parseInt( arg.pageID, 10); // 数値に変換
        let user=arg.user;
        let entry_id=arg.entry_id;

        let amebaId=document.querySelector('#gHeaderRight .amebaId').textContent;
        let entryList_li=document.querySelectorAll('#entryList li');

        if(user!=null){
            if(amebaId!=user){ // 他ユーザーのブログでリスト表示を押した場合
                if(history.length>1){
                    window.history.back(); }
                else{
                    window.close(); }}
            else{
                let k;
                for(k=0; k<entryList_li.length; k++){
                    let entryList_a=entryList_li[k].querySelector('h2 a');
                    if(entryList_a){
                        if(entryList_a.getAttribute('href').indexOf(entry_id)!=-1){
                            entryList_li[k].style.outline='2px solid red';
                            entryList_li[k].scrollIntoView({block: "center"});
                            break; }}}
                if(k==entryList_li.length){
                    pageID+=1;
                    let path=
                        'https://blog.ameba.jp/ucs/entry/srventrylist.do?pageID='+
                        pageID+'&entry_ym='+entry_ym+'&user='+user+'&entry_id='+entry_id;
                    window.location.href=path; }}}
    } //「記事の編集・削除」の場合


    if(document.querySelector('.l-body')){ //「編集画面」の場合
        if(document.querySelector('.l-form form > .error')){ // 他ユーザで再編集を押した場合
            if(history.length>1){
                window.history.back(); }
            else{
                window.close(); }}
    } //「編集画面」の場合

} // icon_click()

 

 

 

「Edit At Once Am」最新版について 

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

 

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