Actually, when the browser action is clicked: http://code.google.com/chrome/extensions/browserAction.html#event-onClicked
you get the Tab object already, so you don't even have to call getSelected. :) Adam On Mon, Dec 7, 2009 at 12:44 PM, Adam Barth <[email protected]> wrote: > You probably want to call this function to get information about the > current tab: > > http://code.google.com/chrome/extensions/tabs.html#method-getSelected > > Then you want to read the url property of the Tab object, and prepend > your string. Finally, you want to call update: > > http://code.google.com/chrome/extensions/tabs.html#method-update > > to change the location of the tab. Should be a fun, simple extension! > Good luck! > > Adam > > > On Sun, Dec 6, 2009 at 2:24 PM, Godfrey Harrylal > <[email protected]> wrote: >> Ok, I've gotten so frustrated with having to open another browser or >> manually loading up the StumbleUpon web toolbar lately that this >> afternoon, I decided to try my hand at writing an extension. The idea >> was simple, and just a quick fix until a real toolbar for Chrome is >> created. I just wanted a button (browser_action from what I >> understand) to re-load the current page in the same tab prefixed with >> "http://www.stumbleupon.com/toolbar/#url=" so that the StumbleUpon Web- >> Toolbar shows. I got as far as a full manifest: >> >> { >> "name": "Stumbleupon Web-Toolbar Extension", >> >> "version": "1.0", >> >> "description": "Prefixes current URL with <http:// >> www.stumbleupon.com/toolbar/#url=> to enable SU web toolbar", >> >> "browser_action": { >> "default_icon": "stumbleupon.png", >> "default_title": "Reload the current page with the StumbleUpon Web- >> Toolbar enabled" >> }, >> "permissions": [ >> "tabs" >> ]} >> >> (http://www.doitmyselfblog.com/wp-content/uploads/2008/08/ >> stumbleupon.png) <- image taken from here. >> >> And now, I have no idea what to do. I've never done any Javascript or >> real coding before, so help would be appreciated, although I'm not >> going to turn it down if someone just does it and uploads the ".crx". >> >> What am I supposed to do with "chrome.tabs.create(object >> createProperties, function callback)"? >> From what I've seen so far, this doesn't go in the manifest... or does >> it? I think it's supposed to be in a ".js" file... but how do I link >> that to be manifest? Basically, how do I get my nice button to refresh >> the current tab when clicked, with "http://www.stumbleupon.com/toolbar/ >> #url=(url before click here)". >> >> Example: >> >> 1) I'm have a tab open with the url "http://www.google.com" >> 2) I click the button >> 3) The current tab refreshes with a new url: "http:// >> www.stumbleupon.com/toolbar/#url=http://www.google.com" >> >> If opening in a new tab is easier to explain or implement, that'd work >> too. >> >> Thanks to whoever responds! >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> "Chromium-extensions" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/chromium-extensions?hl=en. >> >> >> > -- You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.
