JBrowser Source Docs

jbrowser.services.privacy

Generated from the source code of JBrowser 1.5.4.

jbrowser/services/privacy.py · 499 lines

Privacy sandbox: third-party tracker blocking, GPC / DNT, HTTPS upgrades, dev host routing.

Constants#

Name Value
RT QWebEngineUrlRequestInfo.ResourceType
CHALLENGE_SITES ('google.com', 'gstatic.com', 'recaptcha.net', 'youtube.com', 'hcaptcha.com', 'cloudfla…
CAPTCHA_COOKIE_SITES ('recaptcha.net', 'hcaptcha.com', 'challenges.cloudflare.com', 'arkoselabs.com')
SIGNIN_UA_HOSTS ('accounts.google.com',)
SIGNIN_PAGE_HOSTS ('accounts.google.com', 'accounts.youtube.com', 'login.microsoftonline.com', 'login.liv…
BLOCKLIST_SOURCES [('EasyPrivacy (trackers & telemetry)', 'https://easylist.to/easylist/easyprivacy.txt')…
TRACKING_PARAMS {'fbclid', 'gclid', 'gclsrc', 'dclid', 'gbraid', 'wbraid', 'msclkid', 'yclid', 'twclid'…
TRACKING_PREFIXES ('utm_', 'pk_', 'mtm_', 'piwik_', 'hmb_', 'ga_')
SITE_TRACKING_PARAMS {'youtube.com': {'si', 'pp', 'feature'}, 'youtu.be': {'si', 'feature'}, 'spotify.com': …

Blocklist#

class Blocklistsource
Blocklist(extra_file: Path)

Blocklist.load_extra#

load_extra() -> Nonesource

Blocklist.match#

match(host: str, path: str='/') -> boolsource

PrivacyService#

class PrivacyService(QObject)source
PrivacyService(settings: Settings, blocklist_file: Path, parent: QObject | None=None)

Holds privacy policy and answers per-request decisions for the interceptors.

Signals

Signal Arguments
blocklistUpdated (int, str)

PrivacyService.dev_hosts#

dev_hosts() -> set[str]source

PrivacyService.dev_target#

dev_target(host: str) -> tuple[str, int] | Nonesource

PrivacyService.is_allowlisted#

is_allowlisted(host: str) -> boolsource

PrivacyService.set_site_protection#

set_site_protection(host: str, enabled: bool) -> Nonesource

PrivacyService.should_block#

should_block(info: QWebEngineUrlRequestInfo) -> boolsource

PrivacyService.cosmetic_script#

cosmetic_script() -> strsource

Profile script that hides ad boxes and "Advertisement" frames, or "" when tracker blocking is off or no lists have been downloaded yet (see engine/js.py cosmetic_js).

PrivacyService.is_challenge_site#

static is_challenge_site(host: str) -> boolsource

PrivacyService.rewrite#

rewrite(info: QWebEngineUrlRequestInfo) -> QUrl | Nonesource

Dev-host routing and HTTPS upgrades. Returns a redirect target or None.

PrivacyService.was_upgraded#

was_upgraded(url: QUrl, window: float=30.0) -> boolsource

True when url is an https address JBrowser upgraded from http a moment ago.

PrivacyService.upgrade_fallback#

upgrade_fallback(url: QUrl) -> QUrl | Nonesource

HTTPS-First fallback: the upgraded address failed, so return the original http one.

allow_cookie(request) -> boolsource

PrivacyService.maybe_update_blocklist#

maybe_update_blocklist() -> Nonesource

Weekly background refresh (skipped when the user chose the built-in list only).

PrivacyService.update_blocklist#

update_blocklist(proxies: dict | None=None, manual: bool=True) -> boolsource

PrivacyService.reset_blocklist#

reset_blocklist() -> Nonesource

BlocklistUpdater#

class BlocklistUpdater(QThread)source
BlocklistUpdater(urls: list[str], out_file: Path, filters_file: Path, proxies: dict, parent: QObject | None=None)

Signals

Signal Arguments
done (int, str)

BlocklistUpdater.run#

run() -> Nonesource

ProfileInterceptor#

class ProfileInterceptor(QWebEngineUrlRequestInterceptor)source
ProfileInterceptor(privacy: PrivacyService, parent: QObject | None=None)

Runs for every request of a profile: privacy headers, HTTPS upgrade, dev host routing.

ProfileInterceptor.interceptRequest#

interceptRequest(info: QWebEngineUrlRequestInfo) -> Nonesource

PageInterceptor#

class PageInterceptor(QWebEngineUrlRequestInterceptor)source
PageInterceptor(privacy: PrivacyService, on_blocked: Callable[[str], None], parent: QObject | None=None, on_websocket: Callable[[], None] | None=None)

Per-card interceptor so blocked requests can be attributed and counted per card.

PageInterceptor.interceptRequest#

interceptRequest(info: QWebEngineUrlRequestInfo) -> Nonesource

Functions#

firefox_user_agent#

firefox_user_agent(today: date | None=None) -> strsource

A current Firefox user agent for Windows. Firefox 140 came out on 2025-06-24 and a new version follows about every four weeks; counting 30 days per version never runs ahead.

strip_tracking#

strip_tracking(url: QUrl) -> tuple[QUrl, int]source

Return url without known tracking query parameters, and how many were removed.

parse_filter_list#

parse_filter_list(text: str) -> set[str]source

Extract whole-domain block rules from hosts files and Adblock Plus lists.