Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6946391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:33:33+00:00 2026-05-27T13:33:33+00:00

Is there a Chrome extension post install hook/API function that will let me perform

  • 0

Is there a Chrome extension post install hook/API function that will let me perform an action after the plugin is installed or updated?

I would like to perform an action after my extension is installed, and only right after it is installed. This action should only be performed once (post-install or post-update) of the extension.

Update

Some people have proposed setting the version of the extension in localStorage, the problem that I have is that the content script that has access to localStorage is not loaded into the page when the plugin is first installed.

AFAIK after a plugin is installed, and it makes use of a content script injected into the tab/page, the page has to be reloaded.

I don’t know how to access localStorage from the background page; localStorage can only be accessed from a content script.

To get the version number from the background page to the content script requires the use of chrome API function to execute scripts:

chrome.tabs.executeScript(null, {code:function_to_execute}, function() { // callback });

However, when you install a plugin, and the page that this plugin needs to inject a content script into is already loaded, it does not inject the content script, you have to reload the page.

update 2

Looking at some of the tips provided in more detail, for the purpose of saving the version number, it is possible to access the localStorage of the background page. However, for what I need to do, which is reload a specific tab at a specific URL (in order to make sure the content script is the newest version) after installing or updating a plugin, it ended up being unnecessary to bother with localStorage.

For the sake of staying on topic, the advice given about writing the version number to localStorage (in the background page) and then checking against the version number in the manifest file is good enough to allow someone to run a script the first time it is installed/or updated.

HowTo

Make manifest file available to the background page (note: this is taken from somewhere else, I don’t take credit for it, but I can’t remember the source, if you know, let me know and I will add it).

// MAKE MANIFEST FILE AVAILABLE
chrome.manifest = (function() {
    var manifestObject = false;
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4) {
            manifestObject = JSON.parse(xhr.responseText);
        }
    };
    xhr.open("GET", chrome.extension.getURL('/manifest.json'), false);
    try {
        xhr.send();
    } catch(e) {
        console.log('Couldn\'t load manifest.json');
    }
    return manifestObject;
})();

Now you can access your version number like this: chrome.manifest.version

To write to localStorage just pass it in like so: localStorage['my_plugin_version'] = chrome.manifest.version

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:33:34+00:00Added an answer on May 27, 2026 at 1:33 pm

    You can do this using a background page. When the extension is installed, the background page is opened in the background, and thus executed. To make sure it’s not executed every time, simply store a value in localStorage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an google-chrome-extension which has html notifications. There will be a close
I'm developing a Chrome extension and I'm wondering is there a way that I
Hello Chrome Extension geeks, Is there any way that we can read a the
I'm building a small Chrome extension that must send messages through a POST http
Is there a way to control the order that my Chrome extension's context menu
I have a Chrome extension with a browser action that is trying to imitate
So I've created a plugin for windows working in IE Chrome etc (there is
There are several resources out there that explain how the sandbox in Chrome works
i am beginner with chrome extension.There is simple problem. There is the code in
Is there a way to obtain/read cache files using a chrome extension without NPAPI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.