「旧エディタ」で書かれた文書の扱い
Chrome をベースに制作しているので、「旧エディタ」で書かれたブログ記事の問題を見落していました。 テーマ整理を必要とするユーザーは、2017年以前からアメーバブログを書いているユーザーが多いかも知れません。 ブログの標準エディタは何度か更新されて来た様ですが、アメブロは未だ「旧エディタ」を提供しています。
提供が終了していないという事は、ユーザーの中には、慣れたエディタを離れるのを嫌って「旧エディタ」を使い続けている場合が、有り得るという事です。
今回、この「旧エディタ」で投稿した記事をテストすると、処理されない事が判りました。 歴史の長いユーザーには、これは致命的な問題になるので、改善をしました。
アメブロが設定した「エディタ移行」のルート
調べて見ると、ブログのエディタ選択は、以下の様な決まりになっていました。(Windows OS の PCユーザーの範囲での調査です)
❶「ブログ設定」のエディタ選択は、新規に作成する文書に対して、どのエディタで作成するかを選択するものです。
「旧エディタ」(元標準エディタ)は Firefox / Internet Explorer が利用可能です。 Chrome / Edge は選択ボタンがグレーアウトして選択できません。以降は「最新版エディタ」「タグ編集エディタ」を「新エディタ」とします。
❷「旧エディタ」で書かれた文書の再編集は、Firefox / Internet Explorer では「旧エディタ」が開かれます。 しかし Chrome / Edge で再編集した場合は「新エディタ」で開かれます。 これは ❶の選択とは無関係です。
❸ Firefox / Internet Explorer は「旧エディタ」で開き、保存する場合も旧エディタの文書として保存されます。
❹ Chrome / Edge で開いて保存をすると、新エディタの文書として保存をする事になり、その文書は「旧エディタ」で開く事ができなくなります。
(注)「 …entry/srventryupdateinput.do?id=xxxxxxxxxxx&editor_flg=5 」のクエリ文字列指定で、記事を「最新版エディタ」を選択して開く事が出来ますが、旧エディタの「 editor_flg=0 」の指定は無効です。 新旧のどちらのエディタで保存したかが、再編集時のエディタの新旧の選択を決定してしまうと言えます。
● 以上の仕組みから、Firefox / Internet Explorer で「旧エディタ」を指定しているユーザーが、他のブラウザに乗り換えない場合だけ「旧エディタ」で編集可能な文書を書き続けている事になります。
● Chrome / Edge のブラウザに乗り換えたユーザーは、再編集をしていない過去記事に関しては、「旧エディタ」の文書を保有している事になります。
「Theme Rep」が勝手にエディタを変更させて良いか?
Firefoxを使い「旧エディタ」で記事を作成して「Theme Rep」のテストをすると、予想の通り「テーマ変更」ができません。 投稿時の「完了画面」を閉じるコードが、「旧エディタの編集画面」を閉じてしまうのが原因でした。
これを避けるため、「旧エディタ」の文書を「&editor_flg=5」のクエリ文字で「最新版エディタ」で開いて「テーマ変更」するコードを作りました。 これは新旧の文書の全てが処理できました。 しかし、上記の問題に気付いたわけです。
そのコードで「テーマ変更」をした過去記事は、もはや「旧エディタ」で編集が出来なくなるわけです。 過去記事を何度も再編集するユーザーは、そう多くはなく、普通は「テーマ」が整理できて満足するでしょう。
しかし「旧エディタ」を使い続け、「新エディタ」は使いたくないユーザーは全く居ないとは言えません。 そんなユーザーが「Theme Rep」を使い、後に過去記事を再編集しようとして「新エディタ」が開いたら、「なにしてくれとんねん」と思うでしょう。
方針と新しいデザイン
過去記事を扱うツールである以上、「旧エディタ」による文書には遭遇するはずで、これが処理できないのは片手落ちです。 しかし、過去記事を全て「新エディタ」で開くのは避けたい。 となると、少しコードが増えますが、「旧エディタ」の文書は「旧エディタ」で開いて処理し保存する事にしました。 これなら、「旧エディタ」しか使わないユーザーが困る事はありません。
スクリプトの動作する画面の判定
編集画面を開いた場合は、以下のコードで判定しています。
開いた「URL」に「updateinput」の文字列があれば、どれかの再編集画面です。 更に、画面に「body.l-body」があれば「最新版エディタ or タグ編集エディタ」です。
それ以外は「旧エディタ」で開いたと判定できます。
また、投稿の結果を報告する「完了画面」も「URL」を調べる形に変更しました。 これまでの判定コードは「旧エディタ」を閉じるコードとして働いてしまうので。
小型の編集画面のデザイン
小型の編集画面で「テーマ変更」を処理しますが、何かの理由で連続処理がストップした時に、「送信ボタン」をすぐ押せる様に考えています。「旧エディタ」は新たにアレンジが必要だったので、背景色もオレンジ色にしました。
◎ 旧エディタの文書
◎ 新エディタの文書
◎「Ameblo Writer」が適用された 新エディタの文書
「Theme Rep」の操作方法 は以下を参照ください
●「Theme Rep N」は新タイプスキン対応版のマニュアル(ページャーが大)
●「Theme Rep O」は旧タイプスキン対応版のマニュアル(ページャーが小)
「Theme Rep」 ver. 0.4 の導入手順
「Theme Rep」は Chrome/ Edge/ Firefox の拡張機能「Tampermonkey」上で動作するスクリプトツールです。 以下は簡単な導入手順です。
❶「Tampermonkey」を導入します
使用しているブラウザに拡張機能「Tampermonkey」を導入する事が必要です。 以下のページに簡単な導入の説明をしていますから参照ください。 既にこの拡張機能を導入している場合は、❶ の操作は不要です。
❷「Tampermonkey」にスクリプトを登録します
「Tampermonkey」の「+」マークの「新規スクリプト」タブを開きます。
◎「新規スクリプト」には、最初からテンプレートが記入されています。 これは全て削除して、完全に空白にした編集枠に 下のコードをコピー&ペーストします。
〔コピー方法〕 軽量シンプルなツール「PreBox Button 」を使うと
コード枠内を「Ctrl+左Click」➔「Copy code 」を「左Click」
の操作で、掲載コードのコピーが可能になります。
◎ 最後に「ファイル」メニューの「保存」を押すと、ツールが使用可能になります。
◎「Edit At Once Archive」と同時に使用可能ですが、記事編集はできません。
〔 Theme Rep N 〕 ver. 0.4
// ==UserScript==
// @name Theme Rep N
// @namespace http://tampermonkey.net/
// @version 0.4
// @description ブログテーマの整理・変更ツール 新スキン版
// @author Ameba Blog User
// @match https://ameblo.jp/*
// @match https://secret.ameba.jp/*
// @match https://blog.ameba.jp/ucs/entry/srventry*
// @run-at document-start
// @noframes
// @grant none
// ==/UserScript==
let target0=document.querySelector('head');
let monitor0=new MutationObserver(main0);
monitor0.observe(target0, { childList: true });
function main0(){
if(document.querySelector('.skin-page')){ // 新スキンブログ画面で動作
let panel=document.createElement('div');
panel.innerHTML=
'<span id="eaoa_span">記事選択:Click / Ctrl + Click'+
' 変更先テーマ選択:Ctrl + Click</span>'+
'<div id="eaoa_inner"><input id="theme_write" type="submit" value="OK">'+
'<input id="not_write" type="submit" value="Cancel">'+
'<input id="blog_setting" type="submit" value="テーマ編集"></div>'+
'<style>#eaoa_panel { position: fixed; z-index: 100; top: 60px; left: 60px; '+
'font: bold 16px/24px Meiryo; color: #999; background: #fff; width: 620px; '+
'height: 80px; padding: 17px 5px 0; border: 1px solid #aaa; border-radius: 6px; '+
'overflow: hidden; box-shadow: 0px 20px 30px rgb(0, 0, 0, .2); } '+
'#eaoa_span { margin-left: 20px; white-space: nowrap; } '+
'#eaoa_inner { position: absolute; bottom: 6px; left: 5px; '+
'height: 37px; width: 620px; background: #e4eef8; } '+
'.eaoa_box { padding: 2px 15px 0; margin: 0 10px; color: #000; '+
'border: 1px solid #666; border-radius: 2px; } '+
'#theme_write, #not_write, #blog_setting { position: absolute; bottom: 4px; '+
'font: bold 16px Meiryo; padding: 1px 6px 0; height: 28px; display: none; '+
'color: #000; box-shadow: inset 0 0 0 40px rgb(40, 180, 250, 0.3); } '+
'#theme_write { right: 280px; } #not_write { right: 180px; } '+
'#blog_setting { right: 30px; display: inline-block; '+
'box-shadow: inset 0 0 0 20px rgb(0, 255, 232, 0.1); }';
panel.setAttribute('id', 'eaoa_panel');
let eaoa_panel=document.querySelector('#eaoa_panel');
if(!eaoa_panel){
document.querySelector('body').appendChild(panel); }
let blog_setting=document.querySelector('#blog_setting');
if(blog_setting){
blog_setting.onclick=function(){
window.open('https://blog.ameba.jp/ucs/theme/themeinput.do', '_blank'); }}
} // 新スキンブログ画面で動作
} // main0()
let target1=document.querySelector('head');
let monitor1=new MutationObserver(main1);
monitor1.observe(target1, { childList: true });
function main1(){
let bord_active=document.querySelector('.skin-borderLoud.is-active');
if(bord_active && bord_active.textContent=="テーマ別"){ // テーマ別画面で動作
let style=document.createElement('style');
style.innerHTML=
'#main { font-family: Meiryo; } '+
'[data-uranus-component="entryItemTheme"] '+
'{ width: 400px; padding: 3px 8px 0; } '+
'[data-uranus-component="entryItemTheme"]:hover '+
'{ outline: 1px solid #2196f3; outline-offset: -1px; } '+
'.select_item { background: #2196f3; } '+
'.select_item dt, .select_item dd a { color: #fff !important; opacity: 1; } '+
'.skin-archiveNav .to_theme { outline: 2px solid red; outline-offset: -2px; } '+
'.doing_item { background: #00bcd4; } '+
'.doing_item dt, .doing_item dd a { color: #fff !important; opacity: 1; }';
style.setAttribute("id", 'eaoa_style');
if(!document.getElementById('eaoa_style')){
document.querySelector('body').appendChild(style); }
let s_mode=0; // 選択操作モード
let count; // 変更指定した文書数
let theme_bar;
let new_win;
let link_target;
select_set();
select_to();
function select_set(){
let ac_list=document.querySelectorAll('.skin-borderQuiet');
for(let k=0; k<ac_list.length; k++){
let theme=
ac_list[k].querySelector('[data-uranus-component="entryItemTheme"]');
if(theme){
theme.onclick=function(event){
event.preventDefault();
if(event.ctrlKey){
select_all(theme); }
else{
selected(theme); }}}}
function select_all(item){
if(s_mode==0){
let theme_s=
document.querySelectorAll('[data-uranus-component="entryItemTheme"]');
if(item.classList.contains('select_item')){
for(let k=0; k<theme_s.length; k++){
theme_s[k].classList.remove('select_item'); }}
else{
for(let k=0; k<theme_s.length; k++){
theme_s[k].classList.add('select_item'); }}}}
function selected(item){
if(s_mode==0){
if(item.classList.contains('select_item')){
item.classList.remove('select_item'); }
else{
item.classList.add('select_item'); }}}
} // select_set()
function select_to(){
let btn_arch=document.querySelectorAll('.skin-btnArchive');
for(let k=0; k<btn_arch.length; k++){
btn_arch[k].onclick=function(event){
clear_red();
if(event.ctrlKey){
event.stopImmediatePropagation();
event.preventDefault();
to_theme(btn_arch[k]); }}}
function to_theme(select_theme){
if(!select_theme.hasAttribute('aria-current')){
count_select();
if(count>0){
s_mode=1;
select_theme.classList.add('to_theme'); // 変更先テーマを選択
let btn_link=select_theme.getAttribute('href').split('theme-');
let theme_id=btn_link[1].slice(0, 11);
let theme_name=select_theme.textContent;
setTimeout(()=>{
let eaoa_span=document.querySelector('#eaoa_span');
let theme_write=document.querySelector('#theme_write');
let not_write=document.querySelector('#not_write');
if(eaoa_span && theme_write && not_write){
eaoa_span.innerHTML='記事数<span class="eaoa_box b1"></span>'+
'⇨ テーマ<span class="eaoa_box b2"></span>に変更';
document.querySelector('.eaoa_box.b1').textContent=count;
document.querySelector('.eaoa_box.b2').textContent=theme_name;
theme_write.style.display='block';
not_write.style.display='block';
theme_write.onclick=function(){ // OKを押した場合
theme_write.style.display='none';
not_write.style.display='none';
select_array(theme_id);
open_all(); }
not_write.onclick=function(){ // Cancelを押した場合
clear_red(); }}
}, 100 ); }
}} // to_theme()
function count_select(){
count=0;
let theme_s=
document.querySelectorAll('[data-uranus-component="entryItemTheme"]');
for(let k=0; k<theme_s.length; k++){
if(theme_s[k].classList.contains('select_item')){
count +=1; }}}
} // select_to()
function clear_red(){
s_mode=0;
let eaoa_span=document.querySelector('#eaoa_span');
let theme_write=document.querySelector('#theme_write');
let not_write=document.querySelector('#not_write');
eaoa_span.innerHTML='記事選択:Click / Ctrl + Click 変更先テーマ選択:Ctrl + Click';
theme_write.style.display='none';
not_write.style.display='none';
let btn_arch=document.querySelectorAll('.skin-btnArchive');
for(let k=0; k<btn_arch.length; k++){
btn_arch[k].classList.remove('to_theme');
btn_arch[k].blur(); }}
function select_array(new_theme){
theme_bar=[];
new_win=[];
link_target=[];
let ac_list=document.querySelectorAll('.skin-borderQuiet');
for(let k=0; k<ac_list.length; k++){
let theme=ac_list[k].querySelector('[data-uranus-component="entryItemTheme"]');
if(theme && theme.classList.contains('select_item')){
theme_bar.push(theme);
let title_link=ac_list[k].querySelector('h2 a');
let entry_id_a=title_link.getAttribute('href').split('entry-');
if(entry_id_a[1]){
let entry_id=entry_id_a[1].slice(0, 11);
if(entry_id){
link_target.push(
'https://blog.ameba.jp/ucs/entry/srventryupdateinput.do?id='+entry_id+
'&eaoa='+new_theme); }}}}}
function open_all(){
let next=0;
open_win(next);
let search=setInterval(continuas, 500); // 自動で実行指示 🟥
function continuas(){
if(new_win[next].closed){
next +=1;
if(next<link_target.length){
open_win(next); }
else{
clearInterval(search);
ending(); }}}}
function open_win(n){
let top_p=window.screenY;
let left_p=window.screenX-720;
new_win[n]=window.open(
link_target[n], n, 'top='+top_p+', left='+left_p+', width=700, height=250');
theme_bar[n].classList.remove('select_item');
theme_bar[n].classList.add('doing_item'); } // 処理中のグリーン表示
function ending(){
let eaoa_span=document.querySelector('#eaoa_span');
if(eaoa_span){
eaoa_span.innerHTML='処理が終了しました。 テーマ別記事リストを更新します';
setTimeout(()=>{
// reload_part();
window.location.reload(false);
}, 4000);
setTimeout(function(){
clear_red();
select_set();
select_to();
}, 4500); }}
function reload_part(){
let part=document.querySelector('.skin-blogArchiveBody.skin-bgMain');
if(part){
let url=location.href;
ajaxUpdate(url, part); // リスト表示を更新
function ajaxUpdate(url, elem){ // XMLHttpRequestを使ってAjaxで更新
url=url+'?ver='+new Date().getTime(); // キャッシュされないurl
let ajax=new XMLHttpRequest;
ajax.open('GET', url, true);
ajax.onload=function(){
let tmp=document.createElement('div');
tmp.setAttribute('id', 'tmp_div');
tmp.style.display='none';
let tmp_div=document.querySelector('#tmp_div');
if(!tmp_div){
document.querySelector('body').appendChild(tmp); }
tmp.innerHTML=ajax.responseText;
elem.innerHTML=
tmp.querySelector('.skin-blogArchiveBody.skin-bgMain').innerHTML;
tmp.innerHTML=''; }
ajax.send(null); }}}
}} // main1() テーマ別画面で動作
window.addEventListener('DOMContentLoaded', function(){
if(location.pathname.indexOf('updateinput')!=-1){ // 編集画面で動作
let theme_id;
let query=window.location.search.slice(1); // 文頭?を除外
if(query){
let theme_id_n=query.split('&')[1].split('=')[0];
if(theme_id_n && theme_id_n=='eaoa'){
theme_id=query.split('&')[1].split('=')[1]; }}
if(document.body.classList.contains('l-body')){ // 最新版エディタで動作
let style=document.createElement('style');
style.innerHTML=
'#globalHeader, #js-header-bar, #js-preview, .l-main, .l-hashtag, '+
'.p-cover, .l-communication, .p-warning--copylight, #globalFooter '+
'{ display: none !important; } '+
'.p-title__text { width: 675px !important; } '+
'.l-under-module { margin: 0px; } '+
'.l-postTime { position: absolute; left: 0 !important; } '+
'.p-theme { position: absolute; left: 265px !important; width: 410px; } '+
'.l-footer { padding: 0; } '+
'.p-submit__container { margin: 85px 150px 0 0 !important; }';
style.setAttribute("id", 'eaoa_style');
if(!document.getElementById('eaoa_style')){
document.querySelector('body').appendChild(style); }
if(theme_id){ // 編集画面の処理 🟦
let interval=setInterval(find_selector, 1000);
function find_selector(){
let selector=document.querySelector('#js-themeSelector');
let publish=document.querySelector('.js-submitButton[publishflg="0"]');
if(selector && publish){
clearInterval(interval);
selector.value=theme_id;
rel();
function rel(){
setTimeout(()=>{
publish.click();
}, 500); } // 処理の余裕時間 保存前で停止させない🟥
}}}
} // 最新版エディタで動作
else{ // 旧エディタで動作
let style=document.createElement('style');
style.innerHTML=
'#globalHeader, #ucsHeader, .l-ucs-sidemenu-area, #ucsMainRight, '+
'#entryCreate h1, #entryTheme .btnDefault, .entryHashtag, '+
'#firstDescriptionArea, #entryMain, #displayTag, #atclInfo, #previewBtn, '+
'.amemberHelp, #attentionBox2 { display: none !important; } '+
'#ucsContent { background: orange; } '+
'#ucsMainLeft { margin: 0 20px; } '+
'#subContentsArea { margin: 0 !important; } '+
'#title { padding: 2px 10px 0; font: 16px Meiryo; } '+
'#js-ga_change select { padding: 3px 6px 0; font: 16px Meiryo; } '+
'.btnDefault { font: 16px Meiryo; } ';
style.setAttribute("id", 'eaoa_style');
if(!document.getElementById('eaoa_style')){
document.querySelector('body').appendChild(style); }
if(theme_id){ // 編集画面の処理 🟦
let interval=setInterval(find_selector, 1000);
function find_selector(){
let selector=document.querySelector('#js-ga_change select');
let publish=
document.querySelector('.actionControl .btnDefault[value="全員に公開"]');
if(selector && publish){
clearInterval(interval);
selector.value=theme_id;
rel();
function rel(){
setTimeout(()=>{
publish.click();
}, 500); } // 処理の余裕時間 保存前で停止させない🟥
}}}
} // 旧エディタで動作
}}); // 編集画面で動作
window.addEventListener('DOMContentLoaded', function(){
if(location.pathname.indexOf('updateend')!=-1){ // 送信完了画面で動作
window.document.body.style.background='#c5d8e1';
window.document.body.style.boxShadow='0 0 0 100vh #c5d8e1';
select_e(close_w);
function select_e(close_w){
let error_report=document.querySelector('.p-error');
if(error_report==null){ // 保存エラー無い場合 編集画面を閉じる
if(window.opener){
window.opener.close(); }}
else{ // 保存エラーのある場合は 赤を送信 編集画面を残す
if(window.opener){
report('red'); }}
close_w(); }
function close_w(){
window.open('about:blank','_self').close(); } // 完了画面は常に自動的に閉じる
function report(color){
window.opener.document.querySelector('.p-title__text').style.background=color; }}
}); // 送信完了画面で動作
〔 Theme Rep O 〕 ver. 0.4
// ==UserScript==
// @name Theme Rep O
// @namespace http://tampermonkey.net/
// @version 0.4
// @description ブログテーマの整理・変更ツール 旧スキン版
// @author Ameba Blog User
// @match https://ameblo.jp/*
// @match https://secret.ameba.jp/*
// @match https://blog.ameba.jp/ucs/entry/srventry*
// @run-at document-start
// @noframes
// @grant none
// ==/UserScript==
let target0=document.querySelector('head');
let monitor0=new MutationObserver(main0);
monitor0.observe(target0, { childList: true });
function main0(){
if(document.querySelector('.skinBody')){ // 旧スキンブログ画面で動作
let panel=document.createElement('div');
panel.innerHTML=
'<span id="eaoa_span">記事選択:Click / Ctrl + Click'+
' 変更先テーマ選択:Ctrl + Click</span>'+
'<div id="eaoa_inner"><input id="theme_write" type="submit" value="OK">'+
'<input id="not_write" type="submit" value="Cancel">'+
'<input id="blog_setting" type="submit" value="テーマ編集"></div>'+
'<style>#eaoa_panel { position: fixed; z-index: 100; top: 60px; left: 60px; '+
'font: bold 16px/24px Meiryo; color: #999; background: #fff; width: 620px; '+
'height: 80px; padding: 17px 5px 0; border: 1px solid #aaa; border-radius: 6px; '+
'overflow: hidden; box-shadow: 0px 20px 30px rgb(0, 0, 0, .2); } '+
'#eaoa_span { margin-left: 20px; white-space: nowrap; } '+
'#eaoa_inner { position: absolute; bottom: 6px; left: 5px; '+
'height: 37px; width: 620px; background: #e4eef8; } '+
'.eaoa_box { padding: 2px 15px 0; margin: 0 10px; color: #000; '+
'border: 1px solid #666; border-radius: 2px; } '+
'#theme_write, #not_write, #blog_setting { position: absolute; bottom: 4px; '+
'font: bold 16px Meiryo; padding: 1px 6px 0; height: 28px; display: none; '+
'color: #000; box-shadow: inset 0 0 0 40px rgb(40, 180, 250, 0.3); } '+
'#theme_write { right: 280px; } #not_write { right: 180px; } '+
'#blog_setting { right: 30px; display: inline-block; '+
'box-shadow: inset 0 0 0 20px rgb(0, 255, 232, 0.1); }';
panel.setAttribute('id', 'eaoa_panel');
let eaoa_panel=document.querySelector('#eaoa_panel');
if(!eaoa_panel){
document.querySelector('body').appendChild(panel); }
let blog_setting=document.querySelector('#blog_setting');
if(blog_setting){
blog_setting.onclick=function(){
window.open('https://blog.ameba.jp/ucs/theme/themeinput.do', '_blank'); }}
} // 旧スキンブログ画面で動作
} // main0()
let target1=document.querySelector('head');
let monitor1=new MutationObserver(main1);
monitor1.observe(target1, { childList: true });
function main1(){
let tab_active=document.querySelector('.skinBlock.currentTab');
if(tab_active && tab_active.textContent=="テーマ別記事一覧"){ // テーマ別画面で動作
let style=document.createElement('style');
style.innerHTML=
'#main { font-family: Meiryo; } '+
'.themeList li a { padding: 2px 4px 0; } '+
'.skinBorderList li:hover { outline: 1px solid #2196f3; } '+
'.select_item { background: #2196f3; } '+
'.select_item a, .select_item * { color: #fff !important; } '+
'.listContentsArea .to_theme { background: red; color: #fff !important; } '+
'.doing_item { background: #00bcd4; } '+
'.doing_item * { color: #fff !important; }';
style.setAttribute("id", 'eaoa_style');
if(!document.getElementById('eaoa_style')){
document.querySelector('body').appendChild(style); }
let s_mode=0; // 選択操作モード
let count; // 変更指定した文書数
let theme_bar;
let new_win;
let link_target;
select_set();
select_to();
function select_set(){
let ac_list=document.querySelectorAll('.skinBorderList li');
for(let k=0; k<ac_list.length; k++){
ac_list[k].onclick=function(event){
event.preventDefault();
if(event.ctrlKey){
select_all(ac_list[k]); }
else{
selected(ac_list[k]); }}}
function select_all(item){
if(s_mode==0){
let ac_list=document.querySelectorAll('.skinBorderList li');
if(item.classList.contains('select_item')){
for(let k=0; k<ac_list.length; k++){
ac_list[k].classList.remove('select_item'); }}
else{
for(let k=0; k<ac_list.length; k++){
ac_list[k].classList.add('select_item'); }}}}
function selected(item){
if(s_mode==0){
if(item.classList.contains('select_item')){
item.classList.remove('select_item'); }
else{
item.classList.add('select_item'); }}}
} // select_set()
function select_to(){
let btn_arch=document.querySelectorAll('.themeList li a');
for(let k=0; k<btn_arch.length; k++){
btn_arch[k].onclick=function(event){
clear_red();
if(event.ctrlKey){
event.stopImmediatePropagation();
event.preventDefault();
to_theme(btn_arch[k]); }}}
function to_theme(select_theme){
if(!select_theme.hasAttribute('aria-current')){
count_select();
if(count>0){
s_mode=1;
select_theme.classList.add('to_theme'); // 変更先テーマを選択
let btn_link=select_theme.getAttribute('href').split('theme-');
let theme_id=btn_link[1].slice(0, 11);
let theme_name=select_theme.textContent;
setTimeout(()=>{
let eaoa_span=document.querySelector('#eaoa_span');
let theme_write=document.querySelector('#theme_write');
let not_write=document.querySelector('#not_write');
if(eaoa_span && theme_write && not_write){
eaoa_span.innerHTML='記事数<span class="eaoa_box b1"></span>'+
'⇨ テーマ<span class="eaoa_box b2"></span>に変更';
document.querySelector('.eaoa_box.b1').textContent=count;
document.querySelector('.eaoa_box.b2').textContent=theme_name;
theme_write.style.display='block';
not_write.style.display='block';
theme_write.onclick=function(){ // OKを押した場合
theme_write.style.display='none';
not_write.style.display='none';
select_array(theme_id);
open_all(); }
not_write.onclick=function(){ // Cancelを押した場合
clear_red(); }}
}, 100 ); }
}} // to_theme()
function count_select(){
count=0;
let ac_list=document.querySelectorAll('.skinBorderList li');
for(let k=0; k<ac_list.length; k++){
if(ac_list[k].classList.contains('select_item')){
count +=1; }}}
} // select_to()
function clear_red(){
s_mode=0;
let eaoa_span=document.querySelector('#eaoa_span');
let theme_write=document.querySelector('#theme_write');
let not_write=document.querySelector('#not_write');
eaoa_span.innerHTML='記事選択:Click / Ctrl + Click 変更先テーマ選択:Ctrl + Click';
theme_write.style.display='none';
not_write.style.display='none';
let btn_arch=document.querySelectorAll('.themeList li a');
for(let k=0; k<btn_arch.length; k++){
btn_arch[k].classList.remove('to_theme');
btn_arch[k].blur(); }}
function select_array(new_theme){
theme_bar=[];
new_win=[];
link_target=[];
let ac_list=document.querySelectorAll('.skinBorderList li');
for(let k=0; k<ac_list.length; k++){
if(ac_list[k].classList.contains('select_item')){
theme_bar.push(ac_list[k]);
let title_link=ac_list[k].querySelector('h1 a');
let entry_id_a=title_link.getAttribute('href').split('entry-');
if(entry_id_a[1]){
let entry_id=entry_id_a[1].slice(0, 11);
if(entry_id){
link_target.push(
'https://blog.ameba.jp/ucs/entry/srventryupdateinput.do?id='+entry_id+
'&eaoa='+new_theme); }}}}}
function open_all(){
let next=0;
open_win(next);
let search=setInterval(continuas, 500); // 自動で実行指示 🟥
function continuas(){
if(new_win[next].closed){
next +=1;
if(next<link_target.length){
open_win(next); }
else{
clearInterval(search);
ending(); }}}}
function open_win(n){
let top_p=window.screenY;
let left_p=window.screenX-720;
new_win[n]=window.open(
link_target[n], n, 'top='+top_p+', left='+left_p+', width=700, height=250');
theme_bar[n].classList.remove('select_item');
theme_bar[n].classList.add('doing_item'); } // 処理中のグリーン表示
function ending(){
let eaoa_span=document.querySelector('#eaoa_span');
if(eaoa_span){
eaoa_span.innerHTML='処理が終了しました。 テーマ別記事リストを更新します';
setTimeout(()=>{
reload_part();
}, 4000);
setTimeout(function(){
clear_red();
select_set();
select_to();
}, 4500); }}
function reload_part(){
let part=document.querySelector('.listContentsArea.skinBlock');
if(part){
let url=location.href;
ajaxUpdate(url, part); // リスト表示を更新
function ajaxUpdate(url, elem){ // XMLHttpRequestを使ってAjaxで更新
url=url+'?ver='+new Date().getTime(); // キャッシュされないurl
let ajax=new XMLHttpRequest;
ajax.open('GET', url, true);
ajax.onload=function(){
let tmp=document.createElement('div');
tmp.setAttribute('id', 'tmp_div');
tmp.style.display='none';
let tmp_div=document.querySelector('#tmp_div');
if(!tmp_div){
document.querySelector('body').appendChild(tmp); }
tmp.innerHTML=ajax.responseText;
elem.innerHTML=
tmp.querySelector('.listContentsArea.skinBlock').innerHTML;
tmp.innerHTML=''; }
ajax.send(null); }}}
}} // main1() テーマ別画面で動作
window.addEventListener('DOMContentLoaded', function(){
if(location.pathname.indexOf('updateinput')!=-1){ // 編集画面で動作
let theme_id;
let query=window.location.search.slice(1); // 文頭?を除外
if(query){
let theme_id_n=query.split('&')[1].split('=')[0];
if(theme_id_n && theme_id_n=='eaoa'){
theme_id=query.split('&')[1].split('=')[1]; }}
if(document.body.classList.contains('l-body')){ // 最新版エディタで動作
let style=document.createElement('style');
style.innerHTML=
'#globalHeader, #js-header-bar, #js-preview, .l-main, .l-hashtag, '+
'.p-cover, .l-communication, .p-warning--copylight, #globalFooter '+
'{ display: none !important; } '+
'.p-title__text { width: 675px !important; } '+
'.l-under-module { margin: 0px; } '+
'.l-postTime { position: absolute; left: 0 !important; } '+
'.p-theme { position: absolute; left: 265px !important; width: 410px; } '+
'.l-footer { padding: 0; } '+
'.p-submit__container { margin: 85px 150px 0 0 !important; }';
style.setAttribute("id", 'eaoa_style');
if(!document.getElementById('eaoa_style')){
document.querySelector('body').appendChild(style); }
if(theme_id){ // 編集画面の処理 🟦
let interval=setInterval(find_selector, 1000);
function find_selector(){
let selector=document.querySelector('#js-themeSelector');
let publish=document.querySelector('.js-submitButton[publishflg="0"]');
if(selector && publish){
clearInterval(interval);
selector.value=theme_id;
rel();
function rel(){
setTimeout(()=>{
publish.click();
}, 500); } // 処理の余裕時間 保存前で停止させない🟥
}}}
} // 最新版エディタで動作
else{ // 旧エディタで動作
let style=document.createElement('style');
style.innerHTML=
'#globalHeader, #ucsHeader, .l-ucs-sidemenu-area, #ucsMainRight, '+
'#entryCreate h1, #entryTheme .btnDefault, .entryHashtag, '+
'#firstDescriptionArea, #entryMain, #displayTag, #atclInfo, #previewBtn, '+
'.amemberHelp, #attentionBox2 { display: none !important; } '+
'#ucsContent { background: orange; } '+
'#ucsMainLeft { margin: 0 20px; } '+
'#subContentsArea { margin: 0 !important; } '+
'#title { padding: 2px 10px 0; font: 16px Meiryo; } '+
'#js-ga_change select { padding: 3px 6px 0; font: 16px Meiryo; } '+
'.btnDefault { font: 16px Meiryo; } ';
style.setAttribute("id", 'eaoa_style');
if(!document.getElementById('eaoa_style')){
document.querySelector('body').appendChild(style); }
if(theme_id){ // 編集画面の処理 🟦
let interval=setInterval(find_selector, 1000);
function find_selector(){
let selector=document.querySelector('#js-ga_change select');
let publish=
document.querySelector('.actionControl .btnDefault[value="全員に公開"]');
if(selector && publish){
clearInterval(interval);
selector.value=theme_id;
rel();
function rel(){
setTimeout(()=>{
publish.click();
}, 500); } // 処理の余裕時間 保存前で停止させない🟥
}}}
} // 旧エディタで動作
}}); // 編集画面で動作
window.addEventListener('DOMContentLoaded', function(){
if(location.pathname.indexOf('updateend')!=-1){ // 送信完了画面で動作
window.document.body.style.background='#c5d8e1';
window.document.body.style.boxShadow='0 0 0 100vh #c5d8e1';
select_e(close_w);
function select_e(close_w){
let error_report=document.querySelector('.p-error');
if(error_report==null){ // 保存エラー無い場合 編集画面を閉じる
if(window.opener){
window.opener.close(); }}
else{ // 保存エラーのある場合は 赤を送信 編集画面を残す
if(window.opener){
report('red'); }}
close_w(); }
function close_w(){
window.open('about:blank','_self').close(); } // 完了画面は常に自動的に閉じる
function report(color){
window.opener.document.querySelector('.p-title__text').style.background=color; }}
}); // 送信完了画面で動作
「Theme Rep」最新版について
旧いバージョンの JavaScriptツールは、アメーバのページ構成の変更で動作しない場合があり、導入する場合は最新バージョンをお勧めします。
●「Theme Rep」の最新バージョンへのリンクは、以下のページのリンクリストから探せます。









