diff --git a/src/assets/locale/en/settings.json b/src/assets/locale/en/settings.json
index d32dccf..20eb45c 100644
--- a/src/assets/locale/en/settings.json
+++ b/src/assets/locale/en/settings.json
@@ -74,6 +74,9 @@
"braveApi": {
"label": "Brave API Key",
"placeholder": "Enter your Brave API key"
+ },
+ "googleDomain": {
+ "label": "Google Domain"
}
},
"system": {
diff --git a/src/components/Option/Settings/search-mode.tsx b/src/components/Option/Settings/search-mode.tsx
index 932632b..f77149c 100644
--- a/src/components/Option/Settings/search-mode.tsx
+++ b/src/components/Option/Settings/search-mode.tsx
@@ -1,5 +1,6 @@
import { SaveButton } from "@/components/Common/SaveButton"
import { getSearchSettings, setSearchSettings } from "@/services/search"
+import { ALL_GOOGLE_DOMAINS } from "@/utils/google-domains"
import { SUPPORTED_SERACH_PROVIDERS } from "@/utils/search-provider"
import { useForm } from "@mantine/form"
import { useQuery } from "@tanstack/react-query"
@@ -18,6 +19,7 @@ export const SearchModeSettings = () => {
searxngURL: "",
searxngJSONMode: false,
braveApiKey: "",
+ googleDomain: ""
}
})
@@ -82,6 +84,32 @@ export const SearchModeSettings = () => {
>
)}
+ {form.values.searchProvider === "google" && (
+ <>
+
+
+ {t("generalSettings.webSearch.googleDomain.label")}
+
+
+
+
+ >
+ )}
{form.values.searchProvider === "brave-api" && (
<>
diff --git a/src/services/search.ts b/src/services/search.ts
index 73b3327..447d2b2 100644
--- a/src/services/search.ts
+++ b/src/services/search.ts
@@ -92,11 +92,21 @@ export const setBraveApiKey = async (braveApiKey: string) => {
await storage2.set("braveApiKey", braveApiKey)
}
+export const getGoogleDomain = async () => {
+ const domain = await storage2.get("searchGoogleDomain")
+ return domain || "google.com"
+}
+
+export const setGoogleDomain = async (domain: string) => {
+ await storage2.set("searchGoogleDomain", domain)
+}
+
export const getSearchSettings = async () => {
const [isSimpleInternetSearch, searchProvider, totalSearchResult, visitSpecificWebsite,
searxngURL,
searxngJSONMode,
- braveApiKey
+ braveApiKey,
+ googleDomain
] =
await Promise.all([
getIsSimpleInternetSearch(),
@@ -105,7 +115,8 @@ export const getSearchSettings = async () => {
getIsVisitSpecificWebsite(),
getSearxngURL(),
isSearxngJSONMode(),
- getBraveApiKey()
+ getBraveApiKey(),
+ getGoogleDomain()
])
return {
@@ -115,7 +126,8 @@ export const getSearchSettings = async () => {
visitSpecificWebsite,
searxngURL,
searxngJSONMode,
- braveApiKey
+ braveApiKey,
+ googleDomain
}
}
@@ -126,7 +138,8 @@ export const setSearchSettings = async ({
visitSpecificWebsite,
searxngJSONMode,
searxngURL,
- braveApiKey
+ braveApiKey,
+ googleDomain
}: {
isSimpleInternetSearch: boolean
searchProvider: string
@@ -134,7 +147,8 @@ export const setSearchSettings = async ({
visitSpecificWebsite: boolean
searxngURL: string
searxngJSONMode: boolean,
- braveApiKey: string
+ braveApiKey: string,
+ googleDomain: string
}) => {
await Promise.all([
setIsSimpleInternetSearch(isSimpleInternetSearch),
@@ -143,6 +157,7 @@ export const setSearchSettings = async ({
setIsVisitSpecificWebsite(visitSpecificWebsite),
setSearxngJSONMode(searxngJSONMode),
setSearxngURL(searxngURL),
- setBraveApiKey(braveApiKey)
+ setBraveApiKey(braveApiKey),
+ setGoogleDomain(googleDomain)
])
}
diff --git a/src/utils/google-domains.ts b/src/utils/google-domains.ts
new file mode 100644
index 0000000..66c419a
--- /dev/null
+++ b/src/utils/google-domains.ts
@@ -0,0 +1,188 @@
+export const ALL_GOOGLE_DOMAINS = [
+ "google.ad",
+ "google.ae",
+ "google.al",
+ "google.am",
+ "google.as",
+ "google.at",
+ "google.az",
+ "google.ba",
+ "google.be",
+ "google.bf",
+ "google.bg",
+ "google.bi",
+ "google.bj",
+ "google.bs",
+ "google.bt",
+ "google.by",
+ "google.ca",
+ "google.cd",
+ "google.cf",
+ "google.cg",
+ "google.ch",
+ "google.ci",
+ "google.cl",
+ "google.cm",
+ "google.co.ao",
+ "google.co.bw",
+ "google.co.ck",
+ "google.co.cr",
+ "google.co.id",
+ "google.co.il",
+ "google.co.in",
+ "google.co.jp",
+ "google.co.ke",
+ "google.co.kr",
+ "google.co.ls",
+ "google.co.ma",
+ "google.co.mz",
+ "google.co.nz",
+ "google.co.th",
+ "google.co.tz",
+ "google.co.ug",
+ "google.co.uk",
+ "google.co.uz",
+ "google.co.ve",
+ "google.co.vi",
+ "google.co.za",
+ "google.co.zm",
+ "google.co.zw",
+ "google.com",
+ "google.com.af",
+ "google.com.ag",
+ "google.com.ai",
+ "google.com.ar",
+ "google.com.au",
+ "google.com.bd",
+ "google.com.bh",
+ "google.com.bn",
+ "google.com.bo",
+ "google.com.br",
+ "google.com.bz",
+ "google.com.co",
+ "google.com.cu",
+ "google.com.cy",
+ "google.com.do",
+ "google.com.ec",
+ "google.com.eg",
+ "google.com.et",
+ "google.com.fj",
+ "google.com.gh",
+ "google.com.gi",
+ "google.com.gt",
+ "google.com.hk",
+ "google.com.jm",
+ "google.com.kh",
+ "google.com.kw",
+ "google.com.lb",
+ "google.com.ly",
+ "google.com.mm",
+ "google.com.mt",
+ "google.com.mx",
+ "google.com.my",
+ "google.com.na",
+ "google.com.ng",
+ "google.com.ni",
+ "google.com.np",
+ "google.com.om",
+ "google.com.pa",
+ "google.com.pe",
+ "google.com.pg",
+ "google.com.ph",
+ "google.com.pk",
+ "google.com.pr",
+ "google.com.py",
+ "google.com.qa",
+ "google.com.sa",
+ "google.com.sb",
+ "google.com.sg",
+ "google.com.sl",
+ "google.com.sv",
+ "google.com.tj",
+ "google.com.tr",
+ "google.com.tr",
+ "google.com.tw",
+ "google.com.ua",
+ "google.com.uy",
+ "google.com.vc",
+ "google.com.vn",
+ "google.cv",
+ "google.cz",
+ "google.de",
+ "google.dj",
+ "google.dk",
+ "google.dm",
+ "google.dz",
+ "google.ee",
+ "google.es",
+ "google.fi",
+ "google.fm",
+ "google.fr",
+ "google.ga",
+ "google.ge",
+ "google.gl",
+ "google.gm",
+ "google.gp",
+ "google.gr",
+ "google.gy",
+ "google.hn",
+ "google.hr",
+ "google.ht",
+ "google.hu",
+ "google.ie",
+ "google.iq",
+ "google.is",
+ "google.it",
+ "google.je",
+ "google.jo",
+ "google.kg",
+ "google.ki",
+ "google.kz",
+ "google.la",
+ "google.li",
+ "google.lk",
+ "google.lt",
+ "google.lu",
+ "google.lv",
+ "google.md",
+ "google.mg",
+ "google.mk",
+ "google.ml",
+ "google.mn",
+ "google.ms",
+ "google.mu",
+ "google.mv",
+ "google.mw",
+ "google.ne",
+ "google.nl",
+ "google.no",
+ "google.nr",
+ "google.nu",
+ "google.pl",
+ "google.ps",
+ "google.pt",
+ "google.ro",
+ "google.rs",
+ "google.ru",
+ "google.rw",
+ "google.sc",
+ "google.se",
+ "google.sh",
+ "google.si",
+ "google.sk",
+ "google.sm",
+ "google.sn",
+ "google.so",
+ "google.sr",
+ "google.td",
+ "google.tg",
+ "google.tk",
+ "google.tl",
+ "google.tm",
+ "google.tn",
+ "google.to",
+ "google.tt",
+ "google.vg",
+ "google.vu",
+ "google.ws"
+]
\ No newline at end of file
diff --git a/src/web/search-engines/google.ts b/src/web/search-engines/google.ts
index 51dd9a3..8c0a92d 100644
--- a/src/web/search-engines/google.ts
+++ b/src/web/search-engines/google.ts
@@ -1,5 +1,6 @@
import { pageAssistEmbeddingModel } from "@/models/embedding"
import {
+ getGoogleDomain,
getIsSimpleInternetSearch,
totalSearchResults
} from "@/services/search"
@@ -18,15 +19,16 @@ import {
export const localGoogleSearch = async (query: string) => {
+ const baseGoogleDomain = await getGoogleDomain()
await urlRewriteRuntime(
- cleanUrl("https://www.google.com/search?hl=en&q=" + query),
+ cleanUrl(`https://www.${baseGoogleDomain}/search?hl=en&q=` + query),
"google"
)
const abortController = new AbortController()
setTimeout(() => abortController.abort(), 10000)
const htmlString = await fetch(
- "https://www.google.com/search?hl=en&q=" + query,
+ `https://www.${baseGoogleDomain}/search?hl=en&q=` + query,
{
signal: abortController.signal
}