「Ameba Search Repeat / with CSS」ver. 1.7
「Ameba Search Repeat / with CSS」は、「Stylus」を使えないブラウザや、「Stylus」のページアレンジを使いたくない場合のために、Ameba検索ページのアレンジをスクリプト自体で行う様にしたものです。
「Stylus」の高速なスタイル適用は、「Tampermonkey」上のスクリプトでは、残念ながら真似が出来ません。 このため、起動時や検索語を変更した再検索時に、デフォルトの検索画面が一瞬表示されます。 しかし、この表示上の問題以外、機能は全く同等です。
「Ameba Search Repeat / with CSS」を利用するには、以下のスクリプトコードを「Tampermonkey」にコピー&ペーストして登録してください。 このスクリプトは、Chrome版 / Firefox版 / Edge版 の「Tampermonkey」で動作を確認しています。
〔コピー方法〕 軽量シンプルなツール「PreBox Button 」を使うと
コード枠内を「Ctrl+左Click」➔「Copy code 」を「左Click」
の操作で、掲載コードのコピーが可能になります。
〔 Ameba Search Repeat / width CSS 〕ver. 1.7
// ==UserScript== // @name Ameba Search Repeat / with CSS // @namespace http://tampermonkey.net/ // @version 1.7 // @description ブログ内検索の再検索を実行可能にする // @author Ameba Blog User // @match https://search.ameba.jp/* // @match https://search.ameba.jp/search/entry/* // @run-at document-start // @grant none // ==/UserScript== addEventListener('DOMContentLoaded', function(){ let target=document.querySelector('body'); // 監視 target let monitor=new MutationObserver(catch_env); monitor.observe(target, {childList: true}); // 検索待受け開始 function catch_env(){ if (document.location.href.indexOf("https://search.ameba.jp/search/entry/") ==0){ in_view(); search_next(); } // ブログ内検索の主要スクリプト else{ out_view(); }} function search_next(){ // 検索結果ページごとにURLは更新される let blogDB={}; // 閲覧記事のID/チェックフラグの記録配列 let entry_id_DB; // ID検索用の配列 let read_json=localStorage.getItem('ASR_DB_back'); // ローカルストレージ 保存名 blogDB=JSON.parse(read_json); if(blogDB==null){ blogDB=[['ASR00000000', '0']]; } if(get_userid(0) !=null){ blogDB[0]=['ASR00000000', get_userid(0) ]; } // スクリプト起動時に開いたユーザーIDを記録 let write_json=JSON.stringify(blogDB); localStorage.setItem('ASR_DB_back', write_json); // ローカルストレージ 保存 reg_set(); function reg_set(){ let k; entry_id_DB=[]; // リセット for(k=0; k<blogDB.length; k++){ entry_id_DB[k]=blogDB[k][0]; }} // ID検索用の配列を作成 list_set(); function list_set(){ let entrylist=[]; let entrylink=[]; let entryhref=[]; let history=[]; entrylist=document.querySelectorAll('.PcEntryListItem'); for(let k=0; k<entrylist.length; k++){ entrylink[k]=entrylist[k].querySelector('.PcEntryListItem >a'); entryhref[k]=entrylink[k].getAttribute('href').slice(-16, -5); // entrylink[k].setAttribute('target', '_blank'); // リストのクリックを別タブで開く設定 mark(k); list_listen(k); hmark_listen(k); } function mark(k){ history[k]=document.createElement('p'); history[k].innerText='\u00A0'; history[k].setAttribute('class', 'history'); history[k].setAttribute('style', 'position: absolute; left: 10px; ' + 'width: 14px; height: 14px; border-radius: 4px; background: #fff'); if(entrylink[k].querySelector('.history')){ entrylink[k].querySelector('.history').remove(); } entrylink[k].appendChild(history[k]); let list_size=entrylink[k].getBoundingClientRect().height; let img_size=entrylist[k].querySelector('.UserThumbnail').getBoundingClientRect().height; let top=(list_size + img_size)/2 - 6; history[k].style.top=top + 'px'; // サムネイルとリストの上下間にマークを配置 let index=entry_id_DB.indexOf(entryhref[k]); if(index !=-1){ if(blogDB[index][1]==1){ history[k].style.background='#009688'; } // フラグ1ならグリーン else if(blogDB[index][1]==2){ history[k].style.background='#ff8800'; } // フラグ2ならオレンジ else if(blogDB[index][1]==0){ history[k].style.background='#fff'; }}} // フラグ0なら白 function list_listen(k){ entrylink[k].addEventListener('click', function(){ all_click(); }, false); entrylink[k].addEventListener('contextmenu', function(){ all_click(); }, false); function all_click(){ let index=entry_id_DB.indexOf(entryhref[k]); if(index==-1){ blogDB.push([entryhref[k], 1]); // 閲覧履歴に記事ID/フラグ1を追加 history[k].style.background='#009688'; } // グリーン else{ blogDB[index]=[entryhref[k], 1]; // この記事IDの履歴をフラグ1に更新 history[k].style.background='#009688'; } // グリーン let write_json=JSON.stringify(blogDB); localStorage.setItem('ASR_DB_back', write_json); // ストレージ保存 reg_set(); }} function hmark_listen(k){ history[k].addEventListener('click', function(event){ event.preventDefault(); event.stopImmediatePropagation(); let index=entry_id_DB.indexOf(entryhref[k]); if(index==-1){ blogDB.push([entryhref[k], 1]); // 閲覧履歴に記事ID/フラグ1を追加 history[k].style.background='#009688'; } // グリーン else{ if(blogDB[index][1]==1){ blogDB[index]=[entryhref[k], 2]; // この記事IDの履歴をフラグ2に更新 history[k].style.background='#ff8800'; } // オレンジ(Noteフラグ) else if(blogDB[index][1]==2){ blogDB[index]=[entryhref[k], 0]; // この記事IDの履歴をフラグ0に更新 history[k].style.background='#fff'; } // 白(履歴のフラグをリセット) else if(blogDB[index][1]==0){ blogDB[index]=[entryhref[k], 1]; // この記事IDの履歴をフラグ1に更新 history[k].style.background='#009688'; }} // グリーン let write_json=JSON.stringify(blogDB); localStorage.setItem('ASR_DB_back', write_json); // ストレージ保存 reg_set(); }, false); }} reset_sw(); function reset_sw(){ let box=document.querySelector('.PcResultPagination'); if(box){ let sw=document.createElement('p'); sw.innerText='Reset'; sw.setAttribute('id', 'history_reset'); if(!box.querySelector('#history_reset')){ box.appendChild(sw); } let tooltip=document.createElement('p'); tooltip.innerText='開いた記事のマークをリセット'; tooltip.setAttribute('id', 'sw_tooltip2'); if(!box.querySelector('#sw_tooltip2')){ box.appendChild(tooltip); } sw.addEventListener('click', function(){ let conf_str='🟩 リストの閲覧履歴マークをリセットします'; let ok=confirm(conf_str); if(ok){ blogDB=[['ASR00000000', blogDB[0][1]]]; let write_json=JSON.stringify(blogDB); localStorage.setItem('ASR_DB_back', write_json); // ストレージ保存 reg_set(); list_set(); }}, false); }} back_sw(); function back_sw(){ let box=document.querySelector('.PcNavigationSearch'); let sw=document.createElement('p'); sw.innerText='\u23CF\uFE0E'; sw.setAttribute('id', 'back_blog'); if(!box.querySelector('#back_blog')){ box.appendChild(sw); } let tooltip=document.createElement('p'); tooltip.innerText='ブログTOPへ'; tooltip.setAttribute('id', 'sw_tooltip'); if(!box.querySelector('#sw_tooltip')){ box.appendChild(tooltip); } sw.addEventListener('click', function(){ location.href='https://ameblo.jp/' + blogDB[0][1]; }, false); } let user_id=get_userid(1); if(user_id){ let search_box_react=document.querySelector('#react-autowhatever-1'); if(search_box_react){ search_box_react.remove(); } let search_button=document.querySelector('.PcSearchForm_Button'); search_button.addEventListener('click', function(e){ let input_box=document.querySelector('.PcSuggestForm_Input').value if(input_box!=''){ location.href='https://search.ameba.jp/search/entry/' + input_box + user_id; } e.preventDefault(); e.stopPropagation(); }, false); } function get_userid(n){ let this_url=location.href; let index_after=this_url.indexOf('.html?aid='); let caption=document.querySelector('.PcEntryList_Caption'); if(index_after==-1){ // ブログ内検索から出た時 何もしない if(caption){ caption.textContent='ブログ記事'; caption.style.color='#298538'; caption.style.background='transparent'; }} else{ if(caption){ caption.textContent='ブログ内検索'; caption.style.color='#fff'; caption.style.background='#2196f3'; } let user_id_a=this_url.slice(index_after); let index_before=user_id_a.indexOf('&p='); let user_id; if(index_before==-1){ user_id=user_id_a; } else{ user_id=user_id_a.substring(0, index_before); } if(n==1){ return user_id; } else if(n==0){ user_id=user_id.replace('.html?aid=', ''); return user_id; }}} } // search_next function in_view() { let css = ""; css += [ "/* IN VIEW CSS */", "html {", " overflow-y: scroll;", " overflow-y: overlay;", " background: #c5d8e1; }", "body {", " font-family: Meiryo, sans-serif;", " background: var(--backg); }", "#announcer {", " opacity: 0; }", "#listingAdA,", "#listingAdB {", " display: none; }", ".PcSearchTemplate_AdSenseTop,", ".PcSearchTemplate_AdSenseBottom {", " display: none; }", ".PcSideBar_AdArea {", " display: none; }", "div[id^=\"div-gpt-ad\"] {", " display: none; }", ".PcGlobalFooter {", " display: none; }", "/* Ameba検索 詳細モード *************** */", "body {", " padding: 0 !important; }", ".PcGlobalHeader {", " display: none; }", ".PcDefaultPage_Main {", " min-width: 800px; }", ".PcSearchEntryTemplate_Wrap {", " width: 800px; }", ".PcSearchEntryTemplate_Left {", " width: 728px;", " margin: 10px 0 0;", " overflow: visible; }", ".PcNavigationSearch {", " width: 728px;", " margin: 12px auto; }", ".PcNavigationSearch_Logo {", " margin-right: 20px; }", ".PcNavigationSearch_AmebaLogo {", " margin-right: 0; }", ".PcNavigationSearch_AmebaLogo:after {", " border: none; }", ".AmebaLogo {", " width: 100px; }", ".PcNavigationSearch_Logo > img {", " width: 36px; }", ".PcSearchForm_InputArea {", " border: 1px solid #607d8b;", " border-radius: 6px;", " overflow: hidden;", " padding: 0; }", ".PcSearchForm_InputArea {", " box-shadow: none !important; }", ".PcSuggestForm_Input {", " width: 418px;", " height: 32px;", " padding: 2px 8px 0; }", ".PcSearchForm_Button {", " height: 34px;", " width: 80px;", " border-radius: 0;", " background-color: #2196f3; }", ".PcSearchForm_Button:hover {", " opacity: 1;", " background: #1976d2; }", ".PcSearchForm_Button:focus {", " box-shadow: inset 0 0 0 1px #e1f5fe; }", "#back_blog {", " border: 1px solid #fff;", " border-radius: 6px;", " padding: 4px;", " margin-left: 20px;", " font-size: 24px;", " color: #fff;", " background: #2196f3;", " cursor: pointer; }", "#sw_tooltip {", " position: relative;", " left: -165px;", " white-space: nowrap;", " font-size: 14px;", " padding: 4px 10px 0;", " border: 1px solid #ccc;", " background: #fff;", " box-shadow: 4px 4px 6px 0 rgba(0, 0, 0, 0.5);", " display: none; }", "#back_blog:hover + #sw_tooltip {", " display: block; }", ".PcSuggestForm_SectionTitle {", " top: 36px;", " left: 5px; }", ".PcSuggestForm_SectionTitle button {", " background: #fff;", " border-radius: 4px;", " border: 1px solid #aaa;", " margin-top: -2px; }", ".PcSuggestForm_List {", " top: 36px;", " left: 5px; }", ".PcSuggestForm_List.hasTitle {", " top: 73px;", " left: 5px; }", ".PcNavigationBar {", " display: none; }", ".PcBreadcrumbsList {", " position: absolute;", " top: 74px;", " left: calc(50% + 70px);", " margin-left: -100px;", " padding: 4px 10px;", " z-index: 2; }", "@media screen and (max-width: 800px) {", ".PcBreadcrumbsList {", " left: 470px; } }", ".PcBreadcrumbsList_List {", " white-space: nowrap; }", ".PcEntryList {", " position: relative;", " display: flex;", " flex-direction: column; }", ".PcBreadcrumbsList_Icon {", "margin: 0; }", ".PcEntryList_Header {", " justify-content: initial;", " margin-bottom: 4px;", " border-bottom: 2px solid #efefef;", " order: 0; }", ".PcEntryList_Caption {", " margin: 0 30px 6px 0;", " padding: 5px 10px 2px !important; }", ".PcEntryList_TabList {", " display: none; }", ".PcEntryList_ListInfo {", " position: absolute;", " top: 0;", " left: calc(50% - 210px);", " width: 285px;", " order: 1; }", "@media screen and (max-width: 800px) {", ".PcEntryList_ListInfo {", " left: 154px; } }", ".PcHitCountRange {", " color: #000;", " margin: 8px 0 0;", " max-width: 170px;", " white-space: nowrap;", " overflow: hidden;", " text-overflow: ellipsis; }", ".PcBlogEntryFilter {", " display: none; }", ".PcErrorMessage {", " margin-top: 50px; }", ".PcEntryList {", " margin-bottom: 15px; }", ".PcEntryList_List {", " order: 3; }", ".PcEntryListItem {", " margin-bottom: 2px;", " padding: 2px;", " border: none;", " background: #f4f4f4; }", ".PcEntryListItem:hover {", " outline: 2px solid #2196f3; }", ".PcEntryListItem_Link:hover {", " opacity: 1; }", ".PcEntryListItem .UserThumbnail {", " width: 24px;", " height: 24px;", " margin-left: 4px;", " border-radius: 6px;", " border: 1px solid #ccc; }", ".PcEntryListItem_Entry {", " margin: 0 8px; }", ".PcEntryListItem_ThumbnailIconWrap {", " height: 16px;", " width: 16px;", " bottom: -16px;", " right: -12px; }", ".PcEntryListItem_EntryTitle {", " margin-top: 3px;", " margin-bottom: 2px; }", ".PcEntryListItem_EntryData {", " margin-bottom: 2px;", " height: 13px; }", ".PcEntryListItem_EntryContent {", " line-height: 1.25; }", ".PcEntryListItem_EntryImage {", " flex-basis: 75px;", " height: 75px; }", ".hlword1 {", " color: #333 !important;", " font-weight: inherit !important;", " background: linear-gradient(transparent 1.1em, #f90 0, #f90 calc(1.1em + 3px), transparent 0); }", ".PcEntryListItem_Link {", " position: relative; }", ".PcEntryListItem_Link::before {", " content: '';", " position: absolute;", " left: 10px;", " top: 44.5px;", " width: 14px;", " height: 14px;", " border-radius: 4px;", " background: #f4f4f4; }", ".PcEntryListItem_Link:visited::before {", " background: #2196f3; }", ".PcResultPagination {", " position: relative;", " margin-bottom: 6px;", " padding: 0 80px 4px;", " border-bottom: 2px solid #efefef;", " order: 2; }", ".PcResultPagination_Paging_active,", ".PcResultPagination_PagingLink {", " border-radius: 4px;", " padding: 2px 6px; }", ".PcEntryList .Loading {", " opacity: 0.3;", " order: 4; }", ".PcEntryList .PcEntryList_LoadingDummy {", " order: 5; }", ".PcResultPagination_MoreLink {", " padding: 2px 6px 1px 6px;", " border-radius: 4px; }", ".PcResultPagination_MoreLink:hover {", " background: #fff;", " text-decoration: none; }", ".PcResultPagination_List {", " margin: 0; }", ".PcResultPagination_Paging_active {", " background-color: #1976d2; }", ".PcResultPagination_PagingLink:hover {", " background-color: #fff; }", "#history_reset {", " position: absolute;", " left: 0;", " padding: 2px 6px 0;", " color: #fff;", " border: 1px solid #fff;", " border-radius: 4px;", " background: #009688;", " cursor: pointer; }", "#sw_tooltip2 {", " position: absolute;", " top: -3px;", " left: 70px;", " font-size: 14px;", " padding: 5px 10px 2px;", " border: 1px solid #ccc;", " background: #fff;", " box-shadow: 4px 4px 6px rgba(0, 0, 0, 0.5);", " display: none; }", "#history_reset:hover + #sw_tooltip2 {", " display: block; }", ".PcSideBar {", " display: none; }" ].join(" "); let node = document.createElement("style"); node.type = "text/css"; node.setAttribute("class", "sih"); node.appendChild(document.createTextNode(css)); let heads = document.getElementsByTagName("head"); if(heads[0].querySelector('.sih')){ heads[0].querySelector('.sih').remove(); } heads[0].appendChild(node); } // in_view() function out_view() { let css = ""; css += [ "/* OUT VIEW CSS */", "html {", " overflow-y: scroll;", " overflow-y: overlay;", " background: #c5d8e1; }", "body {", " font-family: Meiryo, sans-serif !important;", " background: var(--backg); }", "#announcer {", " opacity: 0; }", "#listingAdA,", "#listingAdB {", " display: none; }", ".PcSearchTemplate_AdSenseTop,", ".PcSearchTemplate_AdSenseBottom {", " display: none; }", ".PcSideBar_AdArea {", " display: none; }", "div[id^=\"div-gpt-ad\"] {", " display: none; }", ".PcGlobalFooter {", " display: none; }", ".hlword1 {", " color: #333 !important;", " font-weight: inherit !important;", " background: linear-gradient(transparent 1.1em, #f90 0, #f90 calc(1.1em + 3px), transparent 0); }" ].join(" "); let node = document.createElement("style"); node.type = "text/css"; node.setAttribute("class", "sih"); node.appendChild(document.createTextNode(css)); let heads = document.getElementsByTagName("head"); if(heads[0].querySelector('.sih')){ heads[0].querySelector('.sih').remove(); } heads[0].appendChild(node); } // out_view() })
「Ameba Search Repeat / with CSS」最新版について
旧いバージョンの JavaScriptツールは、アメーバのページ構成の変更で動作しない場合があり、導入する場合は最新バージョンをお勧めします。
●「Ameba Search Repeat / with CSS」の最新バージョンへのリンクは、以下のページのリンクリストから探せます。