logo

scripts

A bunch of scripts, some to be moved to their own repository git clone https://anongit.hacktivis.me/git/scripts.git/

low-tech-solar-stats.user.js (1373B)


  1. // ==UserScript==
  2. // @name Low-Tech JS
  3. // @namespace https://hacktivis.me/
  4. // @description jQuery-less JS version to display the power stats on the page
  5. // @include https://solar.lowtechmagazine.com/*
  6. // @version 0.0.2
  7. // @grant none
  8. // ==/UserScript==
  9. // Upstream should try to do it via CSS instead IMO
  10. document.getElementById("menu").child.style.display = "inline-block";
  11. var url = "https://solar.lowtechmagazine.com/api/stats.json";
  12. // var weather_ignore = ["snow", "sleet", "wind", "fog"];
  13. // var weather_data = ["today", "tomorrow", "day_after_t"];
  14. // var weather_days = ["today", "tomorrow", "day after tomorrow"];
  15. // var forecast = "";
  16. var request = new XMLHttpRequest();
  17. request.onload = function() {
  18. res = JSON.parse(request.response);
  19. // @DONE: Location + Hardware
  20. document.getElementById("dashboard_level").innerText = res.bat_capacity;
  21. document.getElementById("battery").innerText = res.bat_capacity;
  22. document.getElementById("battery").style.height = res.bat_capacity;
  23. document.getElementById("time").innerText = res.local_time;
  24. document.getElementById("uptime").innerText = res.uptime;
  25. if(res.ac_power == "0W") {
  26. document.getElementById("power").innerText = res.bat_power;
  27. } else {
  28. document.getElementById("power").innerText = res.ac_power;
  29. }
  30. // @TODO: Forecast
  31. }
  32. request.open('GET', url, true)
  33. request.send(null)