javascript - Adding an icon to content & handling its events -


i trying use code dont know exact class google search results replace "the_search_result_class". please me find out dom class google search results on google search page.

function somefunction() {     alert("the user clicked on icon.") }  var icon = document.createelement("img"); icon.src = chrome.extension.geturl("icon.png"); var searchresults = document.getelementsbyclassname("the_search_result_class") (var = 0; < searchresults.length; i++) {     var searchresulticon = icon.clonenode();     searchresulticon.addeventlistener("click", somefunction, false);     searchresults[i].append(searchresulticon); } 

to find out dynamic class name on page:

  1. open developer console (ctrl+shift+j)
  2. click on "elements" tab , on magnifying glass icon
  3. select element interested in on page , see html source below.

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -