Skip to content

Commit

Permalink
disable sendBeacon() altogether, just return true (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer authored Jul 4, 2024
1 parent b9682d7 commit 922b00b
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/wombat.js
Original file line number Diff line number Diff line change
Expand Up @@ -6028,25 +6028,12 @@ Wombat.prototype.initRegisterUnRegPHOverride = function() {
}
};

/**
* Applies an override to navigator.sendBeacon in order to ensure that
* the URL argument is rewritten. This ensures that when a page is rewritten
* no information about who is viewing is leaked to the outside world
*/
Wombat.prototype.initBeaconOverride = function() {
if (!this.$wbwindow.navigator.sendBeacon) return;
var orig_sendBeacon = this.$wbwindow.navigator.sendBeacon;
var wombat = this;
this.$wbwindow.navigator.sendBeacon = function sendBeacon(url, data) {
try {
return orig_sendBeacon.call(this, wombat.rewriteUrl(url), data);
} catch(e) {
return true;
}
};
};

Wombat.prototype.initMiscNavigatorOverrides = function() {
if (this.$wbwindow.navigator.sendBeacon) {
this.$wbwindow.navigator.sendBeacon = function() { return true; };
}

if (this.$wbwindow.navigator.mediaDevices) {
this.$wbwindow.navigator.mediaDevices.setCaptureHandleConfig = function() {};
}
Expand Down Expand Up @@ -6908,9 +6895,6 @@ Wombat.prototype.wombatInit = function() {
this.initRegisterUnRegPHOverride();
this.initPresentationRequestOverride();

// sendBeacon override
this.initBeaconOverride();

// additional navigator. overrides
this.initMiscNavigatorOverrides();

Expand Down

0 comments on commit 922b00b

Please sign in to comment.