I am trying to make a simple chrome extension, which can find a text in a webpage and make it bold. When I find a simple text, it works, however, it does not work when an original text includes html tag.
Here are my codes,
$("p:contains(" + "like apple" + )").html(
function( _ , html ) {
return html.split("like apple").join("<b>" + "like apple" + "/b>");
}
)
For example,
if I find word "like apple", in <p>I like apple</p>, it becomes <p>I <b>like apple</b></p>.
However, for <p>I like <i>apple</i></p>, the code can not find the words "like apple" because of <i>.
How can I fix the code, which can find a text including html tags and change its css style?