title: Google Chrome Extension to highlight and alert all links on a webpage
body: <p>I am a newbie in writing Google Chrome Extensions. I (specifically) intended to make a <code>browser action</code> extension which when clicked would open all the links(URLs) on a page resulting when we <code>Google Search</code> any topic.
  Till now I'm able to make something which <em><code>highlights</code></em> and <strong><em><code>alerts</code></em></strong><code>(javascript alert function )</code> the links present on any webpage.<br>
  The <code>manifest.json</code> and the <code>script</code> file required are given below:-<br><br>
  <br>
  <strong><code>manifest.json==&gt;</code></strong></p>
  
  <p><code>{</code><br>
    <code>"name": "Highlight then alert.",</code><br>
    <code>"description": "Highlight and alert links on a webpage.",</code><br>
    <code>"version": "1.1",</code><br>
    <code>"background": {</code><br>
      <code>"scripts": ["write.js"]</code><br>
    <code>},</code><br>
    <code>"permissions": [</code><br>
      <code>"tabs", "http://*/*", "https://*/*"</code><br>
    <code>],</code><br>
    <code>"browser_action": {</code><br>
        <code>"default_title": "highlighter",</code><br>
        <code>"default_icon": "highlight_16x16.png"</code><br>
    <code>},</code><br>
    <code>"manifest_version": 2</code><br>
  <code>}</code><br></p>
  
  <p><strong><code>write.js==&gt;</code></strong><br><br></p>
  
  <p><code>chrome.browserAction.onClicked.addListener(function(tab) {</code><br></p>
  
  <p><strong><code>var action_url1 = "javascript:(function()</code><br><code>{for(i=0;i&lt;document.links.length;i++)alert(document.links[i]);})();";</code></strong><br>
  <br> 
  <strong><code>var action_url2 = "javascript:(function()</code><br><code>{for(i=0;i&lt;document.links.length;i++)document.links[i].style.backgroundColor='#F00';})();";</code></strong><br><br>
  <code>chrome.tabs.update(tab.id, {url: action_url1});</code><br>
  <code>chrome.tabs.update(tab.id, {url: action_url2});</code><br>
  <code>});</code><br><br><br>
  Right now, I am writing a simple <code>inline</code> javascript code , storing them in different variables as shown and then passing them into the Chrome Object method<br>- <strong><code>chrome.tabs.update()</code></strong> to perform the the <code>highlight</code> and <code>alert</code> operation.<br>
  I need to figure out a way to perform the same operation by writing an absolute javascript function rather than passing through a variables.<br>
  Suggestions ?</p>