Skip to content

Commit

Permalink
Closes #759
Browse files Browse the repository at this point in the history
Closes #760
Increase version to 1.1.1
  • Loading branch information
ParticleCore committed Oct 12, 2019
1 parent 3ce6b6c commit 9b69df7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 35 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.1.0",
"version" : "1.1.1",
"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.
36 changes: 36 additions & 0 deletions src/Webextension/js/background-inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,42 @@ window.main = function (

};

window.pbjMod = function (data) {

if (!data.response ||
!data.response.parts ||
!data.url.endsWith("pbj=1")
) {

return;

}

let i;

for (i = 0; i < data.response.parts.length; i++) {

if (!data.response.parts[i].player) {
continue;
}

if (window.autoPlayVideo &&
data.response.parts[i].player &&
data.response.parts[i].player.args &&
data.response.parts[i].player.args.fflags
) {
data.response.parts[i].player.args.fflags = data.response.parts[i].player.args.fflags.replace(
/disable_new_pause_state3=true/g,
"disable_new_pause_state3=false"
);
}

break;

}

};

window.imageLoader = function (
element,
url
Expand Down
59 changes: 26 additions & 33 deletions src/Webextension/js/background.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";

const GET_BROADCAST_ID = 0;
const YT_PATTERN = "*://www.youtube.com/*";
const YT_DOMAIN = "https://www.youtube.com";
const GET_BROADCAST_ID = 0;

let api;
let util;
Expand Down Expand Up @@ -59,6 +59,10 @@ api = {
broadcastId: util.generateUUID(),
mainFrameListener: function (details) {

if (details.frameId !== 0) {
return {};
}

if (settings.autoPlayVideo &&
!settings.maxResThumbnail
) {
Expand Down Expand Up @@ -87,11 +91,15 @@ api = {

};

util.filterEngine(details ,modifier);
util.filterEngine(details, modifier);

},
scriptListener: function (details) {

if (details.frameId !== 0) {
return {};
}

if (settings.autoPlayVideo) {
return;
}
Expand Down Expand Up @@ -123,6 +131,12 @@ api = {
;
} else {

str = str
.replace(
/(\.onDone=function\(([a-z0-9]+)\){)/gi,
"$1(" + window.pbjMod + "($2));"
);

if (!settings.autoPlayVideo) {
str = str
.replace(
Expand All @@ -145,36 +159,12 @@ api = {
util.filterEngine(details, modifier);

},
xhrListener: function (details) {
headersListener: function (details) {

if (settings.autoPlayVideo) {
return;
if (details.frameId !== 0) {
return {requestHeaders: details.requestHeaders};
}

console.log("xhr: " + details.url);

let modifier;

modifier = function (str) {

if (!settings.autoPlayVideo) {
str = str
.replace(
/disable_new_pause_state3=true/g,
"disable_new_pause_state3=false"
)
;
}

return str;

};

util.filterEngine(details, modifier);

},
headersListener: function (details) {

function setCookieValue(originalValue) {

if (typeof originalValue !== 'string' &&
Expand Down Expand Up @@ -269,8 +259,13 @@ api = {

const block = ["blocking"];
const blockHeaders = ["blocking", "requestHeaders"];
const headersFilter = {urls: [YT_PATTERN]};
const mainFilter = {urls: [YT_PATTERN], types: ["main_frame"]};
const headersFilter = {
urls: [YT_PATTERN]
};
const mainFilter = {
urls: [YT_PATTERN],
types: ["main_frame"]
};
const scriptFilter = {
urls: [
YT_PATTERN + "/base.js",
Expand All @@ -279,12 +274,10 @@ api = {
],
types: ["script"]
};
const xhrFilter = {urls: [YT_PATTERN + "pbj=1"], types: ["xmlhttprequest"]};

chrome.webRequest.onBeforeSendHeaders.addListener(api.headersListener, headersFilter, blockHeaders);
chrome.webRequest.onBeforeRequest.addListener(api.mainFrameListener, mainFilter, block);
chrome.webRequest.onBeforeRequest.addListener(api.scriptListener, scriptFilter, block);
chrome.webRequest.onBeforeRequest.addListener(api.xhrListener, xhrFilter, block);

},
ini: function () {
Expand Down
2 changes: 1 addition & 1 deletion src/Webextension/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.1.0",
"version": "1.1.1",
"description": "YouTube with more freedom",
"default_locale": "en_US",
"icons": {
Expand Down

0 comments on commit 9b69df7

Please sign in to comment.