From 449e829b78ba2739ffef70ce63e92ef294a91f5d Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Fri, 21 Jun 2024 16:21:22 -0700 Subject: [PATCH] fix youtube capture + bump wabac.js to 2.19.1 (#230) - deps: bump to wabac 2.19.1 - add new html rx rewriting (from wabca.js 2.19.x) to fix youtube - bump to 0.12.2 --- package.json | 4 ++-- src/recorder.js | 14 ++++++++------ yarn.lock | 18 +++++++++--------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index f561948f..38fe77d1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@webrecorder/archivewebpage", "productName": "ArchiveWeb.page", - "version": "0.12.1", + "version": "0.12.2", "main": "index.js", "description": "Create Web Archives directly in your browser", "repository": "https://github.com/webrecorder/archiveweb.page", @@ -11,7 +11,7 @@ "@fortawesome/fontawesome-free": "^5.13.0", "@ipld/car": "^5.3.1", "@webrecorder/awp-sw": "^0.4.4", - "@webrecorder/wabac": "^2.18.3", + "@webrecorder/wabac": "^2.19.1", "auto-js-ipfs": "^2.3.0", "browsertrix-behaviors": "^0.6.0", "btoa": "^1.2.1", diff --git a/src/recorder.js b/src/recorder.js index 75c6158a..a4a99af4 100644 --- a/src/recorder.js +++ b/src/recorder.js @@ -1,6 +1,6 @@ import { RequestResponseInfo } from "./requestresponseinfo.js"; -import { baseRules as baseDSRules } from "@webrecorder/wabac/src/rewrite"; +import { baseRules as baseDSRules, htmlRules as htmlDSRules } from "@webrecorder/wabac/src/rewrite"; import { rewriteDASH, rewriteHLS } from "@webrecorder/wabac/src/rewrite/rewriteVideo"; import { Buffer } from "buffer"; @@ -988,6 +988,8 @@ class Recorder { let newString = null; let string = null; + const { url, extraOpts } = reqresp; + const ct = this._getContentType(params.responseHeaders); switch (ct) { @@ -1007,13 +1009,13 @@ class Recorder { case "text/javascript": case "application/javascript": case "application/x-javascript": { - const rw = baseDSRules.getRewriter(params.request.url); + const rules = ct === "text/html" ? htmlDSRules : baseDSRules; + const rw = rules.getRewriter(url); - if (rw !== baseDSRules.defaultRewriter) { - string = payload.toString("utf-8"); - newString = rw.rewrite(string, {live: true, save: reqresp.extraOpts}); + if (rw !== rules.defaultRewriter) { + string = payload.toString(); + newString = rw.rewrite(string, {live: true, save: extraOpts}); } - break; } } diff --git a/yarn.lock b/yarn.lock index eebbb4f4..0af83a3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -984,15 +984,15 @@ uuid "^9.0.0" warcio "^2.2.1" -"@webrecorder/wabac@^2.17.3", "@webrecorder/wabac@^2.18.1", "@webrecorder/wabac@^2.18.3": - version "2.18.3" - resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.18.3.tgz#eda195452a9964e8216fb0676d5da6cc69239dae" - integrity sha512-qmNLXky9QHpljt0EyEmcO6L2qFGG63mZbMYKso0MZZLFY3NeUf/ANafq9pWWm1Bw10+zoV6KRtHUin8gropccA== +"@webrecorder/wabac@^2.17.3", "@webrecorder/wabac@^2.18.1", "@webrecorder/wabac@^2.19.1": + version "2.19.1" + resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.19.1.tgz#ce0d609f9e90c708af99945e1fa338be0ba2b5f9" + integrity sha512-m8Fi70OkhzkicbcbN5TrrBpj5D/EZKzVp5905kGPoC2F2zLqxUDMzx1FOHt2sTO/1b9NMvBmw9Pk1JQyYEm6rA== dependencies: "@peculiar/asn1-ecc" "^2.3.4" "@peculiar/asn1-schema" "^2.3.3" "@peculiar/x509" "^1.9.2" - "@webrecorder/wombat" "^3.7.6" + "@webrecorder/wombat" "^3.7.8" acorn "^8.10.0" auto-js-ipfs "^2.1.1" base64-js "^1.5.1" @@ -1013,10 +1013,10 @@ stream-browserify "^3.0.0" warcio "^2.2.1" -"@webrecorder/wombat@^3.7.6": - version "3.7.6" - resolved "https://registry.yarnpkg.com/@webrecorder/wombat/-/wombat-3.7.6.tgz#e52a1bcfccd0150517989bc4310a03730a1f74e7" - integrity sha512-SA34StdLc+D60Aa8bZ2I+8PLjody1B/j9DmZ2zyXg/EZuPLSG4ec6XvMzq8QYuoGvD+hkjAf0YlUGxmI/viIcw== +"@webrecorder/wombat@^3.7.8": + version "3.7.8" + resolved "https://registry.yarnpkg.com/@webrecorder/wombat/-/wombat-3.7.8.tgz#a414278b6fbd99bc02a97e384f0373307e60d9fa" + integrity sha512-BmEHrvGLHPQtECmCK9Oz7G3p2StsyaFOlNmAMDSNK/GjqPH+UWZOqDryBkWryTh+pFZXKblqyotLtvR4YxVyeQ== dependencies: warcio "^2.2.0"