Skip to content

Conversation

@adervark
Copy link

@adervark adervark commented Jan 9, 2026

Problem

Fixes #30 - The Manifest V3 service worker becomes inactive after idle time, causing submissions to fail unless DevTools is open.

Solution

  • Added a content script that runs on all Codeforces pages and maintains a chrome.runtime.connect() keep-alive port connection
  • Added port connection handling in the background script to track connected ports
  • Added tab load waiting before sending submit messages to prevent race conditions

Changes

File Change
src/contentScript.ts NEW - Keep-alive port on CF pages
src/backgroundScript.ts Added port connection handling
src/handleSubmit.ts Wait for tab load before sending message
webpack.config.js Added contentScript entry point
manifest-chrome.partial.json Added content_scripts section
manifest-firefox.partial.json Added content_scripts section

How it works

  1. Content script runs on Codeforces pages at document_start
  2. Establishes keep-alive port with chrome.runtime.connect()
  3. Port connection keeps service worker active in MV3
  4. Message sending now waits for tab to fully load

Testing

  • ✅ Service worker stays active while Codeforces tabs are open
  • ✅ Submissions work without DevTools open

@adervark
Copy link
Author

@agrawal-d could you please take a look at this

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Service Worker Becomes Inactive, Breaking CPH Submissions Unless DevTools Is Open

1 participant