I am trying to write a userscript that (should) allow me to open a translator from any web page.
I append a button to the body of current web page, when clicking on it, it retrieve content from a translator (google, reverso...) and display it on the web page.
Here is the code:
var input = document.createElement("input");
input.type = "button";
input.value = "Open translator";
input.onclick = OpenTranslator;
document.body.appendChild(input);
function OpenTranslator(){
GetTranslatorContent();
}
function GetTranslatorContent(){
$.get('http://www.reverso.net/text_translation.aspx?lang=FR').then(function(responseData){
//alert("Got content");
//document.body.appendChild($('.translate-holder'));
var targetContent = $('.translate-holder');
if (targetContent != null && targetContent != undefined){
alert("Good so far");
}
})
}
However, I got this message when running this code:
So, my question is the folowing:
Is it possible to do what I am trying to do? (get content from a page to put it in an other)
If the answer to the previous question is yes, I am able to do so on pages I am not the admin? (because if I understood well, the error I get is caused because the page I am requesting is not allowing me to do what I want)
Thanks