Skip to content

Commit 4e639f2

Browse files
committed
add new option to disable 'nextHopProtocol' (set to '') detection which can break replay
some sites use performance events, eg: window.performance.getEntriesByType("navigation")[0].nextHopProtocol to perform different network requests. This fixes the value to '' instead of changing based on HTTP protocol. fixes #324
1 parent 507d250 commit 4e639f2

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/recorder.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ const IFRAME_INJECT_URL = "__awp_iframe_inject__";
3333

3434
const BEHAVIOR_LOG_FUNC = "__bx_log";
3535

36+
const DISABLE_PERF_NHP = `;
37+
if (self.PerformanceResourceTiming) {
38+
Object.defineProperty(self.PerformanceResourceTiming.prototype, "nextHopProtocol", {value: ""});
39+
}
40+
`;
41+
3642
// ===========================================================================
3743
// @ts-expect-error - TS7006 - Parameter 'time' implicitly has an 'any' type.
3844
function sleep(time) {
@@ -62,6 +68,7 @@ class Recorder {
6268
archiveScreenshots = false;
6369
archivePDF = false;
6470
disableMSE = false;
71+
disablePerf = false;
6572

6673
_fetchQueue: FetchEntry[] = [];
6774

@@ -166,6 +173,7 @@ class Recorder {
166173
(await getLocalOption("archiveScreenshots")) === "1";
167174
this.archivePDF = (await getLocalOption("archivePDF")) === "1";
168175
this.disableMSE = (await getLocalOption("disableMSE")) === "1";
176+
this.disablePerf = (await getLocalOption("disablePerf")) === "1";
169177
}
170178

171179
// @ts-expect-error - TS7006 - Parameter 'autorun' implicitly has an 'any' type.
@@ -201,7 +209,8 @@ class Recorder {
201209
202210
window.addEventListener("beforeunload", () => {});\n` +
203211
(this.archiveFlash ? this.getFlashInjectScript() : "") +
204-
(this.disableMSE ? DISABLE_MEDIASOURCE_SCRIPT : "")
212+
(this.disableMSE ? DISABLE_MEDIASOURCE_SCRIPT : "") +
213+
(this.disablePerf ? DISABLE_PERF_NHP : "")
205214
);
206215
}
207216

src/ui/app.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class ArchiveWebApp extends ReplayWebApp {
6262
archiveScreenshots: boolean | null = null;
6363
archivePDF: boolean | null = null;
6464
disableMSE: boolean | null = null;
65+
disablePerf: boolean | null = null;
6566

6667
showIpfsShareFailed = false;
6768

@@ -132,6 +133,8 @@ class ArchiveWebApp extends ReplayWebApp {
132133

133134
this.disableMSE = (await getLocalOption("disableMSE")) === "1";
134135

136+
this.disablePerf = (await getLocalOption("disablePerf")) === "1";
137+
135138
const archiveScreenshots = await getLocalOption("archiveScreenshots");
136139

137140
// default to true if unset to enable screenshots!
@@ -1101,6 +1104,21 @@ class ArchiveWebApp extends ReplayWebApp {
11011104
websites, but may result in better video/audio capture.
11021105
</p>
11031106
</div>
1107+
<div class="field is-size-6 mt-4">
1108+
<input
1109+
name="prefDisablePerf"
1110+
id="disablePerf"
1111+
class="checkbox"
1112+
type="checkbox"
1113+
?checked="${this.disablePerf}"
1114+
@change=${this.onUpdatePrefsOption}
1115+
/><span class="ml-1">Disable Performance Detection</span>
1116+
<p class="is-size-7 mt-1">
1117+
If set, will disable performance detection features (such as
1118+
current HTTP version), which can fix some replay issues,
1119+
result in more accurate replay.
1120+
</p>
1121+
</div>
11041122
<hr />
11051123
<div class="is-size-6">Privacy related settings:</div>
11061124
<div class="field is-size-6 mt-4">

0 commit comments

Comments
 (0)