0

我正在尝试编写一个脚本,将文本发送到带有我选择的消息的号码,但我被困在这部分。

我可以通过执行以下操作将一个号码传递到 Google Voice“收件人”字段:

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

但我无法通过以下方式将消息传递到“消息”字段:

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

源代码中的代码块如下所示:

http://pastebin.com/2LrhLZXc

谢谢!您的帮助将不胜感激。

4

1 回答 1

0

由于它是 Google,因此该页面可能大量基于 ajax。这意味着它gc-quicksms-text2不会立即出现。它是“text2”的事实表明这些<textarea>s 可能并不总是具有相同的 id;它们可能会自动编号。

所以尝试以下方法:

  1. 安装Firebug,如果你还没有。
  2. 加载并运行此脚本:

    // ==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. 代码应该填写 SMS 框并将每个新文本区域报告给Firebug 控制台。控制台报告什么?

于 2011-07-26T11:47:56.583 回答