AxisStarstreamer
AxisStarstreamer

Reputation: 68

Chrome extension for incognito tab

I am developing an extension that interacts with a website of ours. The interaction is created by sending messages along and handling those.

Sometimes I want to open our website in incognito mode and there, the extension is not working. It looks to me that the listeners on chrome.runtime.onMessage are not triggered.

in my contentScript.js I have something like

window.addEventListener(
  'message',
  (event, r) => {
    //check for sender and type otherwise return;
    chrome.runtime.sendMessage(data);
  }
);

The extension creates a devtools_page, which loads a .html. On that page I have

chrome.runtime.onMessage.addListener(messageHandler)

the messageHandler is never triggered. I can even check if the listener is there with chrome.runtime.onMessage.hasListener(messageHandler), which returns true.

Even when I put the listener in the background.js (set in the manifest.json), this listener is never triggered.

I tried to put "incognito": "split" into the manifest.json but then the browser crashed completely when I open the page in incognito tab. For permissions, I have ["cookies", "tabs"].

Update: I enabled the extension in incognito mode on the extensions settings page

Update: As I said, when setting "incognito": "split", the browser crashes. I narrowed it down to my contentScript.js which is loaded by the manifest "content_scripts". I removed everything. Loading the page, the browser does not crash. But as soon as I run window.addEventListener, the browser crashes when I open the site on an incognito tab

Update: in the windowAddEventListener I do a chrome.runtime.sendMessage(data). I do this to make the website able to send necessary information to the extension to show the data. When removing chrome.runtime.sendMassage, the browser does not crash in incognito mode with "incognito":"split"

Upvotes: 1

Views: 1567

Answers (1)

Jan Kees
Jan Kees

Reputation: 195

Chrome blocks extensions in Incognito mode,

So to test it you can allow certain extensions to work on incognito mode,

  1. Click the menu button in Chrome.

  2. Navigate to More Tools > Extensions.

  3. In the new tab that opens, scroll through the list to find the extension you want to enable while incognito.

  4. Click the “Allow in Incognito” button.

Upvotes: 1

Related Questions