Skip to content

Exclude internal browser protocols from webRequest interception#65

Merged
ormidales merged 2 commits into1.0.3from
copilot/exclude-internal-protocols-interception
Feb 28, 2026
Merged

Exclude internal browser protocols from webRequest interception#65
ormidales merged 2 commits into1.0.3from
copilot/exclude-internal-protocols-interception

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 28, 2026

The background script's webRequest listeners were firing on internal browser URLs (about:blank, moz-extension://, etc.), which have no standard hostname — causing silent try/catch failures and unnecessary CPU usage.

Changes

  • onBeforeRequest, onBeforeSendHeaders, onHeadersReceived: Added an early-exit guard immediately after the main_frame type check to skip any URL that isn't http:// or https://
if (!details.url.startsWith("http://") && !details.url.startsWith("https://")) {
  return; // or return {}
}

Uses explicit scheme prefixes (http:///https://) rather than the looser startsWith("http") to avoid unintended matches.

Original prompt

This section details on the original issue you should resolve

<issue_title>Exclusion des protocoles internes de l'interception des requêtes</issue_title>
<issue_description>## Contexte
Le script d'arrière-plan écoute l'ensemble des requêtes du navigateur via les filtres <all_urls> et types: ["main_frame"] pour ajuster les headers et suivre les redirections.

Problème

L'extension tente d'intercepter et de modifier les requêtes naviguant vers des pages internes du navigateur (comme about:blank, about:config, ou les URL moz-extension://). Cela engendre des erreurs silencieuses dans le bloc try/catch de onBeforeSendHeaders car les URL internes n'ont pas de nom d'hôte classique.

Scénario de Reproduction

  1. Ouvrir un nouvel onglet vide (about:blank).
  2. Inspecter les performances et la console d'arrière-plan de l'extension.
  3. L'API déclenche les listeners pour ces pages, consommant inutilement des cycles CPU et provoquant des rejets de format d'URL.

Comportement Attendu

L'extension doit ignorer immédiatement toute requête dont le protocole n'est pas http: ou https:.

Pistes Techniques

  • Fichier concerné : background.js.
  • Ajouter une vérification précoce details.url.startsWith("http") dans onBeforeRequest, onBeforeSendHeaders et onHeadersReceived.

Environnement

Toutes les plateformes.</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…round.js

Co-authored-by: ormidales <46538211+ormidales@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix internal protocol interception errors in background script Exclude internal browser protocols from webRequest interception Feb 28, 2026
@ormidales ormidales added this to the v1.0.3 milestone Feb 28, 2026
@ormidales ormidales linked an issue Feb 28, 2026 that may be closed by this pull request
@ormidales ormidales marked this pull request as ready for review February 28, 2026 21:10
Copilot AI review requested due to automatic review settings February 28, 2026 21:10
@ormidales ormidales merged commit a076fad into 1.0.3 Feb 28, 2026
@ormidales ormidales deleted the copilot/exclude-internal-protocols-interception branch February 28, 2026 21:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents the extension’s background.js webRequest handlers from processing internal/non-web URLs by adding an early-exit guard for non-http:// / non-https:// schemes, avoiding unnecessary work and URL/hostname edge cases.

Changes:

  • Add a scheme guard in onBeforeRequest to skip non-HTTP(S) main-frame URLs before attempting hostname tracking.
  • Add the same guard in onBeforeSendHeaders to avoid header mutation work for non-HTTP(S) URLs.
  • Add the same guard in onHeadersReceived to skip redirect processing for non-HTTP(S) URLs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Exclusion des protocoles internes de l'interception des requêtes

3 participants