Skip to content

Commit c7cb09f

Browse files
committed
reload wait status: add message indicating that recording will start after reload, prevent double-starting recording by disabling start button after first press
ruffle/flash: add manual navigator.plugins overrides before ruffle runs to avoid pages not detecting flash update to latest ruffle (03-25-2021 nightly) autofetch: prevent injecting multiple times, wrap in iife bump to 0.5.12
1 parent 7e27839 commit c7cb09f

File tree

12 files changed

+148
-106
lines changed

12 files changed

+148
-106
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "ArchiveWeb.page",
3-
"version": "0.5.11",
3+
"version": "0.5.12",
44
"main": "index.js",
55
"description": "Create Web Archives directly in your browser",
66
"repository": "https://github.com/webrecorder/archiveweb.page",
77
"author": "Webrecorder Software",
88
"license": "AGPL-3.0-or-later",
99
"dependencies": {
1010
"@fortawesome/fontawesome-free": "^5.13.0",
11-
"@webrecorder/wabac": "^2.6.4",
11+
"@webrecorder/wabac": "^2.6.7",
1212
"bulma": "^0.9.1",
1313
"flexsearch": "^0.6.32",
1414
"hash-wasm": "^4.4.1",
@@ -20,13 +20,13 @@
2020
"lodash": "^4.17.20",
2121
"node-fetch": "^2.6.1",
2222
"pretty-bytes": "^5.3.0",
23-
"replaywebpage": "^1.3.10",
23+
"replaywebpage": "^1.3.12",
2424
"warcio": "^1.4.1"
2525
},
2626
"devDependencies": {
2727
"copy-webpack-plugin": "^6.4.0",
2828
"css-loader": "^3.5.3",
29-
"electron": "^12.0.1",
29+
"electron": "12.0.2",
3030
"electron-builder": "^22.9.1",
3131
"electron-notarize": "^1.0.0",
3232
"generate-json-webpack-plugin": "1.0.0",

src/autofetcher.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
(() => {
22
const SRC_SET_SELECTOR = 'img[srcset], img[data-srcset], img[data-src], ' +
33
'video[srcset], video[data-srcset], video[data-src], audio[srcset], audio[data-srcset], audio[data-src], ' +
44
'picture > source[srcset], picture > source[data-srcset], picture > source[data-src], ' +
@@ -195,4 +195,9 @@ class AutoFetcher
195195
}
196196
}
197197

198-
new AutoFetcher().init();
198+
if (!self.__awp_autofetch__) {
199+
new AutoFetcher().init();
200+
self.__awp_autofetch__ = true;
201+
}
202+
203+
})();

src/popup.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class RecPopup extends LitElement
4545
this.collDrop = "";
4646

4747
this.allowCreate = true;
48+
49+
this.waitingForStart = false;
4850
}
4951

5052
static get properties() {
@@ -56,6 +58,7 @@ class RecPopup extends LitElement
5658

5759
recording: { type: Boolean },
5860
status: { type: Object },
61+
waitingForStart: { type: Boolean },
5962

6063
replayUrl: { type: String },
6164
pageUrl: { type: String },
@@ -104,6 +107,7 @@ class RecPopup extends LitElement
104107
switch (message.type) {
105108
case "status":
106109
this.recording = message.recording;
110+
this.waitingForStart = !message.firstPageStarted;
107111
this.status = message;
108112
if (message.pageUrl) {
109113
this.pageUrl = message.pageUrl;
@@ -321,6 +325,10 @@ class RecPopup extends LitElement
321325
return html`<i>Can't record this page.</i>`;
322326
}
323327

328+
if (this.waitingForStart) {
329+
return html`<i>Recording will start after the page reloads...</i>`;
330+
}
331+
324332
return html`<i>${this.notRecordingMessage}</i>`;
325333
}
326334

@@ -399,7 +407,7 @@ class RecPopup extends LitElement
399407
${this.canRecord ? html`
400408
${this.renderDropdown()}
401409
<button
402-
?disabled=${this.collDrop === "create"}
410+
?disabled=${this.collDrop === "create" || (!this.recording && this.waitingForStart)}
403411
@click="${!this.recording ? this.onStart : this.onStop}" class="button">
404412
<span class="icon">
405413
${!this.recording ? html`
@@ -436,10 +444,12 @@ class RecPopup extends LitElement
436444

437445
onStart() {
438446
this.sendMessage({type: "startRecording", collId: this.collId, url: this.pageUrl});
447+
this.waitingForStart = true;
439448
}
440449

441450
onStop() {
442451
this.sendMessage({type: "stopRecording"});
452+
this.waitingForStart = false;
443453
}
444454

445455
onSelectColl(event) {

src/recorder.js

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Recorder {
3030
this.running = false;
3131

3232
this.frameId = null;
33-
this.pageCount = 0;
3433
this.pageInfo = {size: 0};
34+
this.firstPageStarted = false;
3535

3636
this.sizeNew = 0;
3737
this.sizeTotal = 0;
@@ -70,10 +70,26 @@ class Recorder {
7070
}
7171

7272
getInjectScript() {
73-
return autofetcher + `
74-
${this.addExternalInject("ruffle/ruffle.js")}
75-
window.addEventListener("beforeunload", () => {});
76-
`;
73+
return autofetcher + `;window.addEventListener("beforeunload", () => {});` + this.getFlashInjectScript();
74+
}
75+
76+
getFlashInjectScript() {
77+
return `
78+
(() => {
79+
const description = "Shockwave Flash 32.0 r0";
80+
const enabledPlugin = { description };
81+
navigator.plugins["Shockwave Flash"] = { description };
82+
function addPlugin(type, suffixes) {
83+
const mime = { enabledPlugin, description: "", type, suffixes};
84+
navigator.mimeTypes[type] = mime;
85+
navigator.mimeTypes[navigator.mimeTypes.length] = mime;
86+
}
87+
addPlugin("application/futuresplash", "sp1");
88+
addPlugin("application/x-shockwave-flash2-preview", "swf");
89+
addPlugin("application/x-shockwave-flash", "swf");
90+
addPlugin("application/vnd.adobe.flash-movie", "swf");
91+
})();
92+
` + this.addExternalInject("ruffle/ruffle.js");
7793
}
7894

7995
async detach() {
@@ -150,6 +166,7 @@ window.addEventListener("beforeunload", () => {});
150166
getStatusMsg() {
151167
return {
152168
recording: this.running,
169+
firstPageStarted: this.firstPageStarted,
153170
sizeTotal: this.sizeTotal,
154171
sizeNew: this.sizeNew,
155172
numUrls: this.numUrls,
@@ -196,11 +213,14 @@ window.addEventListener("beforeunload", () => {});
196213
}
197214

198215
async start() {
216+
this.firstPageStarted = false;
217+
199218
await this.send("Page.enable");
200219

201220
await this._doInjectTopFrame();
202221

203222
await this.sessionInit([]);
223+
204224
this.failureMsg = null;
205225
}
206226

@@ -533,9 +553,21 @@ window.addEventListener("beforeunload", () => {});
533553
this.fullCommit(reqresp, sessions);
534554
}
535555

556+
if (!this.firstPageStarted) {
557+
this.initFirstPage();
558+
}
559+
536560
return true;
537561
}
538562

563+
async initFirstPage() {
564+
// Enable unload pause only on first full page that is being recorded
565+
await this.send("Debugger.enable");
566+
await this.send("DOMDebugger.setEventListenerBreakpoint", {'eventName': 'beforeunload'});
567+
this.updateStatus();
568+
this.firstPageStarted = true;
569+
}
570+
539571
_initNewPage(url, mime) {
540572
this.pageInfo = {
541573
id: this.newPageId(),
@@ -594,13 +626,7 @@ window.addEventListener("beforeunload", () => {});
594626

595627
await this.commitPage(this.pageInfo, results[0], false);
596628

597-
// Enable unload pause only on first full page that is being recorded
598-
if (!this.pageCount++) {
599-
await this.send("Debugger.enable");
600-
await this.send("DOMDebugger.setEventListenerBreakpoint", {'eventName': 'beforeunload'});
601-
}
602-
603-
await this.updateStatus();
629+
this.updateStatus();
604630
}
605631

606632
async updateHistory(sessions) {

wr-ext/bg.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wr-ext/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Webrecorder ArchiveWeb.page",
33
"description": "Create high-fidelity web archives directly in your browser",
4-
"version": "0.5.11",
4+
"version": "0.5.12",
55
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
66
"permissions": [
77
"debugger",

wr-ext/popup.js

Lines changed: 38 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wr-ext/replay/sw.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wr-ext/replay/ui.js

Lines changed: 27 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-4.57 MB
Binary file not shown.

0 commit comments

Comments
 (0)