Search code examples
javascriptgoogle-chrome-extensiongoogle-translatecontent-script

How do I get untranslated data when the user views a page in Google Translate?


My extension use content-scripts to grab data from some pages. But, sometimes users use Google Translate on the page and I need original data.

How can I get it? The content-script grabs translated data.


Solution

  • To get the original (untranslated) version:

    1. Get its address from the translate-address input: Address bar

    2. Load that address in a hidden iframe.

    3. Grab the data you want from your new hidden iframe using the usual methods for dealing with iframes in Google-Chrome extensions.

    If the translated page has been modified by AJAX, the AJAX additions aren't available in the "Original" version, but Google-translate doesn't translate these either (for now) -- so just grab the AJAXed changes directly, from the translated-page iframe.