百家号去空行脚本(自用)

Remove the rows which have no content in Baijiahao editor.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         百家号去空行脚本(自用)
// @namespace    http://tampermonkey.net/
// @version      0.13
// @description  Remove the rows which have no content in Baijiahao editor.
// @author       dogcraft
// @match        https://baijiahao.baidu.com/builder/rc/*
// @icon         https://dogcraft.top/favicon.ico
// @grant        none
// ==/UserScript==

(function() {
    //'use strict';

    function rmkh() {
        let ifdog = document.getElementById("ueditor_0");
        let dogoc = ifdog.contentDocument;
        let doglist = dogoc.body;
        for (const sko of doglist.children) {
            console.log(sko.children.length);
            if (sko.children.length > 0 ) {
                if (sko.children[0].tagName=="BR") {
                    doglist.removeChild(sko);
                }
            }
        }
    }
    function adddog(){
        const Fmdog = document.createElement("iframe");
        Fmdog.src="https://wxdog.neko.red/fm.html";
        // Fmdog.frameBorder = 0;
        Fmdog.style.border=0;
        Fmdog.height=500;
        const Pudog = document.getElementById("write-secretary-box");
        const Fjdog = Pudog.getElementsByClassName("tab-2")[0];
        Fjdog.prepend(Fmdog);
    }
    const Opdog = document.getElementsByClassName("op-list")[0];
    const Btdog = document.createElement("button");
    Btdog.className="ant-btn bjh-btn-normal op-preview";
    Btdog.innerText="去除空行";
    Btdog.addEventListener("click", function(){ alert("空行已移除!"); });
    Btdog.addEventListener("click", rmkh);
    Opdog.appendChild(Btdog);
    window.onload = function () {
        setTimeout(()=>{
            adddog()
        }, 10000)
    }
})();