代码高亮强制不换行

This commit is contained in:
jaywcjlove
2016-02-25 12:38:57 +08:00
parent ca72caef9c
commit 86172ed9a8

View File

@@ -8,13 +8,15 @@ chrome.extension.onRequest.addListener(
var elms = body.querySelectorAll('code,pre,h1,h2,h3,h4,h5,h6,p,div,span'); var elms = body.querySelectorAll('code,pre,h1,h2,h3,h4,h5,h6,p,div,span');
for (var i = 0; i < elms.length; i++) { for (var i = 0; i < elms.length; i++) {
var styl = elms[i].getAttribute('style'); var styl = elms[i].getAttribute('style');
if(styl){
styl = styl.replace(/font-family\:[\s\S]*?\;/g,'')
elms[i].setAttribute('style',styl)
}
if(elms[i].tagName === 'PRE'){ if(elms[i].tagName === 'PRE'){
elms[i].setAttribute('style','box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding: 5px; border: 0px; outline: 0px; vertical-align: baseline; overflow: auto; border-radius: 3px; word-break: break-all; word-wrap: break-word; font-stretch: normal; line-height: normal; color: rgb(51, 51, 51); background-color: rgb(247, 247, 249); ') elms[i].setAttribute('style',' word-wrap: normal!important;box-sizing: border-box; overflow: auto;font-size: 0.93em; padding: 1em; margin-top: 1.5em; margin-bottom: 1.5em; line-height: 1.3; word-break: break-all; word-wrap: break-word; color: rgb(101, 123, 131); border: none; border-radius: 3px; max-height: 35em; background-color: rgb(246, 246, 246);')
}else if(elms[i].tagName === 'CODE'){
elms[i].setAttribute('style','box-sizing: border-box;font-size: 1em; color: inherit; border-radius: 0px; white-space: inherit; overflow-wrap: normal; background: none;')
}else{
if(styl){
styl = styl.replace(/font-family\:[\s\S]*?\;/g,'');
elms[i].setAttribute('style',styl);
}
} }
} }
} }