// ==UserScript==
// @name Speedport JSON Parser
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Parse and display DSL information from JSON data
// @match http://192.168.0.1/data/Status.json
// @grant GM_addStyle
// @license MIT
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
// Add custom CSS styles to hide the JSON input and output
GM_addStyle(`
pre:first-child {
display: none !important;
}
body > pre {
visibility: hidden !important;
}
#dsl-info-container {
display: block !important;
}
#dsl-info-container h3 {
font-weight: bold;
}
#dsl-info-container p {
margin: 5px 0;
}
.dsl-info-title {
font-weight: bold;
}
`);
// Clear the screen
document.body.innerHTML = '';
// Fetch the JSON data
fetch("http://192.168.0.1/data/Status.json")
.then(response => response.json())
.then(data => {
// Find the DSL variables
const dslMaxDownstream = data.find(item => item.varid === "dsl_max_downstream");
const dslMaxUpstream = data.find(item => item.varid === "dsl_max_upstream");
const firmwareVersion = data.find(item => item.varid === "firmware_version");
const uptime = data.find(item => item.varid === "uptime");
const dslSyncTime = data.find(item => item.varid === "dsl_sync_time");
const dslDownstream = data.find(item => item.varid === "dsl_downstream");
const dslUpstream = data.find(item => item.varid === "dsl_upstream");
const snr = data.find(item => item.varid === "dsl_snr");
const attn = data.find(item => item.varid === "dsl_atnu");
// Create HTML elements to display the DSL information
const container = document.createElement("div");
container.id = "dsl-info-container";
container.style.margin = "10px";
container.style.padding = "10px";
container.style.border = "1px solid #ccc";
container.style.backgroundColor = "#f5f5f5";
const title = document.createElement("h3");
title.textContent = "Speedport VDSL Information";
const firmware = document.createElement("p");
firmware.innerHTML = "Firmware Version: " + (firmwareVersion ? firmwareVersion.varvalue : "N/A");
const uptimeInfo = document.createElement("p");
uptimeInfo.innerHTML = "Uptime: " + (uptime ? uptime.varvalue : "N/A");
const syncTime = document.createElement("p");
syncTime.innerHTML = "DSL Sync Time: " + (dslSyncTime ? dslSyncTime.varvalue : "N/A");
const downstream = document.createElement("p");
downstream.innerHTML = "DSL Downstream: " + (dslDownstream ? dslDownstream.varvalue + " Mbps" : "N/A");
const upstream = document.createElement("p");
upstream.innerHTML = "DSL Upstream: " + (dslUpstream ? dslUpstream.varvalue + " Mbps" : "N/A");
const maxDownstream = document.createElement("p");
maxDownstream.innerHTML = "DSL Max Downstream: " + (dslMaxDownstream ? dslMaxDownstream.varvalue + " Mbps" : "N/A");
const maxUpstream = document.createElement("p");
maxUpstream.innerHTML = "DSL Max Upstream: " + (dslMaxUpstream ? dslMaxUpstream.varvalue + " Mbps" : "N/A");
const snrInfo = document.createElement("p");
snrInfo.innerHTML = "Signal-to-Noise Ratio: " + (snr ? snr.varvalue : "N/A");
const attnInfo = document.createElement("p");
attnInfo.innerHTML = "Attenuation: " + (attn ? attn.varvalue : "N/A");
// Append the HTML elements to the page
container.appendChild(title);
container.appendChild(firmware);
container.appendChild(uptimeInfo);
container.appendChild(syncTime);
container.appendChild(downstream);
container.appendChild(upstream);
container.appendChild(maxDownstream);
container.appendChild(maxUpstream);
container.appendChild(snrInfo);
container.appendChild(attnInfo);
document.body.appendChild(container);
})
.catch(error => {
console.error("An error occurred while fetching or parsing the JSON data:", error);
});
})();