1

AIM : when ever new tab is opened extension makes a request with the url to server and get the response and change the icon color .

background.js :

chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) 
 {
    url = "http://localhost/test.php?"+ $.param({"url":tab.url});
    $.get(url, function(responseText) {
    console.log("sent data");
  });
});

manifest.json :

 ..."background": { "scripts": ["background.js"] ,"persistent": false },
 "permissions": ["tabs","http://localhost/", "http://*/*"],....

this doesnt works .

but when binded with a button on extension page as :

function send_url(){
  chrome.tabs.getSelected(null,function(tab){
  url = "http://localhost/test.php?"+ $.param({"url":tab.url});
  $.get(url, function(responseText) {
  console.log("url sent ");
  });
 });
}

this sends the url to my local server ! is there any thing which is missing with background.js

S..
  • 5,511
  • 2
  • 36
  • 43
Ratan Kumar
  • 1,640
  • 3
  • 25
  • 52

1 Answers1

2

This is what i was looking for :

 "background": { "scripts": ["assets/js/jquery.min.js","background.js"] ,"persistent": false },
Ratan Kumar
  • 1,640
  • 3
  • 25
  • 52