NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Twitter Tweet Auto Refresh // @namespace tako774.net // @version 0.1 // @description Auto refresh tweet if scrolled to top of page and not mouse over // @match https://twitter.com/* // @author nanashi(@tako774) // @license MIT // ==/UserScript== /* when all conditions below OK, do auto refresh 1) mouse is not on stream 2) permalink is not shown 3) scroll on top tweet */ var isMouseOnStream = false; var stream = document.querySelector("#stream-items-id"); var permalink = document.querySelector("#permalink-overlay"); timer(); stream.onmouseenter = function() { // console.log("[Twitter Tweet Auto Open] stream.onmouseenter"); isMouseOnStream = true; } stream.onmouseleave = function() { // console.log("[Twitter Tweet Auto Open] stream.onmouseleave"); isMouseOnStream = false; } window.onscroll = function () { check(); } function check() { // console.log("[Twitter Tweet Auto Open] checkPosition"); var isPermalinkOpen = permalink.style.display == "block"; // console.log("[Twitter Tweet Auto Open] isMouseOnStream: " + isMouseOnStream); // console.log("[Twitter Tweet Auto Open] isPermalinkOpen: " + isPermalinkOpen + " (" + permalink.style.display + ")"); // console.log("[Twitter Tweet Auto Open] window.pageYOffset: " + window.pageYOffset); if (!isMouseOnStream && !isPermalinkOpen && window.pageYOffset <= 140) { refreshTweet(); } } function refreshTweet() { // console.log("[Twitter Tweet Auto Open] openTweet"); var newTweetsBar = document.querySelector(".new-tweets-bar"); if (newTweetsBar) { newTweetsBar.click(); } } function timer() { check(); window.setTimeout(timer, 1000); }