Answer the question
In order to leave comments, you need to log in
Developing an extension for chrome(Word Translator)?
Good afternoon, the task is to develop an extension for chrome. the essence of which. Highlight a word on a page, translate it, and then replace it on the page. I ask for help on how to implement this, especially replacing the text inside the page. I will be grateful for any help.
Recently, yandex and google translate have become paid. Are there other free machine translation services?
Answer the question
In order to leave comments, you need to log in
Chrome has a built-in translator extension (from google). Moreover, it is free:
If you need to translate a lot of text, then select -> RMB -> Google translator.
especially replacing text inside the page
var a = document.getElementsByTagName('a')[0];
a.innerHTML = a.innerHTML.replace(/Play!/,'Stop!');
An interesting task, probably, I would try this:
Take the word using the context API, translate it, pass it to contentScript, replace the word.
The difficulty is to know exactly where to replace. I suppose that you need to take a whole paragraph of this word, and using the search for a substring or in some other way replace it.
I don’t know what opportunities the context API has, maybe it can or can not catch the tag.
It's just like that, thoughts)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question