Created
February 9, 2016 09:43
-
-
Save lackneets/fa92cac4e3e5f125f211 to your computer and use it in GitHub Desktop.
Chinese Friendly (No more 14px chinese font)
This file contains hidden or 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
javascript: (function(){ | |
"use strict"; | |
var regexCJ = /[\u4e00-\u9fa5]+|[\u0800-\u4e00]+/; | |
function getTextContainerNodes(){ | |
var nodes = Array.from(document.body.getElementsByTagName("*")); | |
var leafNodes = nodes.filter(function(elem) { | |
return elem.hasChildNodes() && Array.from(elem.childNodes).filter(function(node){ | |
return node.nodeType === 3; | |
}).length > 0 | |
}); | |
return leafNodes; | |
} | |
getTextContainerNodes().forEach(function(node){ | |
var size = parseInt(window.getComputedStyle(node).fontSize); | |
window.test = node; | |
if(size == 14 && node.innerText.match(regexCJ)){ | |
node.style.fontSize = '13px'; | |
node.style.lineHeight = '2em'; | |
} | |
}); | |
})(); |
This file contains hidden or 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
(function(){ | |
"use strict"; | |
var regexCJ = /[\u4e00-\u9fa5]+|[\u0800-\u4e00]+/; | |
function getTextContainerNodes(){ | |
var nodes = Array.from(document.body.getElementsByTagName("*")); | |
var leafNodes = nodes.filter(function(elem) { | |
return elem.hasChildNodes() && Array.from(elem.childNodes).filter(function(node){ | |
return node.nodeType === 3; | |
}).length > 0 | |
}); | |
return leafNodes; | |
} | |
getTextContainerNodes().forEach(function(node){ | |
var size = parseInt(window.getComputedStyle(node).fontSize); | |
window.test = node; | |
if(size == 14 && node.innerText.match(regexCJ)){ | |
node.style.fontSize = '13px'; | |
node.style.lineHeight = '2em'; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before
After