Skip to content

chrome.extension not exported to content script #175

Open

Description

@powellnorma

This causes e.g. the "Reddit Enhancement Suite" to not work (can't access chrome.extension.inIncognitoContext):

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'inIncognitoContext')
    at isPrivateBrowsing (foreground.entry.js:15198:29)
    at module35.shouldRun (foreground.entry.js:40259:31)
    at isRunning (foreground.entry.js:47228:177)
    at _addModuleBodyClasses (foreground.entry.js:47321:12)
    at foreground.entry.js:47350:53

To Reproduce
Steps to reproduce the behavior:

  1. Install https://chromewebstore.google.com/detail/reddit-enhancement-suite/kbmfpngjjgdllneeigpgjifpgocmfgmb
  2. Go to https://old.reddit.com
  3. Open dev-tools

Extra

Probably relevant:

// Only load within extension page context
if (process.type === 'service-worker' || location.href.startsWith('chrome-extension://')) {
injectExtensionAPIs()
}

Activity

  1. changed the title [-]MV2 - chrome.extension not exported to content script[/-] [+]chrome.extension not exported to content script[/+] on Feb 22, 2026
  2. powellnorma commented on Feb 22, 2026

    @powellnorma
    ContributorAuthor

    I found a workaround: Automatically adjust the "content_scripts.js" in the extension's manifest to include a chrome.extension polyfill, see #176

    Maybe there is a better way though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions