Skip to content

Instantly share code, notes, and snippets.

@jhchabran
Created November 3, 2012 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhchabran/4006424 to your computer and use it in GitHub Desktop.
Save jhchabran/4006424 to your computer and use it in GitHub Desktop.
# Install the message listener
chrome.extension.onRequest.addListener (request, sender, sendResponse)->
# Select the right response given the message
switch request.message
# Grab all tabs
when "getTabs"
chrome.windows.getCurrent (window)->
chrome.tabs.getAllInWindow window.id, (tabs)->
# We've collected all tabs, let's send them back
sendResponse(tabs:tabs)
break
when "switchTab"
chrome.tabs.update(request.target.id, selected:true)
sendResponse({})
break
else
sendResponse({})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment