Skip to content

Instantly share code, notes, and snippets.

@joshwand
Forked from matthewlmcclure/com.twitter.user.js
Created July 19, 2016 19:19
Show Gist options
  • Save joshwand/05acf16e9ce986adedca1eaea7d5765d to your computer and use it in GitHub Desktop.
Save joshwand/05acf16e9ce986adedca1eaea7d5765d 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('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