low-tech-solar-stats.user.js (1373B)
- // ==UserScript==
- // @name Low-Tech JS
- // @namespace https://hacktivis.me/
- // @description jQuery-less JS version to display the power stats on the page
- // @include https://solar.lowtechmagazine.com/*
- // @version 0.0.2
- // @grant none
- // ==/UserScript==
- // Upstream should try to do it via CSS instead IMO
- document.getElementById("menu").child.style.display = "inline-block";
- var url = "https://solar.lowtechmagazine.com/api/stats.json";
- // var weather_ignore = ["snow", "sleet", "wind", "fog"];
- // var weather_data = ["today", "tomorrow", "day_after_t"];
- // var weather_days = ["today", "tomorrow", "day after tomorrow"];
- // var forecast = "";
- var request = new XMLHttpRequest();
- request.onload = function() {
- res = JSON.parse(request.response);
- // @DONE: Location + Hardware
- document.getElementById("dashboard_level").innerText = res.bat_capacity;
- document.getElementById("battery").innerText = res.bat_capacity;
- document.getElementById("battery").style.height = res.bat_capacity;
- document.getElementById("time").innerText = res.local_time;
- document.getElementById("uptime").innerText = res.uptime;
- if(res.ac_power == "0W") {
- document.getElementById("power").innerText = res.bat_power;
- } else {
- document.getElementById("power").innerText = res.ac_power;
- }
- // @TODO: Forecast
- }
- request.open('GET', url, true)
- request.send(null)