0

I am trying to write a script that will send a text to a number with a message of my choosing, but I am stuck on this part.

I am able to pass a number into the Google Voice "To" field by doing the following:

document.getElementById("gc-quicksms-number").value = number;

but I am unable to pass a message into the "Message" field with this:

document.getElementById("gc-quicksms-text2").value = "Error detected";

The block of code in the source looks like this:

http://pastebin.com/2LrhLZXc

Thank you! Your assistance will be greatly appreciated.

loopx
  • 1
  • 2
  • `document.getElementById("gc-quicksms-text2").value = "Error detected";` works perfectly fine in Firefox. There must be something else in the script. Paste or link to its source code. – Brock Adams Jul 23 '11 at 22:28
  • I only have these two lines in the script, and the first part works fine but not the second. – loopx Jul 23 '11 at 22:30
  • in a test script I mean, just these two lines, the To field is populated fine but not the Message – loopx Jul 23 '11 at 22:49

1 Answers1

0

Since it's Google, that page is probably heavily ajax based. Which means that gc-quicksms-text2 is not there right away. The fact that it's "text2" suggests that these <textarea>s may not always have the same id; they may be auto numbered.

So try the following:

  1. Install Firebug, if you haven't already.
  2. Load and run this script:

    // ==UserScript==
    // @name            _Google voice starter
    // @include         http://www.google.com/googlevoice/*
    // @require         http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
    // ==/UserScript==
    
    unsafeWindow.console.clear();
    var report = unsafeWindow.console.info;
    report ('GM Script start');
    
    
    var timerHandle = setInterval (checkForSMS_Textboxes, 777);
    
    function checkForSMS_Textboxes () {
        var SMS_Textboxes   = $('textarea.gc-quicksms-text');
        var SMS_Textboxes   = $('textarea');
    
        var newTB_ids       = SMS_Textboxes.map ( function () {
                                var jThis   = $(this);
                                if (jThis.prop ('bFoundBefore') )
                                    return null;
                                else {
                                    jThis.prop ('bFoundBefore', true);
                                    jThis.text ('Can you see me?');
                                    return this.id ? this.id : 'null';
                                }
                            } ).get ().join (', ');
    
        if (newTB_ids)
            report ('Found new textarea(s): ', newTB_ids);
    }
    
  3. The code should fill in the SMS boxes and report each new text area to the Firebug console. What does the console report?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295