Created
January 19, 2011 16:45
-
-
Save higeorange/786428 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @include http://twitter.com/* | |
// ==/UserScript== | |
window.addEventListener('DOMNodeInserted', function (e) { | |
var f = e.target.firstElementChild; | |
if(f && f.className == 'main-content') { | |
addTweetEvent(f.querySelector('.twitter-anywhere-tweet-box-editor'), f.querySelector('.tweet-button')); | |
} else if(e.target.className == 'twitter-anywhere-tweet-box-editor') { | |
addTweetEvent(e.target, document.querySelector('.twttr-dialog-container').querySelector('.tweet-button')) | |
} | |
function addTweetEvent(textarea, tweet_button) { | |
var textarea_focus = false; | |
textarea.addEventListener('focus', function() { textarea_focus = true; }, false); | |
textarea.addEventListener('blur', function() { textarea_focus = false; }, false); | |
textarea.addEventListener('keyup', function(e) { | |
if(e.keyCode == 13 && e.ctrlKey && textarea_focus) { | |
e.preventDefault(); | |
tweet_button.click(); | |
} | |
}, false); | |
} | |
}, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @include http://twitter.com/* | |
// ==/UserScript== | |
window.addEventListener('keypress', function(e) { | |
if(e.keyCode === 13 && e.ctrlKey && document.activeElement.className === 'twitter-anywhere-tweet-box-editor') { | |
var button = document.activeElement.parentNode.parentNode.parentNode.querySelector('.tweet-button'); | |
button.click(); | |
} | |
}, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment