From e9c8dd00c28db7d12b0ebe5fcb2e66b3c26e6482 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Wed, 5 Jun 2024 13:52:46 +0530 Subject: [PATCH 1/8] sent response upon receving message ''signit.getfiles" --- sw.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sw.js b/sw.js index 4f82365..33587a3 100644 --- a/sw.js +++ b/sw.js @@ -740,7 +740,7 @@ async function setState(value) { console.log( records[message.text] || records[message.text.toLowerCase()] || [] ); - return records[message.text] || records[message.text.toLowerCase()] || []; + sendResponse(records[message.text] || records[message.text.toLowerCase()] || []); } // When message 'signit.i18nCode' is heard, returns banada object else if ( From c8333373699dddafbd6e0413050326c91b5e7cd0 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Wed, 5 Jun 2024 13:54:17 +0530 Subject: [PATCH 2/8] Uncommeneted searchWidget getValue method --- popup/popup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/popup/popup.js b/popup/popup.js index db73642..23d1eff 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -130,7 +130,7 @@ var browser = (browserType === 'firefox') ? browser : (browserType === 'chrome') UI.prototype.changeView = async function (text) { if (typeof text !== "string") { - // text = this.searchWidget.getValue(); + text = this.searchWidget.getValue(); } // runs normalize function and wordToFiles in a single go and retruns an array of _word and _files From 5a262ab36b52e0d3fffa0e098b3c729e5310cd19 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Wed, 5 Jun 2024 14:27:42 +0530 Subject: [PATCH 3/8] chore: Update SignItVideosGallery.js to fix link target in i18n function --- SignItVideosGallery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignItVideosGallery.js b/SignItVideosGallery.js index 5a590f8..e535fdb 100644 --- a/SignItVideosGallery.js +++ b/SignItVideosGallery.js @@ -24,7 +24,7 @@ SignItVideosGallery.prototype.refresh = async function ( files ) { var banana = { i18n: (msg, url, speaker,index, total) => { let string = sourceMap.get(locale)[msg]; - let Speaker = `${speaker} `; + let Speaker = `${speaker} `; let patterns = ["{{link|$1|$2}}", "$3", "$4"]; let replacements = [Speaker, index, total]; From 7216bfa568707bda5f724432ebc73ee5c06fd69f Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Wed, 5 Jun 2024 14:28:28 +0530 Subject: [PATCH 4/8] refactor: Updated browser.runtime.sendMessage to chrome API --- content_scripts/wpintegration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content_scripts/wpintegration.js b/content_scripts/wpintegration.js index fd2feb3..7470a3d 100644 --- a/content_scripts/wpintegration.js +++ b/content_scripts/wpintegration.js @@ -25,7 +25,7 @@ $( async function () { } title = $( 'h1.firstHeading' ).text(); - files = await browser.runtime.sendMessage({ + files = await chrome.runtime.sendMessage({ command: 'signit.getfiles', wpTitle: title }); From c01b13390e8e6b3f842aac39b6834729e27c0aa0 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Wed, 5 Jun 2024 17:58:19 +0530 Subject: [PATCH 5/8] Updated `getAvailableWord` function --- sw.js | 54 ++++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/sw.js b/sw.js index 33587a3..48f2d6f 100644 --- a/sw.js +++ b/sw.js @@ -575,21 +575,20 @@ async function setState(value) { } // Check a string with multiple words and return the word whose record is available - function getAvailableWord(word) { - const wordArray = word.split(" "); - // For some reason iterating through array returns undefined so I switched to filter method - - // for ( let newWord of wordArray ) { - // if( records.hasOwnProperty(newWord.toLowerCase()) ){ - // return newWord; - // } - // } - wordArray.filter((e) => { - if (records.hasOwnProperty(e.toLowerCase())) return e; - }); - return wordArray[0]; - } + function getAvailableWord( word ) { + // similar to what we did in background-script.js; + + const regex = /[!"#$%&()*+,-./:;<=>?@[\\\]^_{|}~]/; + const stringWithoutSpecialChars = word.replace(regex,""); + const wordArray = stringWithoutSpecialChars.split(" "); + console.log(wordArray); + for ( let newWord of wordArray ) { + if( records.hasOwnProperty(newWord.toLowerCase()) ){ + return newWord; + } + } + } // Given a word string, check if exist in available records data, if so return data on that word // returns format: { filename: url, speaker: name } function wordToFiles(word) { @@ -623,22 +622,17 @@ async function setState(value) { try { await browser.tabs.sendMessage(tabId, { command: "ping" }); } catch (error) { - // var i, var dependencies = browser.runtime.getManifest().content_scripts[0]; var scripts = dependencies.js; var stylesheets = dependencies.css; // Using the scripting API as per Manifest V3 - // for( i = 0; i < scripts.length; i++ ) { - // await browser.scripting.executeScript( tab, { file: scripts[ i ] } ); await browser.scripting.executeScript({ target: { tabId }, files: [...scripts], }); - // } - // for( i = 0; i < stylesheets.length; i++ ) { - // await browser.tabs.insertCSS( tab, { file: stylesheets[ i ] } ); + await browser.scripting.insertCSS({ target: { tabId }, files: [...stylesheets], @@ -647,26 +641,6 @@ async function setState(value) { } } -// Insecure CSP not supported in manifest V3 , so no need to for the bypass logic - - // 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 interactions ****************************************** */ var callModal = async function (msg) { // Tab From 2a8bb61f17352ec3b8c5d89c147a2ec1e642ff2e Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Wed, 5 Jun 2024 17:59:24 +0530 Subject: [PATCH 6/8] Updated i18n as per SearchWidget placeholder message --- popup/popup.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/popup/popup.js b/popup/popup.js index 23d1eff..5524a6e 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -30,7 +30,13 @@ var browser = (browserType === 'firefox') ? browser : (browserType === 'chrome') // which fetches the messages from sourceMap and replpace them with whatever the key-value pair // for that particular message is - banana = {i18n: msg => sourceMap.get(resArr[1])[msg]}; + banana = {i18n: (msg,argument) => { + let string = sourceMap.get(resArr[1])[msg]; + if ((/\$1/).test(string)) { + string = string.replace(/\$1/,argument); + } + return string; + }}; console.log("banana received: ",banana); } else if (browserType === 'firefox') { // Use Firefox WebExtensions API From 67a193bd1ea0ed037437ee72f1ff89db7c0dfa29 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Fri, 7 Jun 2024 14:56:49 +0530 Subject: [PATCH 7/8] refactor: Update CSS for next and previous buttons --- content_scripts/wpintegration.css | 16 +++++++++++----- popup/popup.css | 11 +++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/content_scripts/wpintegration.css b/content_scripts/wpintegration.css index 226bbfe..83876ef 100644 --- a/content_scripts/wpintegration.css +++ b/content_scripts/wpintegration.css @@ -10,11 +10,17 @@ box-shadow: 0 0 .5rem #999; } -.oo-ui-icon-next { - background-image: url('../icons/arrow-right-solid.svg' )} +.oo-ui-icon-nextBtn , .oo-ui-icon-previousBtn{ + padding-top: 5px; +} +.oo-ui-icon-nextBtn::after { + content: "\25B6"; +} -.oo-ui-icon-previous { - background-image: url('../icons/arrow-left-solid.svg' )} +.oo-ui-icon-previousBtn::after { + content: "\25C0"; +} .oo-ui-icon-search { - background-image: url('../icons/magnifying-glass-solid.svg' )} + background-image: url('../icons/magnifying-glass-solid.svg' ) +} diff --git a/popup/popup.css b/popup/popup.css index 7c7516a..2cbcc41 100644 --- a/popup/popup.css +++ b/popup/popup.css @@ -222,12 +222,15 @@ html, body { margin: auto; } -.oo-ui-icon-next { - background-image: url( '../icons/arrow-right-solid.svg' ); +.oo-ui-icon-nextBtn , .oo-ui-icon-previousBtn{ + padding-top: 5px; +} +.oo-ui-icon-nextBtn::after { + content: "\25B6"; } -.oo-ui-icon-previous { - background-image: url( '../icons/arrow-left-solid.svg' ); +.oo-ui-icon-previousBtn::after { + content: "\25C0"; } .oo-ui-icon-search { From c98a3da4d82292cc40102a7278819af4e99dfec9 Mon Sep 17 00:00:00 2001 From: kabir-afk Date: Fri, 7 Jun 2024 14:57:35 +0530 Subject: [PATCH 8/8] refactor: Update next and previous button icons as per CSS --- SignItVideosGallery.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SignItVideosGallery.js b/SignItVideosGallery.js index e535fdb..fd626bf 100644 --- a/SignItVideosGallery.js +++ b/SignItVideosGallery.js @@ -2,8 +2,8 @@ var SignItVideosGallery = function ( container ) { this.videos = []; this.currentIndex = 0; - this.previousVideoButton = new OO.ui.ButtonWidget( { icon: 'previous', framed: false } ); - this.nextVideoButton = new OO.ui.ButtonWidget( { icon: 'next', framed: false } ); + this.previousVideoButton = new OO.ui.ButtonWidget( { icon: 'previousBtn', framed: false } ); + this.nextVideoButton = new OO.ui.ButtonWidget( { icon: 'nextBtn', framed: false } ); this.$videoContainer = $( '