Last active
June 6, 2017 10:12
-
-
Save DemoJameson/1588021b763721a188796b75aafa853c to your computer and use it in GitHub Desktop.
去除 Kotlin 中文站文档多余空格
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 去除 Kotlin 中文站文档多余空格 | |
// @namespace http://demojameson.com/remove-kotlin-cn-doc-unnecessary-space | |
// @version 0.2 | |
// @description 去除 Kotlin 中文站文档多余空格 | |
// @author DemoJameson | |
// @match https://www.kotlincn.net/docs/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var ELEMENT = 1; | |
var TEXT_NODE = 3; | |
removeTextNodeNewLine(document.body); | |
function removeTextNodeNewLine(element){ | |
if (element.nodeType === ELEMENT) { | |
if (element.tagName === 'CODE' || element.tagName === 'PRE') return; | |
element.childNodes.forEach(function(child){ removeTextNodeNewLine(child);}); | |
} else if (element.nodeType === TEXT_NODE) { | |
element.textContent = element.textContent.replace(/\n/g, ''); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment