百家号去空行脚本

Remove the rows which have no content in Baijiahao editor.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         百家号去空行脚本
// @namespace    http://tampermonkey.net/
// @version      0.1
// @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.getElementsByTagName("iframe")[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);
                }
            }
 
        }
 
    }
    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);
})();