使用 google chrome 控制台发送多条消息

Send multiple messages using google chrome console

我想在我的浏览器游戏中测试消息功能。我想也许我可以在 Chrome 控制台中自动发送消息,而不是手动向 50 个测试帐户发送消息。

首先我会做一个for循环。

 for (i=0; i > 50; i++)
    {

     //to do
    }

我会用我的游戏link填写发送表格 game.php?page=messages&mode=write&id=1&subject=message_test ID 用于用户 ID,Subject 填充主题区域。

在我的消息发送模板中,我使用此 JavaScript 发送消息

function check(){
    if($('#text').val().length == 0) {
        alert('{$LNG.mg_empty_text}');
        return false;
    } else {
        $('submit').attr('disabled','disabled');
        $.post('game.php?page=messages&mode=send&id={$id}&ajax=1', $('#message').serialize(), function(data) {
            alert(data);
            parent.$.fancybox.close();
            return true;
        });
    }
}

也许有人可以帮助我如何使用 Chrome 控制台执行功能并发送消息?也许给我一个适当的教程。

如果你想"export"你的功能到控制台进入google chrome或其他开发工具,你可以将它导出到一个window对象,所以

// create a namespace to have all functions under your custom namespace
window.MyCustomNS = {};
window.MyCustomNS.yourFunction = function(id, dataObject) {
if($('#text').val().length == 0) {
    alert('{$LNG.mg_empty_text}');
    return false;
} else {
    $('submit').attr('disabled','disabled');
    $.post('game.php?page=messages&mode=send&id=' +  + '&ajax=1', $.param(dataObject), function(data) {
        alert(data);
        parent.$.fancybox.close();
        return true;
    });
}
};

然后进入控制台试试这个,

window.MyCustomNS.yourFunction('YOUR_ID', { name: 'some parameter', another: 'another parameter' });