Greasy Fork is available in English.

YouTube-kommenttien käännöspainike

Lisää käännöspainike YouTube-kommentteihin && Live Chat Translation

< Feedback on YouTube-kommenttien käännöspainike

Review: Good - script works

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.

§
Posted: 6.5.2023
Edited: 6.5.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) })
linkwanggoAuthor
§
Posted: 10.5.2023

That's right. No token No secret key.

Post reply

Sign in to post a reply.