// ==UserScript==
// @name 移除笔趣阁多余的空格
// @namespace http://www.biquxs.com/
// @version 0.2
// @description Remove consecutive and
elements on biquxs.com
// @author zsjng
// @match http://www.biquxs.com/*
// @grant none
// @license MIT
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
// 获取所有文本节点
function getAllTextNodes(element) {
var walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT, null, false);
var nodes = [];
while (walker.nextNode()) {
nodes.push(walker.currentNode);
}
return nodes;
}
// 替换连续的8个 为一个空格
function replaceConsecutiveNbsp() {
var textNodes = getAllTextNodes(document.body);
for (var i = 0; i < textNodes.length; i++) {
var textNode = textNodes[i];
textNode.nodeValue = textNode.nodeValue.replace(/(\u00A0){8}/g, ' ');
}
}
// 移除