-
-
Save joshwand/05acf16e9ce986adedca1eaea7d5765d 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('new-tweets-bar')[0] || | |
document.getElementsByClassName('js-new-tweets-bar')[0]; | |
if (typeof updateButton != 'undefined') { | |
updating = true; | |
updateButton.onclick = function() { | |
updating = ! updating; | |
}; | |
} else { | |
updating = false; | |
} | |
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); | |
} | |
} | |
}, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment