mirror of
https://github.com/jaywcjlove/wxmp.git
synced 2026-01-10 15:28:47 +08:00
高亮样式添加
This commit is contained in:
15
js/bg.js
15
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: '更改完毕!!' });
|
||||
|
||||
Reference in New Issue
Block a user