「テーマ一覧」パネルとパネル配置コードを変更

「登録テーマ一覧」パネルの配置は、ブログデザインの多種のカラム(列)設定に対応できる様に、「パネル位置」のボタンを追加しました。

 

しかしその後の検証で、「テーマ数」が数十というユーザーが少なくなく、「登録テーマ一覧」パネルがウインドウ下端より外に伸びる事が判りました。 パネルをスクロール表示にしないと変更先テーマを指定できません。 慌てて、昨日のアップロード後にコードを書換ましたが、更に多くのブログでチェックすると、左右の配置変更は不十分な機能と判り、配置コードを改善しました。 

 

 

 

複雑な「左寄せ」「右寄せ」の仕方 

カラム設定は下の様な種類があり、記事リストの位置が左・右・中央と、様々です。

 

 

以下の模式図は、上段が最初に作った「左寄せ」「右寄せ」の配置です。 下段は、改めた配置です。

 

 

どちらが良いかは、実際に配置コードを作ってテストするまで判りませんでした。 上図で、ウインドウ幅を狭めたり拡げたりした状態も考慮が必要です。 ウインドウを拡げるに従い、背後の「記事リスト」が移動します。 これは必ず左側からしだいに離れる様に移動します。 それは、現在の普通のスキンが左上を基準にしているからです。

 

また、狭めてページ幅よりウインドウが狭くなった場合、横スクロールバーが表示され、その時の「記事リスト」とパネルの位置関係もまた複雑です。

 

で結局、新しい下側の配置コードを採用しました。 実際に多数のブログでテストして見ると、下側が順応性が高いのです。 このテストは、特に幅の狭いノート等のモニターを前提にして行いました。 左右に余裕があるモニターでは、ウインドウを拡げればなんとでもなるからです。 

 

以下は新しい配置コードで、「登録テーマ一覧」パネルの幅が、「登録テーマ」の一番長いもので決まるので、それを勘案したコードです。

 

let client_w=themes_panel.clientWidth;
if(panel_position && trep_panel && themes_panel){
    if(get_cookie('trep_panel')=='left'){
        trep_panel.style.left=(50+client_w).toString() +'px';
        trep_panel.style.right='unset';
        themes_panel.style.left='20px';
        themes_panel.style.right='unset'; }
    else{
        trep_panel.style.left='unset';
        trep_panel.style.right=(50+client_w).toString() +'px';
        themes_panel.style.left='unset';
        themes_panel.style.right='20px'; }

    panel_position.onclick=function(){
        if(get_cookie('trep_panel')=='left'){
            trep_panel.style.left='unset';
            trep_panel.style.right=(50+client_w).toString() +'px';
            themes_panel.style.left='unset';
            themes_panel.style.right='20px';
            document.cookie='trep_panel=right; Max-Age=2592000'; }
        else{
            trep_panel.style.left=(50+client_w).toString() +'px';
            trep_panel.style.right='unset';
            themes_panel.style.left='20px';
            themes_panel.style.right='unset';
            document.cookie='trep_panel=left; Max-Age=2592000'; }}}

 

上半分は「Cookie」に保存した「left」「right」のどちらの配置かに従って、「操作パネル」「登録テーマ一覧」の配置を実行します。 後半は、「パネル配置」のボタンを押した際に、その配置を入れ替え、指定した「left」「right」の選択を「Cookie」に保存するコードです。

 

コード中で「client_w」は、テーマを一覧表示した時のパネル幅です。

 

 

表示のテストサンプル 

以下は、各種のカラム配置をテストしたものです。「登録テーマ一覧」にはテーマに登録できる最大文字数「20文字」を入れて、ほぼ限界の幅にしています。 高さ方向は、パネルの高さをウインドウ縦幅の75%を最大値にしました。

 

また、ウインドウ横幅は「約1200px」としていますが、ウインドウを拡げると記事リストをもう少し見易くできますから、一番難しい条件にして、それでも記事リストが確認できるかをテストしたものです。

 

  〔2カラム メニュー左〕

 

  〔2カラム メニュー右〕

 

  〔3カラム 右ワイドメニュー〕

 

  〔3カラム 左ワイドメニュー〕

 

