Jonathan R.
Jonathan R.

Reputation: 221

Chrome extension - Getting text typed by user while composing mail

I'm trying to write an extension that takes text typed by user in real time. I've succeeded to take text from textarea etc in web pages. but not from composed mail area in gmail, I believe that the main problem is that the composed mail box appears only after clicking on the 'compose' button.

This is my code:

$( document ).ready( function() {
    $('div, input, textarea, html, iframe').focus( function() {
        $(this).keyup(function(){
            var text = $(this).val();
            console.log("text: " + text );

        });
    });
 });

Can someone help me understand how to manage in taking the text from the composed message body?

Upvotes: 0

Views: 134

Answers (1)

Steve Campbell
Steve Campbell

Reputation: 3605

iframe is different. You will probably have to inject your code into the iframe separately for it to work, and that code would be somewhat sandboxed from the rest of the code (i.e. like a separate page).

It is not clear how you are injecting the javascript, but the documentation at https://developer.chrome.com/extensions/tabs#method-executeScript shows that you can use allFrames parameter property to specify that you want to include it on frames (including iframes)).

Upvotes: 1

Related Questions