Last active
February 18, 2020 16:52
-
-
Save rsarai/bacb20f782a9266a82a28c3ed52db942 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ==UserScript== | |
// @name Airflow auto-reload | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author Rebeca | |
// @match http://localhost:3000/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const airflow = () => { | |
if (document.title.indexOf('Airflow') === -1) { return; } | |
if (window.location.pathname === '/admin/airflow/log') { | |
window.onscroll = (() => { | |
let timeout; | |
return () => { | |
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { | |
// eslint-disable-next-line no-restricted-globals | |
timeout = setTimeout(() => { location.reload(true); }, 3000); | |
} else if (timeout) { | |
clearTimeout(timeout); | |
timeout = null; | |
} | |
}; | |
})(); | |
window.scrollTo(0, document.body.scrollHeight); | |
window.onscroll(); | |
} else if (window.location.pathname === '/admin/airflow/tree') { | |
if (document.getElementsByClassName('running').length !== 0) { | |
// eslint-disable-next-line no-restricted-globals | |
setTimeout(() => { location.reload(true); }, 3000); | |
} | |
} else if (window.location.pathname === '/admin/airflow/graph') { | |
const is_running = document.getElementsByClassName('running').length !== 0; | |
const is_up_for_retry = document.getElementsByClassName('up_for_retry').length !== 0; | |
const is_up_for_reschedule = document.getElementsByClassName('up_for_reschedule').length !== 0; | |
const is_queued = document.getElementsByClassName('queued').length !== 0; | |
const is_no_status = document.getElementsByClassName('no_status').length !== 0; | |
if (is_running || is_up_for_retry || is_up_for_reschedule || is_queued || is_no_status) { | |
// eslint-disable-next-line no-restricted-globals | |
setTimeout(() => { location.reload(true); }, 3000); | |
} | |
} | |
}; | |
// document.addEventListener('DOMContentLoaded', airflow, false); | |
airflow(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment