Greasy Fork is available in English.

Tlačidlo prekladu komentárov na YouTube

Pridajte tlačidlo prekladu do komentárov na YouTube && Live Chat Translation

< Spätná väzba na Tlačidlo prekladu komentárov na YouTube

Hodnotenie: Dobré - skript funguje

Hello Linkwanggo
Can I ask you a few questions?
Did you use the API to translate the comments? If yes, how did you keep your API key secret from the public?
I'm new to JS and I want to create a script that uses the YouTube api to calculate playlist length, but I don't know how to keep the api key secret from the public.

Thanks.

§
Pridaný: 06.05.2023
Upravený: 06.05.2023

Hello Linkwanggo
Can I ask you a few questions?
Did you use the API to translate the comments? If yes, how did you keep your API key secret from the public?
I'm new to JS and I want to create a script that uses the YouTube api to calculate playlist length, but I don't know how to keep the api key secret from the public.

Thanks.

This script uses the public API from Google. No token No secret key required.

https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=${localeLang}&dj=1&dt=t&dt=rm&q=${q}

  • tl is the target language.
  • sl just set to auto.
  • q is the actual text you want to translate.
fetch(`https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=${localeLang}&dj=1&dt=t&dt=rm&q=${q}`)
                    .then(res => {
                        return res.json()
                    })
                    .then(result => {
                        let resultText = result.sentences.map((function (s) {
                            return "trans" in s ? s.trans : "";
                        })).join("")
                        return resultText.split("\n");
                    }).then(result=>{ console.log(result) })
linkwanggoAutor
§
Pridaný: 10.05.2023

That's right. No token No secret key.

Pridať odpoveď

Aby ste mohli pridať odpoveď, prihláste sa.