1

I have seen this in other Chrome extensions but I have failed to figure out how to do it. Here is my question.

When someone installs my extension I want to open a new tab (to my homepage).

How is this done?

I assume this is done somehow in JavaScript. I have considered setting a cookie or a LocalStorage var, but this doesn't seem very logical since those can be deleted and could cause a new tab to open.

TheRealJAG
  • 1,978
  • 20
  • 16

1 Answers1

1

This should help you check if your extension was just installed:

Detect Chrome extension first run / update

This works, as you thought, using local storage variable. Variables that your extension sets are not available to other extensions so only your extension can delete them. Also, variables from local storage are preserved when browser is restarted. So you should not be concerned about variable being deleted.

To open new tab use chrome.tabs.create function from the tabs module.

Community
  • 1
  • 1
Konrad Dzwinel
  • 36,825
  • 12
  • 98
  • 105
  • Works great but the only problem I have with this solution is this requires the extension to run in the background. I'm trying to avoid this. – TheRealJAG Jan 24 '12 at 22:01
  • I don't think you can avoid using background script for that. All other scripts (popup / content scripts) are not being executed when extension is installed, they are awaiting user interaction (clicking on a extension icon / opening new tab). – Konrad Dzwinel Jan 25 '12 at 14:54
  • You are correct. There is a way to do this via LocalStorage but it doesn't work very well. For now I'll just have to run the process in the background. – TheRealJAG Jan 31 '12 at 18:54