0

Every new update downloaded, my extension open option page in customers computer. Option page include version log and more.

My algorithm is

  1. Get current version and compare with saved variable in background.js
  2. If (currentVersion!=savedVersion){ openOptionPage();savedVersion=currentVersion;}

How to get currentVersion?

is there any available event or property of first time run checker?

ebattulga
  • 10,774
  • 20
  • 78
  • 116
  • 1
    If your question is "How to get the current version of the extension", then see http://stackoverflow.com/questions/6436039/how-to-reference-the-version-information-in-a-google-chrome-extension – Rob W Sep 30 '12 at 12:37
  • 1
    Just write your checking version logic in `background_page.js` directly (not in any event). That code will run first time installed/updated I believe. – Jacob Dam Oct 01 '12 at 04:19

1 Answers1

0

Here's what I do using lscache to store the extension's version in localStorage:

function openOptionsPage() {
    var options_url = chrome.extension.getURL('options.html');
    chrome.tabs.query({
        url: options_url,
    }, function(tabs) {
        if (tabs.length)
            chrome.tabs.update(tabs[0].id, {active:true});
        else
            chrome.tabs.create({url:options_url});
    });
}   
var savedVersion = lscache.get('version');
var currentVersion = chrome.app.getDetails().version;
if (currentVersion !== savedVersion) {
    lscache.set('version', currentVersion);
    openOptionsPage();
}

This only works from the extension's background.js page.

Alan Hamlett
  • 3,160
  • 1
  • 23
  • 23