Created
January 15, 2012 05:16
-
-
Save matthewlmcclure/1614463 to your computer and use it in GitHub Desktop.
Load new tweets automatically.
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
(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