开发者

Google Chrome Help

开发者 https://www.devze.com 2023-03-05 00:20 出处:网络
I want to make an extension that highlights a certain word (for example food) on every page the person visits. I was curious as how to do开发者_开发技巧 this, with a google chrome extension. You shoul

I want to make an extension that highlights a certain word (for example food) on every page the person visits. I was curious as how to do开发者_开发技巧 this, with a google chrome extension.


You should be able to do this just using content scripts. In your content script JS file, this line should do the trick (assuming you also include jQuery in your JS content script includes):

$('body').html($('body').html().replace(word_of_choice, '<span class="highlighted">' + word_of_choice + '</span>'));

And define the highlighted class in a CSS file in your content script includes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号