title: Running chrome extension process while popup is closed
body: <p>Basically I am trying to create an Auto Visitor Extension for Chrome to open a website's URL after some specific time. When I open the popup everything works fine but when the popup is close nothing works. I am trying to find out a method to run that Auto Visitor Extension even when the popup is close I have read multiple questions regarding this phenomena on Stack Overflow but none of them clarifies what I am looking for.</p>
  
  <p>Here is my manifest file:</p>
  
  <p><strong>manifest.json</strong></p>
  
  <pre><code>{
    "manifest_version": 2,
    "name": "Auto Visitor",
    "description": "This extension will visit multiple pages you saved in extension",
    "version": "1.0",
  
    "browser_action": {
     "default_icon": "icon.png",
     "default_popup": "popup.html"
    },
    "background": {
      "scripts": [
        "background.js"
      ],
      "persistent": false
    },
    "permissions": [
     "activeTab",
     "storage",
     "tabs",
     "http://*/",
     "https://*/"
     ]
  }
  </code></pre>
  
  <p>The background file that i want to run even when popup is close :</p>
  
  <p><strong>background.js</strong></p>
  
  <pre><code>// this will work only when you denie the background script in manifest
  chrome.runtime.onInstalled.addListener(function(details) {
      var initTime = 5;
      chrome.storage.local.set({"avtime": initTime}, function() {});
  });
  reloadMainTab();
  function reloadMainTab() {
   chrome.storage.local.get('avurl', function (result) {
        var urlsToLoad = result.avurl;
        console.log(urlsToLoad);
        if(urlsToLoad==undefined){
          // do nothing
        }else{
            var urlsArr = urlsToLoad.split(",");
                chrome.storage.local.get('avtime', function (result) {
                    var thisTime = result.avtime;
                    /*
                     setting it to -1 because it gets incremented by 1 
                     when it goes into getSelected method
                    */
                    var index=-1;
                    setInterval(function(){
                      if(index &lt; urlsArr.length-1){ 
                        chrome.tabs.getSelected(function (tab) {
                          // console.log('index in get selected'+index)
                          chrome.tabs.update(tab.id,{url: urlsArr[index]});
                        });
                        index++;
                      }else{
                        index=-1;
                      }  
                    }, thisTime+"000");
  
                });
        }
    });
  }
  </code></pre>
  
  <p>any help would be really appreciated</p>