Greasy Fork is available in English.
Simply pulls from TrackerStatus API.
当前为
// ==UserScript==
// @name Is it Down?
// @version 0.3
// @namespace http://greasyfork.icu/en/users/113783-klattering
// @description Simply pulls from TrackerStatus API.
// @match https://redacted.ch/*
// ==/UserScript==
// Set to 'true' if you want the banner positioned on top absolutely.
const isAbsolute = false;
// Set to 'true' if using the kuro stylesheet.
const isKuro = false;
(function() {
'use strict';
const trackerStatus = document.createElement('div');
if (isAbsolute) {
trackerStatus.style.position = 'absolute';
trackerStatus.style.top = '0';
trackerStatus.style.width = '100%';
trackerStatus.style.boxSizing = 'border-box';
}
const message = document.createElement('p');
message.style.color = 'white';
message.style.textAlign = 'center';
message.style.fontWeight = 'bold';
message.style.margin = '0';
let messageText;
document.body.prepend(trackerStatus);
trackerStatus.append(message);
trackerStatus.style.display = 'none';
var request = new XMLHttpRequest();
request.open('POST', 'https://cors-anywhere.herokuapp.com/https://red.trackerstatus.info/api/all/', true);
request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
request.onload = function() {
var services = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400) {
Object.entries(services).forEach(service => {
if (service[1].Status === "0") {
trackerStatus.style.display = 'block';
if (isKuro) {
trackerStatus.style.position = 'absolute';
trackerStatus.style.top = '0';
trackerStatus.style.width = '100%';
trackerStatus.style.boxSizing = 'border-box';
document.body.style.position = 'relative';
document.body.style.top = '21px';
trackerStatus.style.top = '-26px';
}
trackerStatus.style.background = '#a00e0e';
trackerStatus.style.padding = '.25rem';
if (service[0] === "TrackerHTTP" || service[0] === "TrackerHTTPS") {
messageText = "The tracker is currently experiencing technical difficulties. <a style=\"color:white; text-decoration:underline\" href=\"https://red.trackerstatus.info\">More info</a>";
}
} else {
}
});
} else {
console.log('error')
}
message.innerHTML = messageText;
}
request.send();
})();