diff --git a/vaft/vaft-ublock-origin.js b/vaft/vaft-ublock-origin.js index f927c53..c16bbea 100644 --- a/vaft/vaft-ublock-origin.js +++ b/vaft/vaft-ublock-origin.js @@ -255,11 +255,19 @@ twitch-videoad.js text/javascript }); } function getWasmWorkerJs(twitchBlobUrl) { + if (!getWasmWorkerJs.cache) { + getWasmWorkerJs.cache = Object.create(null); + } + if (getWasmWorkerJs.cache[twitchBlobUrl]) { + return getWasmWorkerJs.cache[twitchBlobUrl]; + } const req = new XMLHttpRequest(); req.open('GET', twitchBlobUrl, false); req.overrideMimeType("text/javascript"); req.send(); - return req.responseText; + const text = req.responseText; + getWasmWorkerJs.cache[twitchBlobUrl] = text; + return text; } // Hook fetch() in the worker scope to intercept m3u8 playlist requests and ad segments function hookWorkerFetch() { diff --git a/vaft/vaft.user.js b/vaft/vaft.user.js index 1066138..82a2760 100644 --- a/vaft/vaft.user.js +++ b/vaft/vaft.user.js @@ -266,11 +266,19 @@ }); } function getWasmWorkerJs(twitchBlobUrl) { + if (!getWasmWorkerJs.cache) { + getWasmWorkerJs.cache = Object.create(null); + } + if (getWasmWorkerJs.cache[twitchBlobUrl]) { + return getWasmWorkerJs.cache[twitchBlobUrl]; + } const req = new XMLHttpRequest(); req.open('GET', twitchBlobUrl, false); req.overrideMimeType("text/javascript"); req.send(); - return req.responseText; + const text = req.responseText; + getWasmWorkerJs.cache[twitchBlobUrl] = text; + return text; } // Hook fetch() in the worker scope to intercept m3u8 playlist requests and ad segments function hookWorkerFetch() {