diff --git a/bin/update.json b/bin/update.json index fe3a5ac..c754cdc 100644 --- a/bin/update.json +++ b/bin/update.json @@ -3,7 +3,7 @@ "unlisted-iridium@particlecore.github.io" : { "updates" : [ { - "version" : "1.1.0", + "version" : "1.1.1", "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 b5bdf25..d70b8c7 100644 Binary files a/dist/Iridium.xpi and b/dist/Iridium.xpi differ diff --git a/src/Webextension/js/background-inject.js b/src/Webextension/js/background-inject.js index c33118b..98bde27 100644 --- a/src/Webextension/js/background-inject.js +++ b/src/Webextension/js/background-inject.js @@ -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 diff --git a/src/Webextension/js/background.js b/src/Webextension/js/background.js index 39a404a..dbfa8cd 100644 --- a/src/Webextension/js/background.js +++ b/src/Webextension/js/background.js @@ -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; @@ -59,6 +59,10 @@ api = { broadcastId: util.generateUUID(), mainFrameListener: function (details) { + if (details.frameId !== 0) { + return {}; + } + if (settings.autoPlayVideo && !settings.maxResThumbnail ) { @@ -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; } @@ -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( @@ -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' && @@ -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", @@ -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 () { diff --git a/src/Webextension/manifest.json b/src/Webextension/manifest.json index e2f7e31..223ff36 100644 --- a/src/Webextension/manifest.json +++ b/src/Webextension/manifest.json @@ -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": {