// ==UserScript== // @name 8chan Status Checker // @namespace erin // @description check the current status of 8chan during downtime, and see if it's safe to post // @include *8ch.net/* // @version 0.1 // @grant none // ==/UserScript== function goChanStatus(){ var d, db, h, namespace, $, $$, version; d = document; db = document.body; h = document.getElementsByTagName('head')[0]; namespace = "chanStatus"; version = 0.1; $ = function(s, p){ if(!p || p == null){ p = db; } return p.querySelector(s); }; $$ = function(s, p){ if(!p || p == null){ p = db; } return p.querySelectorAll(s); }; $.elm = function(t, a, s){ var e = d.createElement(t); if(a){ for (key in a){ e.setAttribute(key, a[key]); } } if(s){ s.appendChild(e); } return e; }; $.htm = function(s, v){ if(v == null){ return s.innerHTML; }else{ s.innerHTML = v; } return s; }; $.time = function(t, c, l){ if(c == false){ return clearInterval(t); }else{ if(l == true){ return setInterval(function(){ c(); },t); }else{ return setTimeout(function(){ c(); },t); } } }; /*---------------------------------------------*/ $tar = {}; $tar['id'] = 'chanStatusTar'; $tar['style'] = 'position:fixed;bottom:150px;right:50px;border:1px solid;background:#d6daf0;z-index: 1000;padding:10px;border-radius:10px;text-align:center;'; $tar = $.elm('div', $tar, db); $.htm($tar, '

getting status...


(waiting)'); function getChanStatus(){ $.htm($('#chanStatusLoading'), '(connecting)'); var xhr = new XMLHttpRequest(); xhr.open("GET", window.location.href); xhr.onreadystatechange = function(){ if(xhr.readyState == 4) { $.htm($('#chanStatusLoading'), '(Updated)'); $.time(1500, function(){ $.htm($('#chanStatusLoading'), '(waiting)'); }, false); $.time(5000, function(){ getChanStatus(); }, false); if(xhr.status != 200) { $.htm($('#chanStatusHeading'), '

' + xhr.status + '

' + xhr.statusText + '

'); }else{ $.htm($('#chanStatusHeading'), '

200!

Post!

'); } } } xhr.send(); } getChanStatus(); } goChanStatus();