My html page has this code: <html> <head> <script> // Called when the user clicks on the browser action. chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.executeScript(null, {file: "addfriends.js", allFrames: true}); }); chrome.browserAction.setBadgeBackgroundColor({color:[0, 200, 0, 100]}); var i = 0; window.setInterval(function() { chrome.browserAction.setBadgeText({text:String(i)}); i++; }, 10); </script> </head> </html> Code (markup): The problem is the addfiles.js script not loading. The other action works, and creates a icon with numbers counting shown on my Chrome toolbar next to the "wrench" icon. Not sure if there's an error in the above execute function code, or if there's some error in the code of the file, addfiles.js, itself. Below is the content of addfiles.js : document.body.style.background = "red"; var elms = "document.getElementsByName("checkableitems[]")"; for (i=0;i<elms.length;i++){if (elms[i].type="checkbox" )elms[i].click()}; }); Code (markup): Now, this code is for a Chrome extension I'm making. It is supposed to create a button on the toolbar, which consist of a green background with numbers counting upwards - this part works fine - then when this button is clicked its supposed to call and execute the addfiles.js code, and there's where the problem is as nothing happens. What should happen is that the background color of the website I am in when clicking this button should change to red, the second function is specifically for Facebook to automatically select all friends in my list when wanting to invite people for some event. The code for that part, in the addfiles.js file, is based upon a href code calling javascript to execute, which works when simply copying it and pasting it into the web browers URL field - this code looks like this: javascript:elms=document.getElementsByName("checkableitems[]");for%20(i=0;i<elms.length;i++){if%20(elms[i].type="checkbox"%20)elms[i].click()}; Code (markup): So the above code is functional as it works completely fine when copy-pasting it into the url field while in Facebook and having the invite-box for selecting friends open there. However, trying to do it with my above-mentioned chrome extension script it does not work. Any suggestions on what's wrong here and how I can get this to work when executed from my script as well using the mentioned button I've got added to my Chrome's toolbar?
Yes all files in dame directory. But no worries, I managed to figure it out on my own. The background color changer was removed completely in my new and final version of the script, as it was only part of testing. I also changed the number counting icon appearing on the toolbar to a icon that simply says "Add" as the script is now finished and turned into a working Chrome extension. It's function is to Add all Friends when Inviting to a page, event or group by first selecting the Invite friends button in Facebook, scroll down to the bottom of the list that comes up to get all friends loaded in the box (or else only the first few will be selected by the Add Extension) - then simply click the green icon saying "Add" on the Chrome toolbar and ALL friends in your list will be selected at once even if you have thousands. With many friends it may take a time to load before they appear selected. Then simply send out the invitation as you wish to them all at once. I'm attaching the source code files & scripts in its full here, if anyone are interested in taking a look at how I worked it out. The zip archive can be extracted to a folder and installed using Extensions option in Tools in Chrome, using the Developer mode to select the folder and install it with the "Load unpacked extensions.." button. For quick and easy install, go to the official page at http://www.chromeextensions.org/?p=16630 and simply click "Add to Chrome" and you'll get it installed immediately. Description of this extension’s features: It’s function is to Add all Friends when Inviting to a page, event or group by clicking “Add†on the Chrome toolbar and ALL friends in your list will be selected at once even if you have thousands. With many friends it may take a time to load before they appear selected. Then simply send out the invitation to them all at once. So, easy steps: 1. Install “Facebook Add All friends to Invite†extension in Chrome 2. Go to Facebook and enter the page you want to invite someone, click the “Invite friends†button there. 3. When the list of friends comes up, scroll down to bottom of the list so all friends are properly loaded into the box. 4. Then click the green “Add†button in your toolbar in Chrome and all friends are selected even if thousands! 5. Send out the invitation! Enjoy! View attachment Facebook Add All Friends to Invite v1.0.zip