How to enable a pageAction icon for a chrome extension in incognito mode?



Even after selecting the ‘Allow in incognite mode’ my extension which uses pageaction to render in certain urls doesn’t show up in incognito mode. background.js has the following.

chrome.runtime.onInstalled.addListener(function() {
  // Replace all rules ...
  chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
    // With a new rule ...
        // That fires when a page's URL contains a 'g' ...
        conditions: [
          new chrome.declarativeContent.PageStateMatcher({
            pageUrl: { urlContains: 'sears' },
        // And shows the extension's page action.
        actions: [ new chrome.declarativeContent.ShowPageAction() ]





Looks like a bug, so I’ve reported it here:

As a work-around, you could enable split incognito mode by adding the following to the manifest file:

"incognito": "split"

Unfortunately, chrome.runtime.onInstalled is not fired for extensions in incognito mode, so you should avoid using this event when the extension is running in incognito mode, as follows:

if (chrome.extension.inIncognitoContext) {
} else {
function doReplaceRules() {
  chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
    // ... add rules


Facebook Comments

Post a comment