Use Chrome Extension to Modify Google Search Result Page -


i wanna make chrome extension modify google search result page. know can use content script because has ability this. unfortunately fails. wrote code

$('h3.r').append('<b>a</b>') 

or else related dom operations failed. if wrote

alert('aa') 

or

document.body.style.backgroundcolor='green' 

, works. why? way, want have debug when open development tools can not find extension content script. can see other extensions' content scripts.

did add jquery content_scripts in manifest?

if use jquery, must write manifest.json this:

 "content_scripts":[         {             "matches":["http://www.google.com/*"],             "js":["jquery-1.9.1.min.js", "contentscripts.js"]         } ] 

ok, after read page source of google search result page think know problem is:

google loads search result ajax, so, when change query words , search again, page does not refresh, that's why can not dom elements in search result.

that means have add event listener domnodeinserted.

code this:

function fundh3(){   $('h3.r').append('<b>a</b>')  }  searchresultarea.addeventlistener('domnodeinserted', findh3); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -