Greasy Fork is available in English.

Nút dịch bình luận YouTube

Thêm nút dịch vào nhận xét trên YouTube && Live Chat Translation

< Feedback on Nút dịch bình luận YouTube

Review: Good - script works

§
Posted: 05-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.

§
Posted: 06-05-2023
Edited: 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) })
linkwanggoTác giả
§
Posted: 10-05-2023

That's right. No token No secret key.

Post reply

Đăng nhập để bình luận