Skip to content

Instantly share code, notes, and snippets.

@herejia
Created August 7, 2015 13:49
Show Gist options
  • Save herejia/6d30c61febef4c1d5877 to your computer and use it in GitHub Desktop.
Save herejia/6d30c61febef4c1d5877 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name scroll bottom
// @namespace net.herezia
// @include http://srv-hudson:8080/job/*
// @version 1
// @grant none
// ==/UserScript==
var intervalId = null;
var button = document.createElement('input');
with(button) {
setAttribute('value', 'Auto-scroll bottom');
setAttribute('type', 'button');
setStyle('position: fixed; z-index: 1000; top: 0; right: 0');
}
button.addEventListener('click', function() {
if (!intervalId) {
intervalId = setInterval(function() { window.scrollTo(0, document.getElementById('main-panel-content').offsetHeight); }, 500);
button.setValue('Stop');
} else {
button.setValue('Start');
clearInterval(intervalId);
intervalId = null;
}
});
document.getElementsByTagName('body')[0].appendChild(button);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment