From 3081747f09a502a264c8bac1da5502258ec9e42d Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Fri, 21 Jun 2024 20:17:16 +0530 Subject: [PATCH 01/13] chore : added host permissions --- manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.json b/manifest.json index 46a9f54..3f95197 100644 --- a/manifest.json +++ b/manifest.json @@ -19,6 +19,7 @@ "webRequestBlocking", "alarms" ], + "host_permissions":["https://*/*"], "content_scripts": [ { "matches": [ From 32cd24b6cd055ef1ad1001518a6d6b00ac06b96d Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Fri, 21 Jun 2024 20:35:58 +0530 Subject: [PATCH 02/13] feat : added declarativeNetRequest API --- manifest.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 3f95197..a609d41 100644 --- a/manifest.json +++ b/manifest.json @@ -10,13 +10,22 @@ "48": "icons/Lingualibre_SignIt-logo-no-text-square-48.png", "64": "icons/Lingualibre_SignIt-logo-no-text-square-64.png" }, + "declarative_net_request": { + "rule_resources": [ + { + "id": "1", + "enabled": true, + "path": "rules.json" + } + ] + }, "permissions": [ "scripting", "activeTab", "contextMenus", "storage", "webRequest", - "webRequestBlocking", + "declarativeNetRequest", "alarms" ], "host_permissions":["https://*/*"], From 5b35e11ef4965c72f2be278429c5bf2b314ae97a Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Fri, 21 Jun 2024 20:37:10 +0530 Subject: [PATCH 03/13] chore : ruleset for declarativeNetRequest API --- rules.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 rules.json diff --git a/rules.json b/rules.json new file mode 100644 index 0000000..42b4777 --- /dev/null +++ b/rules.json @@ -0,0 +1,11 @@ +[ + { + "id" : 1, + "priority": 1, + "action" : { "type" : "modifyHeaders" }, + "condition" : { + "urlFilter" : "|https*", + "resourceTypes" : ["main_frame"] + } + } + ] \ No newline at end of file From ad74f5bf33e0c71b2c56d3a073a589217b5c552b Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Fri, 21 Jun 2024 23:46:33 +0530 Subject: [PATCH 04/13] chore : added response headers info --- rules.json | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/rules.json b/rules.json index 42b4777..87a64cf 100644 --- a/rules.json +++ b/rules.json @@ -1,11 +1,21 @@ [ { - "id" : 1, - "priority": 1, - "action" : { "type" : "modifyHeaders" }, - "condition" : { - "urlFilter" : "|https*", - "resourceTypes" : ["main_frame"] - } + "id": 1, + "priority": 1, + "action": { + "type": "modifyHeaders", + "responseHeaders": [ + { + "header": "content-security-policy", + "operation": "set" + } + ] + }, + "condition": { + "urlFilter": "|https*", + "resourceTypes": [ + "main_frame" + ] + } } - ] \ No newline at end of file +] \ No newline at end of file From 015bbab7270471a64a0b054145d98861411c7457 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Mon, 24 Jun 2024 20:11:06 +0530 Subject: [PATCH 05/13] chore : updated id --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a609d41..4383cbd 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "declarative_net_request": { "rule_resources": [ { - "id": "1", + "id": "ruleset", "enabled": true, "path": "rules.json" } From 439521bb6883c4bf81cb3381ffc3983b30c26e39 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Tue, 25 Jun 2024 02:03:25 +0530 Subject: [PATCH 06/13] chore : adding value to responseHeaders --- rules.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rules.json b/rules.json index 87a64cf..855c669 100644 --- a/rules.json +++ b/rules.json @@ -6,8 +6,9 @@ "type": "modifyHeaders", "responseHeaders": [ { - "header": "content-security-policy", - "operation": "set" + "header": "Content-Security-Policy", + "operation": "set", + "value": "media-src https://commons.wikimedia.org https://upload.wikimedia.org" } ] }, From 93d205359304ee340b9aa5dde53a825b3aae97e0 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Tue, 25 Jun 2024 02:15:31 +0530 Subject: [PATCH 07/13] test : confirming whether the headers have been modified by DNR --- background-script.js | 35 +++++++++++++++++++---------------- sw.js | 3 +++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/background-script.js b/background-script.js index 5375542..99e84c9 100644 --- a/background-script.js +++ b/background-script.js @@ -333,22 +333,25 @@ async function checkActiveTabInjections( tab ) { } // Edit the header of all pages on-the-fly to bypass Content-Security-Policy -browser.webRequest.onHeadersReceived.addListener(info => { - const headers = info.responseHeaders; // original headers - for (let i=headers.length-1; i>=0; --i) { - let header = headers[i].name.toLowerCase(); - if (header === "content-security-policy") { // csp header is found - // modifying media-src; this implies that the directive is already present - headers[i].value = headers[i].value.replace("media-src", "media-src https://commons.wikimedia.org https://upload.wikimedia.org"); - } - } - // return modified headers - return {responseHeaders: headers}; -}, { - urls: [ "" ], // match all pages - types: [ "main_frame" ] // to focus only the main document of a tab -}, ["blocking", "responseHeaders"]); - +// browser.webRequest.onHeadersReceived.addListener(info => { +// const headers = info.responseHeaders; // original headers +// console.log(headers); +// for (let i=headers.length-1; i>=0; --i) { +// let header = headers[i].name.toLowerCase(); +// if (header === "content-security-policy") { // csp header is found +// // modifying media-src; this implies that the directive is already present +// headers[i].value = headers[i].value.replace("media-src", "media-src https://commons.wikimedia.org https://upload.wikimedia.org"); +// } +// } +// // return modified headers +// return {responseHeaders: headers}; +// }, { +// urls: [ "" ], // match all pages +// types: [ "main_frame" ] // to focus only the main document of a tab +// }, ["blocking", "responseHeaders"]); + +browser.declarativeNetRequest.getAvailableStaticRuleCount(numOfRulesThatCanStillBeAdded=>console.log(numOfRulesThatCanStillBeAdded)); +browser.declarativeNetRequest.getEnabledRulesets(id=>console.log(id)); // this shows the id we set inside our dnr.rule_resources in manifest.json /* *************************************************************** */ /* Browser interactions ****************************************** */ diff --git a/sw.js b/sw.js index a71ac8d..1c1d438 100644 --- a/sw.js +++ b/sw.js @@ -638,6 +638,9 @@ async function setState(value) { } } +browser.declarativeNetRequest.getAvailableStaticRuleCount(numOfRulesThatCanStillBeAdded=>console.log(numOfRulesThatCanStillBeAdded)); +browser.declarativeNetRequest.getEnabledRulesets(id=>console.log(id)); // this shows the id we set inside our dnr.rule_resources in manifest.json + /* Browser interactions ****************************************** */ var callModal = async function (msg) { // Tab From 4b7d27c91617b0bf7635dc84a09cc63a50ec7412 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Thu, 4 Jul 2024 12:55:17 +0530 Subject: [PATCH 08/13] revert : removing DNR API --- manifest.json | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/manifest.json b/manifest.json index 4383cbd..2c03f8c 100644 --- a/manifest.json +++ b/manifest.json @@ -10,22 +10,12 @@ "48": "icons/Lingualibre_SignIt-logo-no-text-square-48.png", "64": "icons/Lingualibre_SignIt-logo-no-text-square-64.png" }, - "declarative_net_request": { - "rule_resources": [ - { - "id": "ruleset", - "enabled": true, - "path": "rules.json" - } - ] - }, "permissions": [ "scripting", "activeTab", "contextMenus", "storage", "webRequest", - "declarativeNetRequest", "alarms" ], "host_permissions":["https://*/*"], From 1ec28512b2569f7a8279434b3a652f49a158c4f9 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Thu, 4 Jul 2024 13:05:35 +0530 Subject: [PATCH 09/13] revert : no longer needed as we aren't using DNR API --- background-script.js | 21 --------------------- sw.js | 3 --- 2 files changed, 24 deletions(-) diff --git a/background-script.js b/background-script.js index 99e84c9..a11d4d7 100644 --- a/background-script.js +++ b/background-script.js @@ -332,27 +332,6 @@ async function checkActiveTabInjections( tab ) { } } -// Edit the header of all pages on-the-fly to bypass Content-Security-Policy -// browser.webRequest.onHeadersReceived.addListener(info => { -// const headers = info.responseHeaders; // original headers -// console.log(headers); -// for (let i=headers.length-1; i>=0; --i) { -// let header = headers[i].name.toLowerCase(); -// if (header === "content-security-policy") { // csp header is found -// // modifying media-src; this implies that the directive is already present -// headers[i].value = headers[i].value.replace("media-src", "media-src https://commons.wikimedia.org https://upload.wikimedia.org"); -// } -// } -// // return modified headers -// return {responseHeaders: headers}; -// }, { -// urls: [ "" ], // match all pages -// types: [ "main_frame" ] // to focus only the main document of a tab -// }, ["blocking", "responseHeaders"]); - -browser.declarativeNetRequest.getAvailableStaticRuleCount(numOfRulesThatCanStillBeAdded=>console.log(numOfRulesThatCanStillBeAdded)); -browser.declarativeNetRequest.getEnabledRulesets(id=>console.log(id)); // this shows the id we set inside our dnr.rule_resources in manifest.json - /* *************************************************************** */ /* Browser interactions ****************************************** */ var callModal = async function(msg){ diff --git a/sw.js b/sw.js index 1c1d438..a71ac8d 100644 --- a/sw.js +++ b/sw.js @@ -638,9 +638,6 @@ async function setState(value) { } } -browser.declarativeNetRequest.getAvailableStaticRuleCount(numOfRulesThatCanStillBeAdded=>console.log(numOfRulesThatCanStillBeAdded)); -browser.declarativeNetRequest.getEnabledRulesets(id=>console.log(id)); // this shows the id we set inside our dnr.rule_resources in manifest.json - /* Browser interactions ****************************************** */ var callModal = async function (msg) { // Tab From ce60a278b9c443e8cd5070c46a2fcdbe774a42be Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Thu, 4 Jul 2024 18:38:59 +0530 Subject: [PATCH 10/13] chore : replacing video tag with iframe --- SignItVideosGallery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignItVideosGallery.js b/SignItVideosGallery.js index 2c9a53f..d931961 100644 --- a/SignItVideosGallery.js +++ b/SignItVideosGallery.js @@ -41,7 +41,7 @@ SignItVideosGallery.prototype.refresh = async function ( files ) { console.log(await banana.i18n("si-panel-videos-gallery-attribution",url, speaker, i+1, total)); this.$videos.push( $( `
- + ${await banana.i18n("si-panel-videos-gallery-attribution",url, speaker, i+1, total)}
` ) ); From 27260e336a77635fa30ef58aad7299c01e08e807 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Thu, 4 Jul 2024 19:44:37 +0530 Subject: [PATCH 11/13] refactor : adding autoplay functionality and resizing the iframe --- SignItVideosGallery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignItVideosGallery.js b/SignItVideosGallery.js index d931961..a1d46c4 100644 --- a/SignItVideosGallery.js +++ b/SignItVideosGallery.js @@ -41,7 +41,7 @@ SignItVideosGallery.prototype.refresh = async function ( files ) { console.log(await banana.i18n("si-panel-videos-gallery-attribution",url, speaker, i+1, total)); this.$videos.push( $( `
- + ${await banana.i18n("si-panel-videos-gallery-attribution",url, speaker, i+1, total)}
` ) ); From b5ea8a2098db838c133251b85a829d04a32708d8 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Thu, 4 Jul 2024 20:24:51 +0530 Subject: [PATCH 12/13] refactor : replaced video with iframe --- SignItVideosGallery.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/SignItVideosGallery.js b/SignItVideosGallery.js index a1d46c4..9e8b907 100644 --- a/SignItVideosGallery.js +++ b/SignItVideosGallery.js @@ -57,7 +57,7 @@ SignItVideosGallery.prototype.switchVideo = function ( newIndex ) { this.$videos[ this.currentIndex ].hide(); this.currentIndex = newIndex; this.$videos[ this.currentIndex ].show(); - $currentVideo = this.$videos[ this.currentIndex ].children( 'video' )[ 0 ]; + $currentVideo = this.$videos[ this.currentIndex ].children( 'iframe' )[ 0 ]; $( async function () { param = await browser.storage.local.get( 'twospeed' ); @@ -84,9 +84,6 @@ SignItVideosGallery.prototype.switchVideo = function ( newIndex ) { } }) - // After switching, play - $currentVideo.play(); - // Arrows disables when on edges this.currentIndex === 0 ? this.previousVideoButton.setDisabled( true ) From a4f9a3c1b3d2a5c7604673c7196458286bf58090 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Thu, 4 Jul 2024 20:26:08 +0530 Subject: [PATCH 13/13] chore : replaced video with iframe --- content_scripts/signit.css | 2 +- content_scripts/wpintegration.css | 2 +- popup/popup.css | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content_scripts/signit.css b/content_scripts/signit.css index 0d7697c..d4a3bab 100644 --- a/content_scripts/signit.css +++ b/content_scripts/signit.css @@ -69,7 +69,7 @@ align-items: center; } -.signit-video video { +.signit-video iframe { box-shadow: 0 0 0.5rem #999; width: 100%; } diff --git a/content_scripts/wpintegration.css b/content_scripts/wpintegration.css index 83876ef..cd9d733 100644 --- a/content_scripts/wpintegration.css +++ b/content_scripts/wpintegration.css @@ -6,7 +6,7 @@ max-width: 300px; } -.signit-inline-container video { +.signit-inline-container iframe { box-shadow: 0 0 .5rem #999; } diff --git a/popup/popup.css b/popup/popup.css index 2cbcc41..92f8591 100644 --- a/popup/popup.css +++ b/popup/popup.css @@ -185,7 +185,7 @@ html, body { align-items: center; } -.signit-video video { +.signit-video iframe { box-shadow: 0 0 .5rem #999; width: 345px; }