Greasy Fork is available in English.
Simply pulls from TrackerStatus API.
当前为
// ==UserScript==
// @name Is it Down?
// @version 0.2
// @namespace http://greasyfork.icu/en/users/113783-klattering
// @description Simply pulls from TrackerStatus API.
// @match https://redacted.ch/*
// ==/UserScript==
const isPostMod = false;
(function() {
'use strict';
console.log(document.body);
const trackerStatus = document.createElement('div');
if (isPostMod) {
trackerStatus.style.position = 'absolute';
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);
var request = new XMLHttpRequest();
request.open('POST', 'https://cors-anywhere.herokuapp.com/https://red.trackerstatus.info/api/all/', true)
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.background = '#a00e0e';
trackerStatus.style.padding = '.25rem';
console.log(service[0]);
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();
})();