Citysatoshi and Cannonsatoshi Alerter

Show fuels and foods in tabs and show a popup when your fuels is below 50% and 25%

  1. // ==UserScript==
  2. // @name Citysatoshi and Cannonsatoshi Alerter
  3. // @description Show fuels and foods in tabs and show a popup when your fuels is below 50% and 25%
  4. // @namespace HPrivakosScripts
  5. // @include *://citysatoshi.com/*
  6. // @include *://cannonsatoshi.com/*
  7. // @version 1.02
  8. // @grant none
  9. // @author HPrivakos
  10. // ==/UserScript==
  11.  
  12. var maximum = $(".text_max")[0].innerHTML.substring(5, 100);
  13. console.log(maximum + "->");
  14. var max = maximum.replace(/ /g, "");
  15. console.log("To ->" + max);
  16. var VarName = "None";
  17. var VarFuel = "None";
  18. var FuelName = "None";
  19. var alert50 = 0;
  20. var alert25 = 0;
  21. console.log(max);
  22.  
  23. if(document.domain == "citysatoshi.com"){
  24. var FuelName = "bread";
  25. var VarName = "CitySatoshi";
  26. var VarFuel = "warehouse of bread";
  27. }
  28. else{
  29. var FuelName = "gallons";
  30. var VarName = "CannonSatoshi";
  31. var VarFuel = "tank of oil";
  32. }
  33.  
  34. Fuel();
  35.  
  36. function Fuel(){
  37. var fuel2 = document.getElementById('fuel_value').innerHTML;
  38. var fuel = fuel2.replace(/ /g, "");
  39. fuel = fuel.replace(/,/g, "");
  40. var percentage = fuel/max * 100;
  41. var percentageround = Math.round(percentage);
  42. console.log(fuel);
  43. document.title = fuel + " " + FuelName + " - " + percentageround + "% - " + VarName;
  44. setTimeout(function(){ Fuel(); }, 5000);
  45. if(percentageround<51 && percentageround>46 && alert50 === 0){
  46. alert("Your " + VarFuel + " is below 50%");
  47. alert50 = alert50 + 1;
  48. }
  49. else if(percentageround<26 && percentageround>21 && alert25 === 0){
  50. alert("Your " + VarFuel + " is below 25%");
  51. alert25 = alert25 + 1;
  52. }
  53. }