Skip to content

Allow specifying HTTP status code and modifying an HTTP header for XHR and fetch API #3828

@piquark6046

Description

@piquark6046

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is NOT a YouTube, Facebook or Twitch report. These sites MUST be reported by clicking their respective links.
  • This is not a support issue or a question. For support, questions, or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

Description

We need to expand syntax of prevent-xhr, prevent-fetch, trusted-prevent-fetch and trusted-prevent-xhr scriptlet by allowing specifying HTTP status code and modifying an HTTP header for XHR and fetch API.

For example, by executing the following code without adblocking, you can receive 0 as its HTTP status code:

(await fetch('https://www3.doubleclick.net', { method: 'HEAD', mode: 'no-cors', cache: 'no-store' })).status

However, the following none of scriptlet filters work:

example.com##+js(no-fetch-if, doubleclick.net, , '{"statusText": ""}')
example.com##+js(no-fetch-if, doubleclick.net, , '{"type": "opaque"}')
example.com##+js(no-fetch-if, doubleclick.net)

because uBO returns 200.

Also, removing, modifying and adding an HTTP response header & its value is required.

A specific URL where the issue occurs.

https://srank.kr/

Steps to Reproduce

  1. Apply each the provided scriptlet filter
  2. Visit https://example.com/
  3. Execute the provided code.

Expected behavior

Return 0.

Actual behavior

Return 200.

uBO version

1.66.4

Browser name and version

Firefox Dev 144.0b9 flatpak

Operating System and version

Ubuntu 25.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions