「リブログ」を別タブで開く様にする
「Popup Reblog」は、リブログカードをクリックすると別タブでリンク先ページが開く様にするツールです。 これは常駐型で常にONにしておきます。 リブログカードの有るページを開いた時、カードタイトル部がグレーになり、機能が有効と判ります。
前回の更新で、「Shift」キーを押しながらクリックすると、デフォルトのページ遷移する動作に戻す様にしました。 今回、これを「Ctrl」キーを押しながらクリックするとページ遷移する仕様に変更しました。
また、機能が切換わった事が判り易い様に、「Ctrl」キーを押すとタイトル部の背景色が白になる様にしました。
「Shift」キーを「Ctrl」キーに変更したのは、何度も「Shift」キーを押すと下の様なOSの機能が動作しようとして煩わしいからです。
「Popup Reblog」ver. 0.4 の導入手順
❶「Tampermonkey」を導入します
使用しているブラウザに拡張機能「Tampermonkey」を導入します。 以下のページに簡単な導入の説明をしていますので参照ください。
●「Popup Reblog」ver. 0.4 は Chrome / 新Edge / Firefox の「Tampermonkey」で動作を確認しています。
❷「Tampermonkey」にスクリプトを登録します
「Tampermonkey」の「+」マークの「新規スクリプト」タブを開きます。
●「新規スクリプト」には、最初からテンプレートが記入されています。 これは全て削除して、完全に空白の編集枠に 下のコードをコピー&ペーストします。
〔コピー方法〕 軽量シンプルなツール「PreBox Button 」を使うと
コード枠内を「Ctrl+左Click」➔「Copy code 」を「左Click」
の操作で、掲載コードのコピーが可能になります。
〔 Popup Reblog 〕 ver. 0.4
// ==UserScript== // @name Popup Reblog // @namespace http://tampermonkey.net/ // @version 0.4 // @description リブログリンクを別タブで開く // @author Ameba Blog User // @match https://ameblo.jp/* // @noframes // @grant none // ==/UserScript== let target=document.querySelector('head'); let monitor=new MutationObserver(new_retry); monitor.observe(target, { childList: true }); function new_retry(){ let ua=0; // Chromeの場合のフラグ 新Edgeを含む let agent=window.navigator.userAgent.toLowerCase(); if(agent.indexOf('firefox') > -1){ ua=1; } // Firefoxの場合のフラグ let iframe_doc; let retry=0; let interval=setInterval(wait_iframe_doc, 100); function wait_iframe_doc(){ retry++; if(retry>10){ // リトライ制限 10回 1sec clearInterval(interval); } try{ iframe_doc= document.querySelector('.reblogCard').contentWindow.document; } // 監視 target catch (e){ ; } if(iframe_doc){ clearInterval(interval); let reblog_card=iframe_doc.querySelector('.rb-card'); if(reblog_card){ if(ua==1){ reblog_card.style.pointerEvents='none'; } let data_href=reblog_card.getAttribute('data-href'); let card_head=reblog_card.querySelector('.rb-card__head'); card_head.style.boxShadow= '-14px 0 0 0 #8eb6ca, 14px 0 0 0 #8eb6ca, inset 0 0 0 40px #8eb6ca'; card_head.querySelector('.rb-text-ellipsis').style.color='#fff'; card_head.querySelector('.rb-text-ellipsis').style.fontSize='14px'; card_head.querySelector('.rb-text-ellipsis').style.margin='10px'; if(ua==0){ reblog_card.addEventListener('click', function(event){ event.preventDefault(); event.stopImmediatePropagation(); if(event.ctrlKey==true){ window.location.href=data_href; } else{ window.open(data_href, '_blank'); }}, false); } if(ua==1){ let rb_card_main=reblog_card.querySelector('.rb-card__main'); rb_card_main.style.pointerEvents='auto'; rb_card_main.addEventListener('click', function(event){ event.preventDefault(); event.stopImmediatePropagation(); if(event.ctrlKey==true){ window.location.href=data_href; } else{ window.open(data_href, '_blank'); }}, false); } document.body.addEventListener('keydown', function(event){ if(event.ctrlKey==true){ card_head.style.boxShadow='none'; card_head.querySelector('.rb-text-ellipsis').style.color='#666'; document.body.addEventListener('keyup', function(event){ card_head.style.boxShadow= '-14px 0 0 0 #8eb6ca, 14px 0 0 0 #8eb6ca, inset 0 0 0 40px #8eb6ca'; card_head.querySelector('.rb-text-ellipsis').style.color='#fff'; });}}); }} } // wait_iframe_doc } // new_retry
「Popup Reblog」最新版について
旧いバージョンの JavaScriptツールは、アメーバのページ構成の変更で動作しない場合があり、導入する場合は最新バージョンをお勧めします。
●「Popup Reblog」の最新バージョンへのリンクは、以下のページのリンクリストから探せます。