Shift + Enter to send tweet

Press shift and enter at the same time to send a tweet!

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name     Shift + Enter to send tweet
// @description Press shift and enter at the same time to send a tweet!
// @author   Thestickman391
// @version  1
// @homepageURL https://gist.github.com/Thestickman391/d5e40959eeee7c41b986c06457ec5575
// @include  https://twitter.*/*
// @grant    none
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require  https://greasyfork.org/scripts/31940-waitforkeyelements/code/waitForKeyElements.js
// @namespace https://greasyfork.org/users/710818
// ==/UserScript==

waitForKeyElements ('[data-testid="tweetButton"]', tweetButtonLoaded);

function tweetButtonLoaded (tweetButton)
{
  $('[data-testid="tweetTextarea_0"]').keydown(function(e){
    console.log(e);
    if (e.keyCode == 13 && e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
      $(tweetButton).click();
    }
  })
}