最後の2パターンは、ウインドウ幅を拡げれば記事リストを全幅表示できます。 実際の「登録テーマ一覧」はこの幅以下と考えれば合格と思います。

 

 

 

「テーマ一覧」パネルの構造 

FirefoxとChromeでスクロールバーのコード仕様が違います。「テーマ一覧」の幅を抑えたいのですが、 Firefoxは「overflow: auto」としてもスクロールバーが消えずに残ります。 今回は、スクロールバーを隠してしまい、どちらのブラウザでもパネル幅を最小にできる様にしました。

 

右側が隠れたスクロールバーを表示させたもので、隠す事でマウスホイールでしかスクロール操作が出来なくなっています。

 

 

このデザインはスマートで良いのですが、ブラウザ全体(記事リスト全体)のスクロールと、この「テーマ一覧」のスクロールの両方をマウスホイールで操作する事になります。 ポインターが「テーマ一覧」上にある時はそのテーマリストのスクロールが主になりますが、スクロールが下端に来るとブラウザ全体のスクロールになります。

 

これは、複数のスクロール要素がある場合のブラウザのデフォルトの対応ですが、この場合はユーザーの意図と無関係に「記事リスト」の方がスクロールされます。 これは扱い難いので、なんとか抑止するコードを考えました。 これはネットを探してもサンプルになるコードがありません。

 

let themes_ul=document.querySelector('#themes_ul');
themes_ul.addEventListener('wheel', function(){
    if(themes_ul.scrollHeight==themes_ul.scrollTop + themes_ul.clientHeight){
        themes_ul.scrollTop=themes_ul.scrollHeight - themes_ul.clientHeight - 1; }
    if(themes_ul.scrollTop==0){
        themes_ul.scrollTop=1; }});

 

このコードで「themes_ul」は「テーマ一覧」のスクロール部分のリスト要素です。

コードの内容はスクロールが下端に来れば「1px」上に戻し、上端に来れば「1px」下に戻すものです。 スクロールして良く見ると、上下の端で少しゴソゴソしますが、気にならない程度です。 これで、端部でそれ以上のスクロールを指示しない事になるので、ポインターがパネル上にあればページ全体がスクロールしません。

 

もっと気の利いたコードがあれば良いのですが、どうも適当なコードがありません。 パネルのタイトルをスイッチにして、全体のスクロールを抑止するコードを作りましたが、こちらの方が自然で説明が不要なので、上記コードを採用しました。

 

なお、Firefoxはスクロールの動作仕様が異なるためか、この抑止機能は不十分にしか機能しない様です。 これは、改善できませんでした。

 

 

 

 「Theme Rep N」 ver. 1.1 

「Theme Rep N」は Chrome・Edge / Firefox の拡張機能「Tampermonkey」上で動作するスクリプトツールです。

 

このツールは新タイプスキンを適用したブログ専用です。 基本的な使用方法は、以下のページのマニュアルを参照ください。

 

 

 

 

導入手順

以下に簡単な導入手順を示します。

 

❶「Tampermonkey」を導入します

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

 

 

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

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

 

 

 

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

 

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

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

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

 

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

 

 

〔 Theme Rep N 〕 ver. 1.15

 

// ==UserScript==
// @name         Theme Rep N
// @namespace    http://tampermonkey.net/
// @version      1.15
// @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 theme_list; // 登録テーマの配列

let read_json=sessionStorage.getItem('TRepN'); // セッションストレージ読込み
theme_list=JSON.parse(read_json);
if(theme_list==null){
    theme_list=[[ , ]]; }


function storage(){
    let bord_active=document.querySelector('.skin-borderLoud.is-active');
    if(bord_active && bord_active.textContent=="テーマ別"){ // テーマ別画面で動作
        theme_list=[[ , ]]; // リセット

        let btn_arch=document.querySelectorAll('.skin-btnArchive');
        for(let i=0; i<btn_arch.length; i++){
            theme_list[i]=[ , ]; } // 初期化

        for(let k=0; k<btn_arch.length; k++){
            let btn_link=btn_arch[k].getAttribute('href').split('theme-');
            let theme_id=btn_link[1].slice(0, 11);
            let theme_name=btn_arch[k].textContent;
            theme_list[k][0]=theme_id;
            theme_list[k][1]=theme_name; }

        let write_json=JSON.stringify(theme_list);
        sessionStorage.setItem('TRepN', write_json); }} // セッションストレージに書込み


