Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I haven't tested it myself (due to lack of time), but I believe that the problem is this:</p> <p><strong>The problem</strong><br> You are creating the tabs from <code>popup.js</code>. As soon as a new tab receives focus, the popup (<code>popup.html</code>) is closed/hidden and any JavaScript execution stops. This means that there will be so many tabs opened as many <code>popup.js</code> managed to create <strong>before</strong> the first tab received focus. So, sometimes it will be all, sometimes some etc.</p> <p><strong>The solution</strong><br> The solution is to mive the "tab-creating" code in the background page (or better yet event page). E.g.:</p> <pre><code>// ...in popup.js ... chrome.runtime.getBackgroundPage(function(bgPage) { bgPage.openAllURLsInTabs(); }); ... </code></pre> <p>(Of course, there are many approaches possible, e.g. message-passing etc.)</p> <p><strong>The demo</strong><br> For demonstration purposes, I have put together a tiny extension that opens your 22 URLs is new tabs. For simplicity, it does not feature a popup, just a browser-action.<br> The file structure is like this:</p> <pre><code>TestCX |__background.js |__jquery-1.7.2_min.js |__manifest.json </code></pre> <p><em><strong>background.js:</em></strong></p> <pre><code>var urlList = [ "http://stackoverflow.com/", "http://en.wikipedia.org/wiki/Main_Page", "http://www.codinghorror.com/blog/", "http://nodejs.org/", "https://github.com/", "http://wallbase.cc/", "http://www.chromium.org/Home", "http://www.photoshoptuto.com/?s=test+chrome+tabs", "http://www.youtube.com/", "https://www.tumblr.com/", "http://www.imdb.com/", "http://www.flickr.com/", "http://kickass.to/", "https://www.dropbox.com/", "http://fr.slideshare.net/", "http://www.deviantart.com/", "http://www.livejournal.com/", "http://ohnotheydidnt.livejournal.com/82624099.html", "http://www.etsy.com/", "http://www.mediafire.com/", "http://www.foxnews.com/", "http://www.foxnews.com/politics/2013/10/21/obama-addresses-problems-with-health-care-website/" ]; chrome.browserAction.onClicked.addListener(function() { $.each(urlList, function(key, val) { chrome.tabs.create({ url: val }, function(tab) { console.log("Opened: " + tab.url); }); }); }); </code></pre> <p><em><strong>manifest.json:</em></strong></p> <pre><code>{ "manifest_version": 2, "name": "Paste All URLs", "version": "2.5", "browser_action": { "default_title": "Paste many URLs" }, "background": { "scripts": [ "jquery-1.7.2_min.js", "background.js" ] }, "permissions": [ "tabs" ] } </code></pre> <hr> <p>I hope this helps you solve your problem. If not come back for more :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload