Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added sidebar permissions to manifest and added PowerShell build script #86

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -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! "
20 changes: 19 additions & 1 deletion firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,31 @@
"page": "./src/pages/Options/options.html",
"browser_style": false
},
"sidebar_action": {
"default_title": "Linkwarden",
"default_panel": "./index.html",
"default_icon": {
"16": "./16.png",
"32": "./32.png",
"48": "./48.png",
"128": "./128.png"
}
},
"icons": {
"16": "./16.png",
"32": "./32.png",
"48": "./48.png",
"128": "./128.png"
},
"permissions": ["storage", "activeTab", "tabs", "bookmarks", "contextMenus", "http://*/*", "https://*/*"],
"permissions": [
"storage",
"activeTab",
"tabs",
"bookmarks",
"contextMenus",
"http://*/*",
"https://*/*"
],
"commands": {
"_execute_action": {
"suggested_key": {
Expand Down
5 changes: 4 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
},
"default_title": "Linkwarden"
},
"side_panel": {
"default_path": "./index.html"
},
"options_ui": {
"page": "./src/pages/Options/options.html",
"browser_style": false
Expand All @@ -24,7 +27,7 @@
"48": "./48.png",
"128": "./128.png"
},
"permissions": ["storage", "activeTab", "tabs", "bookmarks", "commands", "contextMenus"],
"permissions": ["storage", "activeTab", "tabs", "bookmarks", "commands", "contextMenus","sidePanel"],
"background": {
"service_worker": "background.js",
"type": "module"
Expand Down
16 changes: 11 additions & 5 deletions src/pages/Background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getCsrfTokenFetch, getSessionFetch, performLoginOrLogoutFetch } from '.
import OnInputEnteredDisposition = chrome.omnibox.OnInputEnteredDisposition;

const browser = getBrowser();
let configuration = null;

// 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
Expand Down Expand Up @@ -280,10 +281,10 @@ browser.omnibox.onInputChanged.addListener(async (text: string, suggest: (arg0:
});

const bookmarkSuggestions = searchedBookmarks.map(bookmark => {
return {
content: bookmark.url,
description: bookmark.name || bookmark.url
}
return {
content: bookmark.url,
description: bookmark.name || bookmark.url
}
});
suggest(bookmarkSuggestions)

Expand All @@ -296,10 +297,15 @@ browser.omnibox.onInputEntered.addListener(async (content: string, disposition:
return;
}

configuration = await getConfig();

const isUrl = /^http(s)?:\/\//.test(content);


// This part was taken https://github.com/sissbruecker/linkding-extension/blob/master/src/background.js Thanks to @sissbruecker
const url = isUrl
? content
: `lk`;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original was wrong implementation of omnibox it did nothing other than to redirect to non-existent page

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix for #83

: `${configuration.baseUrl}/search?q=${encodeURIComponent(content)}`;

// Edge doesn't allow updating the New Tab Page (tested with version 117).
// Trying to do so will throw: "Error: Cannot update NTP tab."
Expand Down