Skip to content

Commit b986702

Browse files
committed
feat: firefox supoort, but block on logseq cors config #4
Want to support firefox, but block by issue logseq/logseq#8649 now.
1 parent 5db4abe commit b986702

File tree

12 files changed

+89
-58
lines changed

12 files changed

+89
-58
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build](https://github.com/EINDEX/logseq-copilot/actions/workflows/build.yml/badge.svg)](https://github.com/EINDEX/logseq-copilot/actions/workflows/build.yml) ![Visitors](https://visitor-badge.glitch.me/badge?page_id=eindex.logseq-copliot&left_color=green&right_color=red) ![License](https://img.shields.io/github/license/eindex/logseq-copilot)
44

5-
**The project is in the early stage of development, and the current version is only a prototype.**
5+
**The project is in the early stage of development, and the current version just MVP.**
66

77
Logseq Copilot is a Chrome extension that allows you to access your Logseq using your browser. Logseq is a privacy-first, open-source platform for knowledge sharing and management. With Logseq Copilot, you can easily retrieve relevant information from your Logseq graph and enrich your online search, reading, learning experience. 🧠
88

@@ -12,7 +12,8 @@ Logseq Copilot is a Chrome extension that allows you to access your Logseq using
1212

1313
## Features
1414

15-
- Show Logseq blocks when you search on Google via your keywords.🔍
15+
- 🔍 Show Logseq content when you search on popular searching engines via your keywords. Now support Google, Bing, Baidu, Yandex, DuckDuckGo, SearX.
16+
1617

1718
## Screenshot
1819

@@ -39,7 +40,9 @@ How to use this extension, Please follow below steps:
3940
3. (Optional) Enable auto start server when Logseq lunched.
4041
![](docs/screenshots/enable-auto-start.png)
4142

42-
3. Install this extension. Now this extenstion is under review by chrome extenstions store and edge add-ons. So you can go to [release page](https://github.com/EINDEX/logseq-copilot/releases) download it.
43+
3. Install this extension.
44+
- Store version(Recommend): [Chrome](https://chrome.google.com/webstore/detail/logseq-copilot/hihgfcgbmnbomabfdbajlbpnacndeihl), [Edge](https://chrome.google.com/webstore/detail/logseq-copilot/ebigopegbohijaikegebaaboaomaifoi)
45+
- Newest Version [release page](https://github.com/EINDEX/logseq-copilot/releases) download it.
4346

4447
4. Go to Options page to setting the connection.
4548
If you setting correct, you will see a message show on your Logseq and options page will show connected.
@@ -48,13 +51,16 @@ How to use this extension, Please follow below steps:
4851

4952
## Roadmap
5053

51-
-[x] CI/CD: Set up a continuous integration and delivery pipeline for the extension development and deployment. 🚦
54+
- [x] 🚦 CI/CD: Set up a continuous integration and delivery pipeline for the extension development and deployment. 🚦
55+
56+
- [x] 🔍 Support other search engines: Extend the functionality of the extension to other popular search engines, such as Bing, DuckDuckGo, and Baidu.
57+
- [x] 💅 Style enhancement: Improve the appearance and usability of the extension interface and the blocks display.
58+
- [ ] 🌐 Support Firefox.
59+
- [ ] 🆕 Browser new tab page queries: Add an option to show Logseq blocks on the browser's new tab page based on predefined or random queries.
60+
- [ ] QuickCapture & advance quick capture, easy and fast making note in Logseq.
5261

53-
- Support other search engines: Extend the functionality of the extension to other popular search engines, such as Bing, DuckDuckGo, and Baidu. 🌎
54-
- Style enhancement: Improve the appearance and usability of the extension interface and the blocks display. 💅
55-
- Enhance search ranking for better blocks: Implement a more sophisticated algorithm for ranking the blocks based on their relevance to the search query and the user preferences. 📊
56-
- Query enhance to recall more blocks: Implement a more flexible and powerful query system for retrieving the blocks from the Logseq graph, such as using natural language or advanced operators. 🗣️
57-
- Browser new tab page queries: Add an option to show Logseq blocks on the browser's new tab page based on predefined or random queries. 🆕
62+
- ~~Enhance search ranking for better blocks: Implement a more sophisticated algorithm for ranking the blocks based on their relevance to the search query and the user preferences. 📊~~ Now this feature depends on Logseq Searing API
63+
- ~~Query enhance to recall more blocks: Implement a more flexible and powerful query system for retrieving the blocks from the Logseq graph, such as using natural language or advanced operators. 🗣️~~ Now this feature depends on Logseq Searing API
5864

5965
_Welcoming more ideas._
6066

build.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ async function build() {
101101
);
102102
await zipFolder(`./${outdir}/edge`);
103103

104+
// firefox
105+
await copyFiles([...commonFiles], `./${outdir}/firefox`);
106+
await fs.writeFile(
107+
`./${outdir}/firefox/manifest.json`,
108+
JSON.stringify(getManifest('firefox')),
109+
);
110+
await zipFolder(`./${outdir}/firefox`);
111+
104112
console.log('Build success.');
105113
}
106114

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
"@semantic-release/github": "^8.0.7",
3535
"@semantic-release/npm": "^9.0.2",
3636
"@semantic-release/release-notes-generator": "^10.0.3",
37-
"@types/chrome": "^0.0.202",
3837
"@types/react": "^18.0.26",
3938
"@types/react-dom": "^18.0.10",
39+
"@types/webextension-polyfill": "^0.10.0",
4040
"archiver": "^5.3.1",
4141
"autoprefixer": "^10.4.13",
4242
"chokidar-cli": "^3.0.0",
@@ -67,6 +67,7 @@
6767
"tailwindcss": "^3.2.6",
6868
"ts-loader": "^9.4.2",
6969
"type-fest": "^3.5.2",
70-
"typescript": "^4.9.4"
70+
"typescript": "^4.9.4",
71+
"webextension-polyfill": "^0.10.0"
7172
}
7273
}

pnpm-lock.yaml

Lines changed: 12 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/browser.ts

Whitespace-only changes.

src/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Browser from 'webextension-polyfill'
2+
13
export type LogseqCopliotConfig = {
24
logseqHost: string;
35
logseqAuthToken: string;
@@ -6,7 +8,7 @@ export type LogseqCopliotConfig = {
68
export const getLogseqCopliotConfig =
79
async (): Promise<LogseqCopliotConfig> => {
810
const { logseqHost = 'http://localhost:12315', logseqAuthToken = '' } =
9-
await chrome.storage.local.get();
11+
await Browser.storage.local.get();
1012
return {
1113
logseqHost,
1214
logseqAuthToken,
@@ -17,5 +19,5 @@ export const saveLogseqCopliotConfig = async (
1719
updates: Partial<LogseqCopliotConfig>,
1820
) => {
1921
console.log('saveLogseqCopliotConfig', updates);
20-
await chrome.storage.local.set(updates);
22+
await Browser.storage.local.set(updates);
2123
};

src/manifest.json.cjs

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,46 @@
11
const ReleaseFor = {
22
chrome: {
3+
manifest_version: 3,
34
key: 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnkAYeXnTWrNIu2h8D4xi9NHWLe0eTR3CX8DDw1c0qyCucaCKxkk/+gZcl89Ifyq5joXc/CeQrM3QVjrL1RAXrKZVqTNvBCUh1H1oJJ47nqkKKI6bNZVT8utjFTjDD1ZYXPYzQhsGuP/cY1wIrlhhIuawFW1h+UUwYlYQtS5FcjJ/RPrao+8KwJaS9p3Cei9rWXhE/PV19ZVOqOUx9ZSzj5/OYCB1u1VWFD5BlUbTXSbzyM/VvXZseAVruVy7oRHJ565AH/uPz2ZVL55Gz0LzcHw4HNRc2f+mSVAbHAuK7JDWtRlrZ3Fbav9qBrcVIAxTpnf5B2I2YMBMcu852Vkc3QIDAQAB',
5+
background: {
6+
service_worker: 'background.js',
7+
},
8+
web_accessible_resources: [
9+
{
10+
resources: ['content-script.css', 'assets/img/logo.png'],
11+
matches: [],
12+
},
13+
],
414
},
515
edge: {
6-
key: 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArg427MiWAPOW6ZtGWebRPWKJHv+IWBczKiyapsmdahLKaVk2YsHJdPhDIMTovcY91hTtwtW7lmJ8CLJHJNoosn52QZ6/qMu4zz5tcnjZA/FM4GN9BaybW/rXhR7LHY0WqKQ5UVYaJoYlNbQif5RnlUYRq2Z+q+bFdP6iJKHEljQjZwv84QFY6Pmln6iBKR7CDBOSr3X917FtzTwIiqnkfSm998+La1dUMfEzfq2qFYq1CuBEFHUtFNU7BCXmnIABefRQygdV9gVqSvyODt756Z2SmvEGhlzla/HVLf+ud84wEXqLnW3I0bvSTGExncxAkM/9fyKjHrGYuuFB9BgnqQIDAQAB',
16+
manifest_version: 3,
17+
background: {
18+
service_worker: 'background.js',
19+
},
20+
web_accessible_resources: [
21+
{
22+
resources: ['content-script.css', 'assets/img/logo.png'],
23+
matches: [],
24+
},
25+
],
26+
},
27+
firefox: {
28+
manifest_version: 2,
29+
background: {
30+
scripts: ['background.js'],
31+
},
32+
persistent: true,
33+
web_accessible_resources: ['content-script.css', 'assets/img/logo.png'],
734
},
835
};
936

1037
const build = (releaseFor) => {
1138
return {
1239
version: '0.0.5',
1340
author: 'eindex.lee@gmail.com',
14-
key: ReleaseFor[releaseFor]['key'],
15-
manifest_version: 3,
1641
name: 'Logseq Copilot',
1742
description:
1843
'Logseq Copilot, Connect with you logseq API server, bring your information when you browsing.',
19-
options_page: 'options.html',
20-
background: {
21-
service_worker: 'background.js',
22-
},
2344
chrome_url_overrides: {},
2445
icons: {
2546
192: 'assets/img/logo.png',
@@ -31,13 +52,13 @@ const build = (releaseFor) => {
3152
css: ['content-script.css'],
3253
},
3354
],
34-
web_accessible_resources: [
35-
{
36-
resources: ['content-script.css', 'assets/img/logo.png'],
37-
matches: [],
38-
},
39-
],
4055
permissions: ['storage'],
56+
options_ui: {
57+
page: 'options.html',
58+
browser_style: false,
59+
open_in_tab: true,
60+
},
61+
...ReleaseFor[releaseFor],
4162
};
4263
};
4364

src/pages/background/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import LogseqClient from '../logseq/client';
2+
import Browser from 'webextension-polyfill'
23

34
const logseqClient = new LogseqClient();
45

5-
chrome.runtime.onConnect.addListener((port) => {
6+
Browser.runtime.onConnect.addListener((port) => {
67
port.onMessage.addListener((msg) => {
78
if (msg.type === 'query') {
89
const promise = new Promise(async () => {
@@ -12,7 +13,7 @@ chrome.runtime.onConnect.addListener((port) => {
1213

1314
promise.catch((err) => console.error(err));
1415
} else if (msg.type === 'open-options') {
15-
chrome.runtime.openOptionsPage();
16+
Browser.runtime.openOptionsPage();
1617
}
1718
});
1819
});

src/pages/content/components/LogseqCopliot.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { LogseqSearchResult } from '../../../types/logseq-block';
33
import { LogseqResponseType } from '../../logseq/client';
44
import { LogseqBlock } from './LogseqBlock';
55
import { LogseqPageContent } from './LogseqPageContent';
6+
import Browser from 'webextension-polyfill'
67

78
type LogseqCopliotProps = {
8-
connect: chrome.runtime.Port;
9+
connect: Browser.Runtime.Port;
910
};
1011

1112
export const LogseqCopliot = ({ connect }: LogseqCopliotProps) => {

src/pages/content/components/LogseqPageContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LogseqPageContentType } from '../../types/logseq-block';
1+
import { LogseqPageContentType } from '../../../types/logseq-block';
22
import LogseqPageLink from './LogseqPage';
33

44
type LogseqPageContentProps = {

0 commit comments

Comments
 (0)