From 1a133d4616a682da953f9e07e351098562e3b674 Mon Sep 17 00:00:00 2001 From: VaiMalaviya <55515799+vaimalaviya1233@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:59:12 -0600 Subject: [PATCH 1/3] powershell build script Signed-off-by: VaiMalaviya <55515799+vaimalaviya1233@users.noreply.github.com> --- build.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 build.ps1 diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..e69de29 From ad4d3f2f315f6d727b90a4231d6823409d5a632d Mon Sep 17 00:00:00 2001 From: VaiMalaviya <55515799+vaimalaviya1233@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:09:14 -0600 Subject: [PATCH 2/3] build script update sidepanel, and bookmark search function fix Signed-off-by: VaiMalaviya <55515799+vaimalaviya1233@users.noreply.github.com> --- build.ps1 | 19 +++++++++++++++++++ src/manifest.json | 9 +++++++-- src/pages/Background/index.ts | 5 ++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index e69de29..0b8023b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -0,0 +1,19 @@ +# Install deps +npm install + +# Build +npm run build + +# Check if --firefox argument was passed +if ($args[0] -eq "--firefox") { + # Copy to firefox/manifest.json + Write-Host "Built for Firefox..." + Copy-Item -Path "firefox/manifest.json" -Destination "dist/manifest.json" +} else { + # Copy to dist/manifest.json + Write-Host "Built for Chrom(ium)e..." + Copy-Item -Path "src/manifest.json" -Destination "dist/manifest.json" +} + +# Done (for now...) +Write-Host "Done! " diff --git a/src/manifest.json b/src/manifest.json index b4b3c46..3bef170 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -18,6 +18,9 @@ "page": "./src/pages/Options/options.html", "browser_style": false }, + "side_panel": { + "default_path": "./index.html" + }, "icons": { "16": "./16.png", "32": "./32.png", @@ -30,14 +33,16 @@ "tabs", "bookmarks", "commands", - "contextMenus" + "contextMenus", + "sidePanel" + ], "background": { "service_worker": "./background.js", "type": "module" }, "omnibox": { - "keyword": "lk" + "keyword": "lw" }, "host_permissions": [ "*://*/*" diff --git a/src/pages/Background/index.ts b/src/pages/Background/index.ts index 19da667..10d57d5 100644 --- a/src/pages/Background/index.ts +++ b/src/pages/Background/index.ts @@ -12,6 +12,7 @@ import OnClickData = chrome.contextMenus.OnClickData; import OnInputEnteredDisposition = chrome.omnibox.OnInputEnteredDisposition; const browser = getBrowser(); +let configuration = null; // this js needs init function which initializes the configuration variable thus solving many lines in this file which repeadiatly uses getConfig() it might be better // This is the main functions that will be called when a bookmark is created, update or deleted // Won't work with axios xhr or something not supported by the browser @@ -236,10 +237,12 @@ browser.omnibox.onInputEntered.addListener(async (content: string, disposition: return; } + configuration = await getConfig(); // code line waiting to be replaced by nothing once global init function is done until then mae do with this + const isUrl = /^http(s)?:\/\//.test(content); const url = isUrl ? content - : `lk`; + : `${configuration.baseUrl}/search?q=${encodeURIComponent(content)}`; // This part was taken https://github.com/sissbruecker/linkding-extension/blob/master/src/background.js // Edge doesn't allow updating the New Tab Page (tested with version 117). // Trying to do so will throw: "Error: Cannot update NTP tab." From ca5181e97445e1f9530d85c331d0cac9eaed2adb Mon Sep 17 00:00:00 2001 From: VaiMalaviya <55515799+vaimalaviya1233@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:27:31 -0600 Subject: [PATCH 3/3] added reload listner for sidepanel Signed-off-by: VaiMalaviya <55515799+vaimalaviya1233@users.noreply.github.com> --- src/pages/Background/index.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/pages/Background/index.ts b/src/pages/Background/index.ts index 10d57d5..247d25a 100644 --- a/src/pages/Background/index.ts +++ b/src/pages/Background/index.ts @@ -270,3 +270,26 @@ browser.omnibox.onInputEntered.addListener(async (content: string, disposition: }); +// refresh for sidepanel on tab change +chrome.tabs.onUpdated.addListener((tabId, changeInfo) => { + // if (changeInfo.url) { + console.log("Tab URL changed:", changeInfo.url, " Tab ID:", tabId); + + // Reload the side panel if needed + chrome.sidePanel.setOptions({ path: "./index.html" }); + // } +}); + +// Listen for tab changes +chrome.tabs.onActivated.addListener(async (activeInfo) => { + console.log("Tab changed:", activeInfo); + + try { + await chrome.sidePanel.setOptions({ + path: "./index.html" + }); + console.log("Side panel reloaded."); + } catch (error) { + console.error("Failed to reload the side panel:", error); + } +}); \ No newline at end of file