jbrowser.services.privacy
Generated from the source code of JBrowser 1.4.0.
Privacy sandbox: third-party tracker blocking, GPC / DNT, HTTPS upgrades, dev host routing.
Constants#
| Name | Value |
|---|---|
RT |
QWebEngineUrlRequestInfo.ResourceType |
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.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.
PrivacyService.allow_cookie#
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, 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)
Per-card interceptor so blocked requests can be attributed and counted per card.
PageInterceptor.interceptRequest#
interceptRequest(info: QWebEngineUrlRequestInfo) -> Nonesource
Functions#
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.