Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 1.36 KB

File metadata and controls

32 lines (24 loc) · 1.36 KB

Background Script Standards for MileIQ_CreateUser Chrome Extension

Manifest V3 Compatibility

  • All background scripts must be written as service workers, as required by Manifest V3.
  • Do not use DOM APIs (e.g., window, document) in background scripts.

Deprecated/Incompatible APIs

  • Do not use chrome.webRequest or chrome.webRequestBlocking in background scripts, as these are restricted in Manifest V3 and do not allow access to request/response bodies.
  • Use chrome.declarativeNetRequest for request blocking or redirection, if needed.

Minimal Example

A minimal, compatible background script should look like this:

chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
  // Example: handle messages from content or popup scripts
  if (request.greeting === "hello") {
    sendResponse({ reply: "hi from background!" });
  }
});

Capturing POST Data

  • If you need to capture POST data or request/response bodies, use a content script to intercept form submissions or XHR/fetch requests, then communicate with the background script via chrome.runtime.sendMessage.

Troubleshooting

  • If you see Service worker registration failed. Status code: 15, check for incompatible code or APIs in your background script.
  • Ensure all permissions in manifest.json are appropriate for Manifest V3.

Last updated: 2024-06-10