Skip to content

Commit

Permalink
disable sendBeacon() altogether, just return true
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Jul 4, 2024
1 parent 5fb1f6b commit 6c893df
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 @@ -6027,25 +6027,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 @@ -6907,9 +6894,6 @@ Wombat.prototype.wombatInit = function() {
this.initRegisterUnRegPHOverride();
this.initPresentationRequestOverride();

// sendBeacon override
this.initBeaconOverride();

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

Expand Down

0 comments on commit 6c893df

Please sign in to comment.