// ==UserScript== // @name Jira auto // @description Reload page every minute and scrolls down the page in the meanwhile // @version 1.1 // @grant none // @include https://*atlassian.net/*sprint* // @namespace https://greasyfork.org/users/193582 // @downloadURL https://update.greasyfork.icu/scripts/369880/Jira%20auto.user.js // @updateURL https://update.greasyfork.icu/scripts/369880/Jira%20auto.meta.js // ==/UserScript== function main ($) { // If ever the Jira box changes, search the correct id to bind the scroll to var window_id = '#ghx-pool'; var refresh_active = window.location.href.indexOf('refresh=false') === -1; var scroll_active = window.location.href.indexOf('scroll=false') === -1; // Refresh the page over time var numMinutes = 1; var timeout = numMinutes*60*1000; setTimeout(function() { if (refresh_active) { window.location.reload(true); } }, timeout); // Scroll down the page var pixels_per_scroll = $('html,body').height()/2; var interval = 5000; var previous_position = -1; setInterval(function() { if (scroll_active) { if (previous_position == $(window_id).scrollTop()) { $(window_id).animate({ scrollTop: 0 }, 500); } else { previous_position = $(window_id).scrollTop() $(window_id).animate({ scrollTop: $(window_id).scrollTop() + pixels_per_scroll }, 500); } } }, interval); function update_url() { var url = location.href; url = url.replace('&scroll=true', ''); url = url.replace('&scroll=false', ''); url = url.replace('&refresh=true', ''); url = url.replace('&refresh=false', ''); url += '&refresh='+refresh_active+'&scroll='+scroll_active; var stateObj = { foo: "bar" }; history.pushState(stateObj, "update_url", url); } function create_button() { if(document.body){ var refresh = document.createElement('span'); var scroll = document.createElement('span'); var css = document.createElement('style'); refresh.id = "refresh"; scroll.id = "scroll"; var refresh_svg = ''; var scroll_svg = ''; var css_refresh = '#refresh {' + ' opacity:1;' + ' -moz-transition-duration:0.2s;' + ' border-radius:5px;' + ' padding:5px;' + ' cursor:pointer;' + ' height:36px;' + ' margin-top:-24px;' + ' width:36px;' + ' position:fixed;' + ' right:10px;' + ' bottom:53%;' + ' z-index:1;' + ' background-color:green;' + ' color:white;' + ' } '; var css_scroll ='#scroll {' + ' opacity:1;' + ' -moz-transition-duration:0.2s;' + ' border-radius:5px;' + ' padding:5px;' + ' padding-bottom: 25px;' + ' cursor:pointer;' + ' height:36px;' + ' margin-top:-24px;' + ' width:36px;' + ' position:fixed;' + ' right:10px;' + ' top:53%;' + ' z-index:1;' + ' background-color:green;' + ' color:white;' + ' }'; var css_red = '.red { background-color:red !important; }'; $(css).text(css_refresh+' '+css_scroll+' '+css_red); $(refresh).html(refresh_svg); $(scroll).html(scroll_svg); $(refresh).toggleClass('red', !refresh_active); $(scroll).toggleClass('red', !scroll_active); refresh.addEventListener('click', function(e){ refresh_active = !refresh_active; $(refresh).toggleClass('red', !refresh_active); update_url(); }); scroll.addEventListener('click', function(e){ scroll_active = !scroll_active; $(scroll).toggleClass('red', !scroll_active); update_url(); }); document.body.appendChild(css); document.body.appendChild(refresh); document.body.appendChild(scroll); } } if(window != window.top) return 0; create_button(); } add_jQuery (main, "1.7.2"); function add_jQuery (callbackFn, jqVersion) { jqVersion = jqVersion || "1.7.2"; var D = document; var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement; var scriptNode = D.createElement ('script'); scriptNode.src = 'https://ajax.googleapis.com/ajax/libs/jquery/' + jqVersion + '/jquery.min.js'; scriptNode.addEventListener ("load", function () { var scriptNode = D.createElement ("script"); scriptNode.textContent = 'var gm_jQuery = jQuery.noConflict (true);\n' + '(' + callbackFn.toString () + ')(gm_jQuery);'; targ.appendChild (scriptNode); }, false); targ.appendChild (scriptNode); }