您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
去掉内联字体样式,删除三个以上换行。
当前为
// ==UserScript== // @name 真白萌新站阅读体验优化 // @namespace mashiro_me // @version 0.3 // @description 去掉内联字体样式,删除三个以上换行。 // @author MikaRyu // @match https://masiro.me/admin/novelReading* // @license BSD // @icon https://www.google.com/s2/favicons?domain=masiro.me // @grant none // ==/UserScript== (function() { 'use strict'; //最大保留换行数 var maxBreakLines = 3; //纯文本模式Falg(改为true使用纯文本模式) var textModFlag = false; //小说内容Box var baseBox = document.getElementsByClassName("box-body nvl-content")[0]; if (textModFlag){ //复制纯文本Box var textBox = baseBox.parentNode.insertBefore(baseBox.cloneNode(false), baseBox); //文本内容复制 FormartNodesAsText(textBox, baseBox); //原内容节点删除 baseBox.parentNode.removeChild(baseBox); }else{ //删除空行 DeleteEmptyRows(baseBox) //删除字体、字体大小、字体颜色 DeleteFontStyles(baseBox); } //删除【maxBreakLines】个以上的换行 DeleteMultiBrs(baseBox, maxBreakLines); })(); function FormartNodesAsText(base, parent){ var childs = parent.childNodes; var orgLth = childs.length; var tagName, innerText, br; for(var i = 0; i < orgLth; i++){ tagName = childs[i].localName; if (typeof(tagName) == "undefined"){ innerText = childs[i].data; if (/^( |\s)*$/.test(innerText)){ continue; } if (/^( |\s)*([「『【[\[]{1}).*([」』】]\]]){1}( |\s)*$/.test(innerText)) { base.appendChild(document.createElement("br")); base.appendChild(childs[i].cloneNode(false)); if (((i + 1) == orgLth) || ( childs[i+1].localName != "br" )){ base.appendChild(document.createElement("br")); } }else{ base.appendChild(childs[i].cloneNode(false)); } if ((i + 1) < orgLth){ if( childs[i+1].localName != "br" ){ base.appendChild(document.createElement("br")); } }else{ base.appendChild(document.createElement("br")); } }else if (tagName == "br" || tagName == "img"){ base.appendChild(childs[i].cloneNode(false)); }else{ if (childs[i].hasChildNodes()){ FormartNodesAsText(base, childs[i]); } } } } function DeleteFontStyles(parent){ var childs = parent.childNodes; var style; for(var i = 0; i < childs.length; i++){ style = childs[i].style; if (typeof(style) != "undefined"){ childs[i].style.fontFamily = null; childs[i].style.fontSize = null; childs[i].style.color = null; } if (childs[i].hasChildNodes()){ DeleteFontStyles(childs[i]); } } } function DeleteEmptyRows(parent){ var childs = parent.childNodes; var tagName, innerText; for(var i = 0; i < childs.length; i++){ tagName = childs[i].localName; if (tagName == "br" || tagName == "img"){ continue; } innerText = childs[i].innerHTML; if (typeof(innerText) == "undefined"){ innerText = childs[i].data; } if ((/^( |\s)*$/g.test(innerText)) || ((! childs[i].hasChildNodes()) && typeof(tagName) != "undefined")){ parent.removeChild(childs[i]); i -= 1; continue; } DeleteEmptyRows(childs[i]); } } function DeleteMultiBrs(parent, num){ var j = 0; var childs = parent.childNodes; var tagName; for(var i = 0; i < childs.length; i++){ tagName = childs[i].localName; if (tagName == "br"){ if( j == num ){ parent.removeChild(childs[i]); i -= 1; }else{ j += 1; } continue; } j = 0; if (childs[i].hasChildNodes()){ DeleteMultiBrs(childs[i], num); } } }