Skip to content

Commit

Permalink
added auto click on the translate button
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Cristian Petcu committed May 13, 2017
1 parent ee3053f commit 0bf0810
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "__MSG_appName__",
"version": "1.2.0",
"version": "1.2.2",
"homepage_url": "https://github.com/andreicristianpetcu/google_translate_this",
"manifest_version": 2,
"description": "__MSG_appDescription__",
Expand Down
9 changes: 7 additions & 2 deletions scripts/inject_google_translate_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ document.body.appendChild(gtdiv);

var googleTranslateElementInitCode = "function(){ \
new google.translate.TranslateElement({pageLanguage: 'auto', autoDisplay: true}, 'google_translate_element'); \
setTimeout(function(){ \
console.log('translating'); \
var iframe = document.getElementsByClassName('goog-te-banner-frame')[0]; \
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document; \
iframeDocument.getElementsByClassName('goog-te-button')[0].children[0].children[0].click(); \
console.log('finished translation'); \
}, 1000); \
}";

var globalFunctionScript = document.createElement('script');
Expand All @@ -16,5 +23,3 @@ var gtScript = document.createElement('script');
gtScript.type = "text/javascript";
gtScript.src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit";
document.getElementsByTagName('head')[0].appendChild(gtScript);

//document.getElementsByClassName("goog-te-button")[0].children[0].children[0].click();
4 changes: 3 additions & 1 deletion updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
{ "version": "1.0.3",
"update_link": "https://github.com/andreicristianpetcu/google_translate_this/releases/download/v1.0.3/google_translate_this_page-1.0.3-an.fx.xpi" },
{ "version": "1.2.0",
"update_link": "https://github.com/andreicristianpetcu/google_translate_this/releases/download/v1.2.0/google_translate_this_page-1.2.0-an.fx.xpi" }
"update_link": "https://github.com/andreicristianpetcu/google_translate_this/releases/download/v1.2.0/google_translate_this_page-1.2.0-an.fx.xpi" },
{ "version": "1.2.2",
"update_link": "https://github.com/andreicristianpetcu/google_translate_this/releases/download/v1.2.2/google_translate_this_page-1.2.2-an.fx.xpi" }
]
}
}
Expand Down

0 comments on commit 0bf0810

Please sign in to comment.