Twitter Mobile - Enter to send message

This script allows user to send message by pressing the enter key on Twitter Mobile DM

目前為 2016-06-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Twitter Mobile - Enter to send message
// @version      0.1
// @description  This script allows user to send message by pressing the enter key on Twitter Mobile DM
// @author       himalay
// @namespace    https://himalay.com.np
// @include     *://mobile.twitter.com/messages/*
// @run-at document-idle
// ==/UserScript==

var elCheckInterval = window.setInterval (function() {
    var dmInput = document.querySelector('[data-testid="dmComposerTextInput"]');
    if (dmInput) {
        dmInput.addEventListener('keydown', function(e) {
            if (!e) e = window.event;
            if (e.keyCode === 13) {
                e.preventDefault(); document.querySelector('[data-testid="dmComposerSendButton"]').click();
            }
        }, false);
        window.clearInterval(elCheckInterval);
    }
}, 500);