diff --git a/bin/update.json b/bin/update.json index 26898cd..0a2968c 100644 --- a/bin/update.json +++ b/bin/update.json @@ -3,7 +3,7 @@ "unlisted-iridium@particlecore.github.io" : { "updates" : [ { - "version" : "1.2.4", + "version" : "1.2.5", "update_link" : "https://github.com/ParticleCore/Iridium/raw/master/dist/Iridium.xpi", "applications" : { "gecko" : { diff --git a/dist/Iridium.xpi b/dist/Iridium.xpi index dd5b11d..db548f2 100644 Binary files a/dist/Iridium.xpi and b/dist/Iridium.xpi differ diff --git a/src/html/options.html b/src/html/options.html index 9107df7..b682806 100644 --- a/src/html/options.html +++ b/src/html/options.html @@ -60,14 +60,15 @@
Download
- +
Coming soon
+
diff --git a/src/js/background-inject.js b/src/js/background-inject.js index 9107b79..ed0a51d 100644 --- a/src/js/background-inject.js +++ b/src/js/background-inject.js @@ -318,7 +318,7 @@ window.main = function ( toggledStyle: {styleType: "STYLE_DEFAULT_ACTIVE"} } } - }, + }/*, SAVE_VIDEO: { injected: false, element: { @@ -342,7 +342,7 @@ window.main = function ( tooltip: "Streams" } } - } + }*/ }; topLevelButtons.forEach(function (value) { diff --git a/src/js/background.js b/src/js/background.js index 7677590..08cec50 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -47,23 +47,66 @@ util = { ) { let str; + let data; + let buffer; let filter; let decoder; let encoder; - - str = ""; + let writeOffset; + let patchVersion; + let combinedArray; + let combinedLength; + let commentBlock; + + data = []; + patchVersion = "iridium patch version " + chrome.runtime.getManifest().version; + commentBlock = (details.type === "script" ? `// ${patchVersion} ` : ``) + "\n"; decoder = new TextDecoder("utf-8"); encoder = new TextEncoder(); filter = util.filterResponse(details.requestId); filter.ondata = function (event) { - str += util.filterCacheData(decoder.decode(event.data, {stream: true})); + data.push(new Uint8Array(event.data)); }; filter.onstop = function (event) { - filter.write(encoder.encode(modifier(str))); - filter.disconnect(); + writeOffset = 0; + combinedLength = 0; + + for (buffer of data) { + combinedLength += buffer.length; + } + + combinedArray = new Uint8Array(combinedLength); + + while (writeOffset < combinedLength) { + + buffer = data.shift(); + combinedArray.set(buffer, writeOffset); + writeOffset += buffer.length; + + } + + // check if the resource has already been modified by the current extension version + // to avoid redundant operations + // note: still have to find a way to handle when a cached version was modified by a + // previous extension version + + str = decoder.decode(combinedArray, {stream: false}); + + if (str.startsWith(commentBlock)) { + filter.write(combinedArray); + } else { + filter.write(encoder.encode(commentBlock + modifier(util.filterCacheData(str)))); + } + + filter.close(); + + str = null; + combinedArray = null; + buffer = null; + data.length = 0; }; diff --git a/src/manifest.json b/src/manifest.json index 1b70e09..110630d 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Iridium for YouTube", - "version": "1.2.4", + "version": "1.2.5", "description": "YouTube with more freedom", "default_locale": "en_US", "options_ui": {