Skip to content

Instantly share code, notes, and snippets.

@matthewlmcclure
Created January 15, 2012 05:16
Show Gist options
  • Save matthewlmcclure/1614463 to your computer and use it in GitHub Desktop.
Save matthewlmcclure/1614463 to your computer and use it in GitHub Desktop.
Load new tweets automatically.
(function() {
// ==UserScript==
// @name Load new tweets automatically.
// @namespace http://matthewlmcclure.com
// @match https://twitter.com/*
// ==/UserScript==
var updating = true;
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
window.setInterval(function () {
var updateButton = document.getElementsByClassName('js-timeline-title')[0] ||
document.getElementsByClassName('js-stream-title')[0];
updateButton.onclick = function() {
updating = ! updating;
}
if (updating) {
updateButton.innerText = 'Stop updating';
var elements = document.getElementsByClassName('new-tweets-bar');
var newTweetsBar;
if (elements.length === 1 && window.pageYOffset < 100) {
newTweetsBar = elements[0];
newTweetsBar.dispatchEvent(event);
}
} else {
updateButton.innerText = 'Update automatically';
}
}, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment