Skip to content

Commit

Permalink
Closes #825
Browse files Browse the repository at this point in the history
  • Loading branch information
ParticleCore committed Mar 14, 2020
1 parent ba6ee1c commit f051f90
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bin/update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"[email protected]" : {
"updates" : [
{
"version" : "1.2.4",
"version" : "1.2.5",
"update_link" : "https://github.com/ParticleCore/Iridium/raw/master/dist/Iridium.xpi",
"applications" : {
"gecko" : {
Expand Down
Binary file modified dist/Iridium.xpi
Binary file not shown.
5 changes: 3 additions & 2 deletions src/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@
<div class="content">
<div class="setting_header" data-locale="text|section-download">Download</div>
<div class="setting_content">
<input class="setting" id="downloadList" type="checkbox">
<div class="custom-content" data-locale="text|content-soon">Coming soon</div>
<!--<input class="setting" id="downloadList" type="checkbox">
<label class="setting" for="downloadList" data-locale="text|setting-download-list">Display download list option</label>
<a class="feature-link" href="https://github.com/ParticleCore/Iridium/wiki/Features#downloadList" data-locale="title|link-wiki" title="Find out what this does" target="features">?</a>
<br>
<label class="setting" for="fileName" data-locale="text|setting-file-name">File name pattern</label>
<a class="feature-link" href="https://github.com/ParticleCore/Iridium/wiki/Features#fileName" data-locale="title|link-wiki" title="Find out what this does" target="features">?</a>
<br>
<input class="setting" id="fileName" type="text">
<input class="setting" id="fileName" type="text">-->
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions src/js/background-inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ window.main = function (
toggledStyle: {styleType: "STYLE_DEFAULT_ACTIVE"}
}
}
},
}/*,
SAVE_VIDEO: {
injected: false,
element: {
Expand All @@ -342,7 +342,7 @@ window.main = function (
tooltip: "Streams"
}
}
}
}*/
};

topLevelButtons.forEach(function (value) {
Expand Down
53 changes: 48 additions & 5 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} ` : `<!-- ${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;

};

Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit f051f90

Please sign in to comment.