Skip to content

Instantly share code, notes, and snippets.

@boxysean
Created March 22, 2012 20:36
Show Gist options
  • Save boxysean/2163853 to your computer and use it in GitHub Desktop.
Save boxysean/2163853 to your computer and use it in GitHub Desktop.
Twitter Autosubmit

Description

Auto submits tweet on "Home" view of twitter.com when 140 characters is reached, keeps textarea in focus, and keeps scrollbar at topmost position.

Developed and tested on OS X 10.5.8, Firefox version 11.0, Greasemonkey 0.9.18.

By Sean McIntyre (email)

Installation Guide

  1. Install and/or update Firefox web browser to version 11.0+. Link.

  2. Install and/or update Greasemonkey (Firefox extension) to version 0.9.18+. Follow this link in Firefox web browser. Click "+ Add to Firefox" button and follow the instructions. Restart Firefox when prompted.

  3. Install twitter_autosubmit.user.js script by clicking here. Click install button when it is available.

  4. Open Firefox Add-ons manager by selecting Tools -> Add-ons. Select User Scripts from left bar. Ensure that Twitter Autosubmit is installed and is enabled. Click the Enable button if the script is disabled. (See following image for how it should look when installed.)

User Scripts Add-ons manager with Twitter Autocomplete installed and enabled

  1. In Firefox, go to Twitter and log in to your account. Test that the script is working by, in the Twitter Home view, typing 140 characters in the top-left tweet box. It will tweet when the 140th character is typed.

  2. If there are any issues, do not hesitate to contact Sean by email with your phone number and he will quickly respond.

// ==UserScript==
// @name Twitter Autosubmit
// @namespace http://www.boxysean.com
// @description Auto submits tweet on Twitter webpage when 140 characters is reached
// @include http://twitter.com/*
// @include https://twitter.com/*
// ==/UserScript==
function reset(tweetBox) {
tweetBox.blur();
tweetBox.focus();
tweetBox.value = "";
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
function perpetualStealFocus() {
setTimeout(function() {
document.querySelector('.tweet-user').querySelector('.twitter-anywhere-tweet-box-editor').focus();
document.body.scrollTop = document.documentElement.scrollTop = 0;
perpetualStealFocus();
}, 2000);
}
perpetualStealFocus();
window.addEventListener('keypress', function(e) {
var ae = document.activeElement;
if (ae.className === 'twitter-anywhere-tweet-box-editor') {
var len = document.activeElement.value.length;
if (len === 139) {
var button = ae.parentNode.parentNode.parentNode.querySelector('.tweet-button');
button.click();
setTimeout(function() { reset(ae) }, 1000);
}
}
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment