Home / File/ dynamicallyInjectContentScripts.js — react Source File

dynamicallyInjectContentScripts.js — react Source File

Architecture documentation for dynamicallyInjectContentScripts.js, a javascript file in the react codebase. 0 imports, 1 dependents.

File javascript BabelCompiler Validation 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  fe7f3f36_186a_b5fa_46a3_1c8b67d7534d["dynamicallyInjectContentScripts.js"]
  406e0fbd_f3e8_fc3b_d05b_4922f1996e21["index.js"]
  406e0fbd_f3e8_fc3b_d05b_4922f1996e21 --> fe7f3f36_186a_b5fa_46a3_1c8b67d7534d
  style fe7f3f36_186a_b5fa_46a3_1c8b67d7534d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/* global chrome */

const contentScriptsToInject = [
  {
    id: '@react-devtools/proxy',
    js: ['build/proxy.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
    world: chrome.scripting.ExecutionWorld.ISOLATED,
  },
  {
    id: '@react-devtools/file-fetcher',
    js: ['build/fileFetcher.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_end',
    world: chrome.scripting.ExecutionWorld.ISOLATED,
  },
  {
    id: '@react-devtools/fallback-eval-context',
    js: ['build/fallbackEvalContext.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
    world: chrome.scripting.ExecutionWorld.MAIN,
  },
  {
    id: '@react-devtools/hook',
    js: ['build/installHook.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
    world: chrome.scripting.ExecutionWorld.MAIN,
  },
  {
    id: '@react-devtools/hook-settings-injector',
    js: ['build/hookSettingsInjector.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
  },
];

async function dynamicallyInjectContentScripts() {
  try {
    // Using this, instead of filtering registered scrips with `chrome.scripting.getRegisteredScripts`
    // because of https://bugs.chromium.org/p/chromium/issues/detail?id=1393762
    // This fixes registering proxy content script in incognito mode
    await chrome.scripting.unregisterContentScripts();

    // Note: the "world" option in registerContentScripts is only available in Chrome v102+
    // It's critical since it allows us to directly run scripts on the "main" world on the page
    // "document_start" allows it to run before the page's scripts
    // so the hook can be detected by react reconciler
    await chrome.scripting.registerContentScripts(contentScriptsToInject);
  } catch (error) {
    console.error(error);
  }
}

dynamicallyInjectContentScripts();

Domain

Subdomains

Frequently Asked Questions

What does dynamicallyInjectContentScripts.js do?
dynamicallyInjectContentScripts.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in dynamicallyInjectContentScripts.js?
dynamicallyInjectContentScripts.js defines 1 function(s): dynamicallyInjectContentScripts.
What files import dynamicallyInjectContentScripts.js?
dynamicallyInjectContentScripts.js is imported by 1 file(s): index.js.
Where is dynamicallyInjectContentScripts.js in the architecture?
dynamicallyInjectContentScripts.js is located at packages/react-devtools-extensions/src/background/dynamicallyInjectContentScripts.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-extensions/src/background).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free