博客园美化首页随笔同时一天发布内容分开分开版块展示

博客园美化首页随笔同时一天发布内容分开分开版块展示

由于我有点强迫症很不习惯博客园会把同一天发的随笔黏一起

一.直接上js代码

<script>
    let forFlow = document.querySelector('.forFlow');
    let day = forFlow.querySelectorAll('.day');
    let topicListFooter = forFlow.querySelector('.topicListFooter');
    let forFlow_html = '';
    let new_day_html = '';
    let new_data = '';
    for (let day_index = 0; day_index < day.length; day_index++) {
        let dayTitle = day[day_index].querySelector('.dayTitle');
        let day_html = day[day_index].innerHTML;
        day_html_list = day_html.split('</div>');
        for (let day_html_list_index = 0; day_html_list_index < day_html_list.length - 1; day_html_list_index++) {
            data = day_html_list[day_html_list_index];
            let data_dayTitle = (data.match('dayTitle'));
            let data_postCon = (data.match('postCon'));
            let data_postTitle = (data.match('postTitle'));
            let data_clear = (data.match('clear'));
            let data_postSeparator = (data.match('postSeparator'));
            let data_postDesc = (data.match('postDesc'));
            if (data_postTitle != null) {
                new_data = '<div class="day">' + '<div class="dayTitle">' + dayTitle.innerHTML + '</div>' + data + '</div>';
            } else if (data_postCon != null) {
                new_data = data + '</div>' + '<div class="postDesc"></div>'+'<div class="clear"></div>'+'</div>';

            } else {
                if (data_dayTitle == null) {
                    if (data_postDesc == null) {
                        if (data_postSeparator == null) {
                            if (data_clear == null) {
                                new_data = data + '</div>';
                            }
                            else {
                            new_data = ''

                        }
                        }

                    }

                }

            }
            console.log(new_data);
            new_day_html = new_day_html + new_data;

        }

        forFlow_html = forFlow_html + new_day_html;
        new_day_html = '';
        new_data = '';

    }
    forFlow_html = forFlow_html+'<div class="topicListFooter">' + topicListFooter.innerHTML + '</div>';
    if (forFlow_html != '') {                     <!-- 为了解决正文会无法加载-->
        forFlow.innerHTML = forFlow_html
    }
</script>

二.缺点

1.编辑栏我把他删了 因为我用不到

要修改区域在

   if (data_postDesc == null) 
    这里修改代码
posted @ 2019-08-18 23:56  小小咸鱼YwY  阅读(477)  评论(0编辑  收藏  举报