function disp_themes(){
    let themes_panel=document.querySelector('#themes_panel');
    let themes_ul=document.querySelector('#themes_ul');

    if(themes_panel && themes_ul){
        themes_ul.innerHTML='';
        for(let k=0; k<theme_list.length; k++){
            let themes_li=document.createElement('li');
            themes_li.setAttribute('class', 'themes_li');
            themes_li.innerHTML=theme_name_disp(theme_list[k][1]);
            let themes_lis=document.querySelectorAll('.themes_li');
            if(themes_lis.length<theme_list.length && theme_list[k]!=''){
                themes_ul.appendChild(themes_li); }}}

    function theme_name_disp(str){
        if(str){
            let name=str.slice(0, str.lastIndexOf('('));
            let num=str.slice(str.lastIndexOf('(')).replace(/[^0-9]/g, '');
            return name+
                '<span class="trep_num"> <c>(</c>'+ num +'<c>)</c></span>'; }}}



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

function main(){
    if(document.querySelector('.skin-page')){ // 新スキンブログ画面で動作
        let panel=document.createElement('div');
        panel.innerHTML=
            '<span id="trep_span">テーマ取得 ▷ 記事選択:Click / Ctrl+Click'+
            ' ▷ 変更先テーマ選択:Click</span>'+
            '<div id="trep_inner">'+
            '<span id="trep_progress"></span>'+
            '<input id="theme_write" type="submit" value="OK">'+
            '<input id="not_write" type="submit" value="Cancel">'+
            '<input id="themes_get" type="submit" value="テーマ取得">'+
            '<input id="w_position" type="submit" value="サブウインドウ位置">'+
            '<input id="panel_position" type="submit" value="パネル位置">'+
            '<input id="blog_setting" type="submit" value="テーマ編集">'+
            '<input id="stop_out" type="submit" value="処理中止"></div>';

        panel.setAttribute('id', 'trep_panel');
        let trep_panel=document.querySelector('#trep_panel');
        if(!trep_panel){
            document.querySelector('body').appendChild(panel); }

        let panel2=document.createElement('div');
        panel2.innerHTML=
            '<p>   登録テーマ一覧</p><ul id="themes_ul"></ul>';

        panel2.setAttribute('id', 'themes_panel');
        if(!document.querySelector('#themes_panel')){
            document.querySelector('body').appendChild(panel2); }

        disp_themes();

        let style=document.createElement('style');
        style.innerHTML=
            '#trep_panel { position: fixed; z-index: 4000; top: 60px; left: 60px; '+
            'font: bold 16px/24px Meiryo; color: #999; background: #fff; '+
            'width: 620px; height: 80px; padding: 17px 5px 0; text-align: left; '+
            'border: 1px solid #aaa; border-radius: 6px; box-sizing: content-box; '+
            'overflow: hidden; box-shadow: 0 20px 30px rgb(0, 0, 0, .2); } '+
            '#trep_span { margin-left: 20px; white-space: nowrap; } '+
            '#trep_inner { position: absolute; bottom: 6px; left: 5px; '+
            'height: 37px; width: 620px; background: #e4eef8; } '+
            '#trep_progress { margin-left: 20px; line-height: 41px; opacity: .5; } '+
            '.trep_box { margin: 0 10px; color: #000; border: 1px solid #666; '+
            'border-radius: 2px; } '+
            '.trep_box.b1 { padding: 3px 15px 0; color: #2196f3; } '+
            '.trep_box.b2 { padding: 3px 10px 0 15px; } '+
            '.trep_num { color: #2196f3; } '+
            'c { font-weight: normal; }'+
            '#theme_write, #not_write, #themes_get, #w_position, #panel_position, '+
            '#blog_setting, #stop_out { position: absolute; bottom: 4px; '+
            'font: bold 16px/16px Meiryo; padding: 2px 10px 0; height: 29px; color: #000; '+
            'box-shadow: inset 0 0 0 40px rgb(40, 180, 250, 0.3); } '+
            '#stop_out { right: 25px; display: none; } '+
            '#theme_write { right: 280px; display: none; } '+
            '#not_write { right: 180px; display: none; } '+
            '#themes_get, #w_position, #panel_position, #blog_setting { display: block; '+
            'color: #777; box-shadow: inset 0 0 0 20px rgb(0, 255, 232, 0.1); } '+
            '#themes_get { left: 20px; } #w_position { left: 160px; } '+
            '#panel_position { left: 340px; } #blog_setting { right: 20px; } '+

            '#themes_panel { position: fixed; z-index: 100; top: 60px; overflow: hidden; '+
            'left: 720px; font: bold 16px/24px Meiryo; color: #666; background: #fff; '+
            'min-width: 200px; min-height: 77px; padding: 8px 6px 12px; '+
            'border: 1px solid #aaa; border-radius: 6px; box-sizing: content-box; '+
            'text-align: left; box-shadow: 0 20px 30px rgb(0, 0, 0, .2); } '+
            '#themes_panel p { margin-bottom: 12px; padding: 4px 0 2px; '+
            'background: #e4eef8; } '+
            '#themes_ul { list-style: none; padding-inline-start: 0;  max-height: 75vh; '+
            'overflow-y: scroll; margin-right: -22px; } '+
            '.themes_li { padding: 3px 10px 0 15px; margin: 1px 6px 4px 1px; '+
            'outline: 1px solid #ccc; outline-offset: -1px; white-space: nowrap; '+
            'cursor: pointer; } '+
            '.themes_li:hover { background: #eee; } '+
            '.themes_li.to_theme { outline: 2px solid red; } '+

            '#main { font-family: Meiryo; } '+
            '.skin-archiveList .skin-borderQuiet:hover { '+
            'outline: 1px solid #2196f3; outline-offset: -1px; '+
            'box-shadow: inset 0 0 0 120px rgba(187, 222, 251, .3); } '+
            '.skin-archiveList .skin-borderQuiet:hover * { opacity: 1; } '+
            '.select_item { background: #2196f3; } '+
            '.select_item * { color: #fff; } '+
            '.doing_item { background: #00bcd4; } '+
            '.doing_item .skin-textQuiet { color: #fff; } '+
            '[data-uranus-component="archiveList"]>li { padding: 4px 8px; } '+
            '[data-uranus-component="entryItemImage"], '+
            '[data-uranus-component="imageFrame"] img '+
            '{ height: 88px !important; width: 88px !important; overflow: hidden; } '+
            '[data-uranus-component="entryItemTitle"] { margin-bottom: 0; } '+
            '[data-uranus-component="entryItemMeta"] { min-height: 40px; } '+
            '[data-uranus-component="entryItemMeta"]> * { margin-bottom: -2px; }';

        style.setAttribute("id", 'trep_style');
        if(!document.getElementById('trep_style')){
            document.querySelector('body').appendChild(style); }


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


        let themes_ul=document.querySelector('#themes_ul');
        themes_ul.addEventListener('wheel', function(){
            if(themes_ul.scrollHeight==themes_ul.scrollTop + themes_ul.clientHeight){
                themes_ul.scrollTop=themes_ul.scrollHeight - themes_ul.clientHeight - 1; }
            if(themes_ul.scrollTop==0){
                themes_ul.scrollTop=1; }});


        let panel_position=document.querySelector('#panel_position');
        let themes_panel=document.querySelector('#themes_panel');
        let client_w=themes_panel.clientWidth;
        if(panel_position && trep_panel && themes_panel){
            if(get_cookie('trep_panel')=='left'){
                trep_panel.style.left=(50+client_w).toString() +'px';
                trep_panel.style.right='unset';
                themes_panel.style.left='20px';
                themes_panel.style.right='unset'; }
            else{
                trep_panel.style.left='unset';
                trep_panel.style.right=(50+client_w).toString() +'px';
                themes_panel.style.left='unset';
                themes_panel.style.right='20px'; }

            panel_position.onclick=function(){
                if(get_cookie('trep_panel')=='left'){
                    trep_panel.style.left='unset';
                    trep_panel.style.right=(50+client_w).toString() +'px';
                    themes_panel.style.left='unset';
                    themes_panel.style.right='20px';
                    document.cookie='trep_panel=right; Max-Age=2592000'; }
                else{
                    trep_panel.style.left=(50+client_w).toString() +'px';
                    trep_panel.style.right='unset';
                    themes_panel.style.left='20px';
                    themes_panel.style.right='unset';
                    document.cookie='trep_panel=left; Max-Age=2592000'; }}}


        let themes_get=document.querySelector('#themes_get');
        if(themes_get){
            themes_get.onclick=function(){
                let entryThemes=document.querySelector('.skin-entryThemes a');
                if(entryThemes){ // 記事一覧外でテーマ取得がクリックされた場合
                    let theme_url=entryThemes.getAttribute('href');
                    location.href=theme_url; }
                else{ // 記事一覧内でテーマ取得がクリックされた場合
                    reload_act(); }}}

    } // 新スキンブログ画面で動作



    let bord_active=document.querySelector('.skin-borderLoud.is-active');
    if(bord_active){ // 記事一覧画面で動作

        let s_mode=0; // 選択操作モード
        let count; // 変更指定した文書数
        let selected_array;
        let new_win;
        let link_target;
        let trep_wtop;
        let trep_wleft;


        learn_themes();
        select_set();
        select_to();

        function learn_themes(){
            let query=location.href.toString().slice(-4);
            if(query=='?org'){
                setTimeout(()=>{
                    storage();
                    disp_themes();
                    let org_url=sessionStorage.getItem('TRepN_org'); // ストレージ読込み
                    if(org_url){
                        location.href=org_url; }
                }, 100); }
            else{
                setTimeout(()=>{
                    storage();
                    disp_themes();
                    select_to();
                }, 100); }
        } // learn_themes()


        function select_set(){
            let ac_list=document.querySelectorAll('.skin-archiveList .skin-borderQuiet');
            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){
                    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 themes_li=document.querySelectorAll('.themes_li');
            for(let k=0; k<themes_li.length; k++){
                themes_li[k].onclick=function(event){
                    clear_red();
                    to_theme(k); }}

            function to_theme(select){
                count_select();
                if(count>0){
                    s_mode=1;
                    themes_li[select].classList.add('to_theme'); // 変更先テーマを選択

                    setTimeout(()=>{
                        let trep_span=document.querySelector('#trep_span');
                        let themes_get=document.querySelector('#themes_get');
                        let w_position=document.querySelector('#w_position');
                        let panel_position=document.querySelector('#panel_position');
                        let blog_setting=document.querySelector('#blog_setting');
                        let theme_write=document.querySelector('#theme_write');
                        let not_write=document.querySelector('#not_write');
                        let stop_out=document.querySelector('#stop_out');
                        if(trep_span && themes_get && w_position &&
                           panel_position && theme_write && not_write && stop_out){
                            trep_span.innerHTML=
                                '記事数<span class="trep_box b1"></span>'+
                                '⇨ テーマ<span class="trep_box b2"></span>に変更';
                            document.querySelector('.trep_box.b1').textContent=count;
                            theme_name_disp(theme_list[select][1]);
                            themes_get.style.display='none';
                            w_position.style.display='none';
                            panel_position.style.display='none';
                            blog_setting.style.display='none';
                            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';
                                stop_out.style.display='block';
                                select_array(theme_list[select][0]);
                                open_all(); }

                            not_write.onclick=function(){ // Cancelを押した場合
                                clear_red(); }}
                    }, 100 ); }
            } // to_theme()


            function count_select(){
                count=0;
                let ac_list=document.querySelectorAll('.skin-archiveList .skin-borderQuiet');
                for(let k=0; k<ac_list.length; k++){
                    if(ac_list[k].classList.contains('select_item')){
                        count +=1; }}}
        } // select_to()


        function theme_name_disp(str){
            let name=str.slice(0, str.lastIndexOf('('));
            let num=str.slice(str.lastIndexOf('(')).replace(/[^0-9]/g, '');
            let target_theme=document.querySelector('.trep_box.b2');
            if(target_theme){
                target_theme.innerHTML=name +'<span class="trep_num"> <c>(</c>'+
                    num+'<c>)</c></span>'; }}


        function clear_red(){
            s_mode=0;
            let trep_span=document.querySelector('#trep_span');
            let themes_get=document.querySelector('#themes_get');
            let w_position=document.querySelector('#w_position');
            let panel_position=document.querySelector('#panel_position');
            let blog_setting=document.querySelector('#blog_setting');
            let theme_write=document.querySelector('#theme_write');
            let not_write=document.querySelector('#not_write');
            let stop_out=document.querySelector('#stop_out');
            trep_span.innerHTML=
                'テーマ取得 ▷ 記事選択:Click / Ctrl+Click ▷ 変更先テーマ選択:Click';
            themes_get.style.display='block';
            w_position.style.display='block';
            panel_position.style.display='block';
            blog_setting.style.display='block';
            theme_write.style.display='none';
            not_write.style.display='none';
            stop_out.style.display='none';

            let themes_li=document.querySelectorAll('.themes_li');
            for(let k=0; k<themes_li.length; k++){
                themes_li[k].classList.remove('to_theme');
                themes_li[k].blur(); }}


        function select_array(new_theme){
            selected_array=[];
            link_target=[];
            let ac_list=document.querySelectorAll('.skin-archiveList .skin-borderQuiet');
            for(let k=0; k<ac_list.length; k++){
                if(ac_list[k].classList.contains('select_item')){
                    selected_array.push(ac_list[k]);
                    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 +'&trep='+ new_theme); }}}}}


        function open_all(){
            trep_wtop=get_cookie('trep_wtop');
            trep_wleft=get_cookie('trep_wleft');

            let stop_out=document.querySelector('#stop_out');
            if(stop_out){
                stop_out.onclick=function(){
                    stop_out.style.boxShadow='inset 0 0 0 20px #1976d2';
                    stop_out.style.color='#fff';
                    stop_out.value='停止処理中';
                    reload_act(); }}

            progress(0);
            let next=0;
            open_win(next);
            let search=setInterval(continuas, 500); // 自動で実行指示 🟥
            function continuas(){
                if(new_win[next].closed){
                    next +=1;
                    progress(next);
                    if(next<link_target.length){
                        open_win(next); }
                    else{
                        progress(next);
                        clearInterval(search);
                        ending(); }}}}


        function progress(n){
            let disp='';
            let trep_progress=document.querySelector('#trep_progress');
            if(n>=0){
                for(let k=0; k<count; k++){
                    if(k<n){
                        disp +='🟦'; }
                    else{
                        disp +='⬜'; }}
                trep_progress.textContent=disp; }
            else{
                trep_progress.textContent=''; }}


        function open_win(n){
            new_win=[];
            let win_option='top='+trep_wtop+',left='+trep_wleft+
                ',width=620,height=260'; // 🔲

            new_win[n]=window.open(link_target[n], n, win_option); // 🔲
            selected_array[n].classList.remove('select_item');
            selected_array[n].classList.add('doing_item'); } // 処理中のグリーン表示


        function ending(){
            let trep_span=document.querySelector('#trep_span');
            if(trep_span){
                trep_span.innerHTML='処理が終了しました。 テーマ別記事リストを更新します';
                setTimeout(()=>{
                    reload_act();
                }, 4000); }}


        let w_position=document.querySelector('#w_position');
        if(w_position){
            w_position.onclick=function(event){
                event.preventDefault();
                let tmp_w;
                open_tmp();

                function open_tmp(){
                    if(!tmp_w || tmp_w.closed){
                        let win_option=
                            'top='+ get_cookie('trep_wtop') +
                            ',left='+ get_cookie('trep_wleft') +',width=620,height=260'; // 🔲
                        tmp_w=window.open('', 'tmp_window', win_option); // 🔲
                        if(!tmp_w.document.querySelector('#tmp_w_set')){
                            tmp_w.document.write(
                                '<p id="tmp_w_set" style="font: bold 18px Meiryo; '+
                                'padding: 30px 0 10px;">サブウインドウの位置設定</p>'+
                                '<p>このサブウインドウを適当な位置へドラッグします<br>'+
                                '下のボタンを押すとウインドウ位置が設定されます</p>'+
                                '<button style="font: bold 16px Meiryo; padding: 2px 10px 0;" '+
                                'onclick="window.close()" type="button">位置を設定</button>'+
                                '<style>body { background: #cbdce3; font-size: 16px; '+
                                'text-align: center; }</style>' ); }}}

                tmp_w.onbeforeunload=function(){ // Cookie保存 30日
                    trep_wtop=tmp_w.screenY;
                    trep_wleft=tmp_w.screenX;
                    document.cookie='trep_wtop='+trep_wtop+'; Max-Age=2592000';
                    document.cookie='trep_wleft='+trep_wleft+'; Max-Age=2592000'; }}}

    } // 記事一覧画面で動作


    function reload_act(){
        let theme_tab=document.querySelector('.skin-archiveNavTabs li:nth-child(3)>a');
        if(theme_tab){
            let theme_url=theme_tab.getAttribute('href');
            let org_url=location.pathname;

            let bord_active=document.querySelector('.skin-borderLoud.is-active');
            if(bord_active && bord_active.textContent=="テーマ別"){ // テーマ別画面の場合
                location.href=org_url; }
            else{
                sessionStorage.setItem('TRepN_org', org_url); // セッションストレージ書込み
                setTimeout(()=>{
                    location.href=theme_url +'?org';
                }, 100); }}}


    function get_cookie(name){
        let cookie_req=document.cookie.split('; ').find(row=>row.startsWith(name));
        if(cookie_req){
            if(cookie_req.split('=')[1]==null){
                return 0; }
            else{
                return cookie_req.split('=')[1]; }}
        if(!cookie_req){
            return 0; }}

} // main()



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=='trep'){
                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, '+
                '.p-theme__add { visibility: hidden; position: fixed; } '+
                '.l-form { padding: 16px 0 !important; } .l-body { padding: 0 15px; } '+
                'html { overflow: hidden !important; } '+
                '.p-title__text { min-width: 590px; width: 590px !important; } '+
                '.l-under-module { margin: 0px; } '+
                '.l-postTime { position: absolute; left: 0 !important; } '+
                '.p-theme { position: absolute; left: 250px !important; } '+
                '.p-theme__select { width: 340px; } '+
                '.l-footer { padding: 0; } '+
                '.p-submit__container { margin: 85px 280px 0 0 !important; }';

            style.setAttribute("id", 'trep_style');
            if(!document.getElementById('trep_style')){
                document.querySelector('body').appendChild(style); }

            if(theme_id){ // 編集画面の処理 🟦
                let interval=setInterval(find_selector, 40); // 処理タイミング 🟥
                function find_selector(){

                    let editor_iframe=document.querySelector('.cke_wysiwyg_frame');
                    let iframe_body;
                    if(editor_iframe){
                        let iframe_doc=editor_iframe.contentWindow.document;
                        if(iframe_doc){
                            iframe_body=iframe_doc.querySelector('body.cke_editable'); }}
                    let tageditor_text=document.querySelector('#entryTextArea');
                    let selector=document.querySelector('#js-themeSelector');
                    let publish=document.querySelector('.js-submitButton[publishflg="0"]');

                    if((iframe_body || tageditor_text) && selector && publish){
                        clearInterval(interval);
                        selector.value=theme_id;
                        rel();
                        function rel(){
                            setTimeout(()=>{
                                publish.click();
                            }, 1000); // 処理タイミング 🟥
                            setTimeout(()=>{
                                publish.style.background='red';
                                publish.click();
                            }, 5000); } // バックアップ押下 停止を救済する🟥
                    }}}
        } // 最新版エディタで動作


        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", 'trep_style');
            if(!document.getElementById('trep_style')){
                document.querySelector('body').appendChild(style); }

            if(theme_id){ // 編集画面の処理 🟦
                let interval=setInterval(find_selector, 200); // 処理タイミング 🟥
                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();
                            }, 1500); // 処理タイミング 🟥
                            setTimeout(()=>{
                                publish.style.background='red';
                                publish.click();
                            }, 5000); } // バックアップ押下 停止を救済する🟥
                    }}}
        } // タグ編集エディタで動作

    }}); // 編集画面で動作



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

}); // 送信完了画面で動作



 

 

〔追記〕2021.02.16

リロード部コードを更新し ver. 1.15 としました。 詳細は次々ページ参照ください。

 

 

 

「Theme Rep N」最新版について 

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

 

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