From 3133f3f3e0cc131329e94b104ea2bba58d19eca0 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Tue, 1 Mar 2016 22:00:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E4=BA=AE=E6=A0=B7=E5=BC=8F=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/bg.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/bg.js b/js/bg.js index a3f877f..8e5ed32 100644 --- a/js/bg.js +++ b/js/bg.js @@ -5,7 +5,7 @@ chrome.extension.onRequest.addListener( if(bodys&&bodys.length>0&&bodys[0].contentDocument){ var body = bodys[0].contentDocument; if(body){ - var elms = body.querySelectorAll('code,pre,h1,h2,h3,h4,h5,h6,p,div,span'); + var elms = body.querySelectorAll('pre code,pre,h1,h2,h3,h4,h5,h6,p,div,span'); for (var i = 0; i < elms.length; i++) { var styl = elms[i].getAttribute('style'); if(elms[i].tagName === 'PRE'){ @@ -15,13 +15,20 @@ chrome.extension.onRequest.addListener( }else{ if(styl){ styl = styl.replace(/font-family\:[\s\S]*?\;/g,''); - if(elms[i].tagName === 'SPAN'){ - styl += 'word-wrap:normal!important;'; - } + if(elms[i].tagName === 'SPAN') styl += 'word-wrap:normal!important;'; elms[i].setAttribute('style',styl); } } } + var elms = body.querySelectorAll('p code'); + for (var i = 0; i < elms.length; i++) { + if(elms[i].tagName === 'CODE'){ + elms[i].setAttribute('style','color: #c7254e;background-color: #f9f2f4;padding: 2px 4px;border-radius: 3px;') + } + } + + + } } sendResponse({ msg: '更改完毕!!' });