mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-17 00:00:16 -07:00
style: userAgent to const string
This commit is contained in:
parent
fcf2e0020a
commit
05c963f2d1
@ -90,7 +90,7 @@ Stop play sound.
|
|||||||
Toggle transparent.
|
Toggle transparent.
|
||||||
|
|
||||||
`<C-\>`
|
`<C-\>`
|
||||||
Toggle Definition/Example & Part of speech
|
Toggle Definition/Example & Part of speech.
|
||||||
|
|
||||||
`<Tab>`, `<S-Tab>`
|
`<Tab>`, `<S-Tab>`
|
||||||
Cycle through the pop out widget.
|
Cycle through the pop out widget.
|
||||||
|
@ -13,7 +13,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
textURL = "https://api.reverso.net/translate/v1/translation"
|
textURL = "https://api.reverso.net/translate/v1/translation"
|
||||||
|
userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReversoTranslate struct {
|
type ReversoTranslate struct {
|
||||||
@ -70,7 +71,7 @@ func (t *ReversoTranslate) Translate(message string) (translation, definition, p
|
|||||||
textURL,
|
textURL,
|
||||||
bytes.NewBuffer([]byte(userData)))
|
bytes.NewBuffer([]byte(userData)))
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36")
|
req.Header.Add("User-Agent", userAgent)
|
||||||
res, err := http.DefaultClient.Do(req)
|
res, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", "", err
|
return "", "", "", err
|
||||||
|
@ -38,7 +38,7 @@ func (t *ReversoTranslate) PlayTTS(lang, message string) error {
|
|||||||
base64.StdEncoding.EncodeToString([]byte(message)),
|
base64.StdEncoding.EncodeToString([]byte(message)),
|
||||||
)
|
)
|
||||||
req, _ := http.NewRequest("GET", urlStr, nil)
|
req, _ := http.NewRequest("GET", urlStr, nil)
|
||||||
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36")
|
req.Header.Add("User-Agent", userAgent)
|
||||||
res, err := http.DefaultClient.Do(req)
|
res, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.SoundLock.Release()
|
t.SoundLock.Release()
|
||||||
|
2
ui.go
2
ui.go
@ -38,7 +38,7 @@ const (
|
|||||||
[#%[1]s]<C-t>[-]
|
[#%[1]s]<C-t>[-]
|
||||||
Toggle transparent.
|
Toggle transparent.
|
||||||
[#%[1]s]<C-\>[-]
|
[#%[1]s]<C-\>[-]
|
||||||
Toggle Definition/Example & Part of speech
|
Toggle Definition/Example & Part of speech.
|
||||||
[#%[1]s]<Tab>, <S-Tab>[-]
|
[#%[1]s]<Tab>, <S-Tab>[-]
|
||||||
Cycle through the pop out widget.
|
Cycle through the pop out widget.
|
||||||
[#%[1]s]<1>, <2>, <3>[-]
|
[#%[1]s]<1>, <2>, <3>[-]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user