Skip to content

Commit 73ba1dc

Browse files
committed
enhance: try to support brave
Signed-off-by: EINDEX <snowstarlbk@gmail.com>
1 parent 29a5355 commit 73ba1dc

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

src/components/logseq.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
}
44

55
.blockContent {
6-
@apply flex flex-col dark:prose-invert prose-sm whitespace-pre-wrap text-sm prose-img:w-full prose-p:my-0 prose-img:my-1;
6+
@apply flex flex-col prose-sm dark:prose-invert whitespace-pre-wrap text-sm prose-img:w-full prose-p:my-0 prose-img:my-1;
77
* {
88
@apply break-all text-sm;
99
}
@@ -22,7 +22,7 @@
2222
}
2323

2424
.pageContent {
25-
@apply flex flex-col gap-2 prose-sm whitespace-pre-wrap text-sm;
25+
@apply flex flex-col gap-2 prose-sm dark:prose-invert whitespace-pre-wrap text-sm;
2626
}
2727

2828
.pageContentFooter {

src/pages/content/index.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ async function run(
2727
) {
2828
console.debug('Logseq copliot', window.location.hostname);
2929

30-
if (searchEngine.isMatch()) {
31-
const query = searchEngine.getQuery();
32-
if (query) {
33-
console.log(`match ${typeof searchEngine}, query ${query}`);
34-
const container = await searchEngine.gotElement();
35-
await mount(container, query);
36-
}
30+
const query = searchEngine.getQuery();
31+
if (query) {
32+
console.log(`match ${typeof searchEngine}, query ${query}`);
33+
const container = await searchEngine.gotElement();
34+
await mount(container, query);
3735
}
3836
}
3937

src/pages/content/searchingEngines/searchingEngines.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ export class Bing extends SearchingEngine {
6060
gotElement(): Element {
6161
const container = document.createElement('li');
6262
const asideElement = document.querySelector('#b_context');
63-
console.log(asideElement)
63+
console.log(asideElement);
6464
container.className = 'b_ans';
65-
65+
6666
asideElement!.insertBefore(container, asideElement!.firstChild);
6767
return container;
6868
}
@@ -91,7 +91,6 @@ export class DuckDuckGo extends SearchingEngine {
9191

9292
export class Yandex extends SearchingEngine {
9393
isMatch(): boolean {
94-
9594
const match = window.location.hostname.match(/yandex\.(com|ru)$/);
9695
return !!match;
9796
}
@@ -186,7 +185,6 @@ export class Baidu extends SearchingEngine {
186185
return null;
187186
}
188187
}
189-
190188
export class Kagi extends SearchingEngine {
191189
isMatch(): boolean {
192190
const match = window.location.hostname.match(/kagi\.com$/g);
@@ -209,13 +207,37 @@ export class Kagi extends SearchingEngine {
209207
}
210208
}
211209

210+
// todo try to support brave search but the CSP ban the inline sytle.
211+
// export class Brave extends SearchingEngine {
212+
// isMatch(): boolean {
213+
// const match = window.location.hostname.match(/search\.brave\.com$/g);
214+
// return !!match;
215+
// }
216+
217+
// getQuery(): string | null {
218+
// const searchUrl = new URL(window.location.href);
219+
// const query = searchUrl.searchParams.get('q');
220+
221+
// return query;
222+
// }
223+
224+
// gotElement(): Element {
225+
// const container = document.createElement('div');
226+
// const asideElement = document.querySelector('#side-right');
227+
// container.style.paddingTop = '20px';
228+
// asideElement!.insertBefore(container, asideElement!.firstChild);
229+
// return container;
230+
// }
231+
// }
232+
212233
const searchEngins = [
213234
new Google(),
214235
new Bing(),
215236
new DuckDuckGo(),
216237
new Yandex(),
217238
new SearX(),
218239
new Kagi(),
240+
// new Brave(),
219241
new Baidu(),
220242
];
221243

0 commit comments

Comments
 (0)