Question: I have an extension to count the number of stylesheets.
When the icon is pressed, the stylesheets of all opened windows or tabs are shown.
However, the extension has no effect on the windows and tabs that are opened later.
How can I solve it ?

**manifest.json**

```
{
 "name": "StyleSheets counter",
 "description": "It counts the stylesheets linked with the web page",
 "version": "2.0",
 "permissions": [
    "tabs", 
"*://*/*",
    "activeTab",
"debugger" 
  ],
 "background": {
 "scripts": ["background.js"],
 "persistent": false
},
"browser_action": {
"default_icon": "SS Counter"
},
"icons": {
    "48": "on.png", 
"48": "off.png" 
},
 "manifest_version": 2
}

```

**background.js**

```
chrome.browserAction.onClicked.addListener(function(tab) {
executeScriptsInExistingTabs();
});

function executeScriptsInExistingTabs(){
    chrome.windows.getAll(null, function(wins) {
      for (var j = 0; j < wins.length; ++j) {
        chrome.tabs.getAllInWindow(wins[j].id, function(tabs) {
          for (var i = 0; i < tabs.length; ++i) {
            if (tabs[i].url.indexOf("chrome://") != 0) {
              chrome.tabs.executeScript(tabs[i].id, { file: 'counter_ss.js' });
            }
          }
        });
      }
    });
}

```

**counter\_ss.js**

```
var theSheets = document.styleSheets;
alert("Number of stylesheets: " + theSheets.length);

```

Answer: 
Change the action's trigger selector to `#scroll-top:not(.menu-stick)`

So:

```
if (distance + navHeight) <= 1) {
    $('#scroll-top:not(.menu-stick)').slideToggle(700, 'easeOutBounce', function() {
        $(this).addClass('menu-stick');
    });
}

```
I obviously can't see all of your code, but possibly try doing a check if the element is already stuck or not:

```
if ( !$('#scroll-top').hasClass('menu-stick') ) {
    // Do animation
    // add class 'menu-stick'
}

```