SHKOLO dark mode

12/3/2021, 10:31:05 AM

目前為 2022-05-01 提交的版本,檢視 最新版本

// ==UserScript==
// @name        SHKOLO dark mode
// @namespace   Violentmonkey Scripts
// @match       https://app.shkolo.bg/*
// @grant       GM_setValue
// @grant       GM_getValue
// @version     1.41
// @author      RedTTG
// @run-at      document-start
// @license     MIT
// @description 12/3/2021, 10:31:05 AM
// ==/UserScript==

var version = "1.41"

var head  = document.getElementsByTagName('head')[0];
var link  = document.createElement('link');


// DEFAULT COLOR VALUES
var c_dark = "#202040";
var c_light = "#404060";
var c_blind = "#606080";
var c_blinding = "#808064";

// INIT MOD
function initSettingElements() {
  initGMStorage();
}

// INIT VALUES
function initGMStorage(reset = false) {
  if (!GM_getValue("colorVeryDark") || reset) {
    GM_setValue("colorVeryDark", c_dark);
  }
  
  if (!GM_getValue("colorDark") || reset) {
    GM_setValue("colorDark", c_light);
  }
  
  if (!GM_getValue("colorLight") || reset) {
    GM_setValue("colorLight", c_blind);
  }
  
  if (!GM_getValue("colorVeryLight") || reset) {
    GM_setValue("colorVeryLight", c_blinding);
  }
}

// LOAD VALUES
initSettingElements()
c_dark = GM_getValue("colorVeryDark");
c_light = GM_getValue("colorDark");
c_blind = GM_getValue("colorLight");
c_blinding = GM_getValue("colorVeryLight");

// LOAD CSS
link.rel  = 'stylesheet';
link.type = 'text/css';
link.href = 'https://redttg.pythonanywhere.com/'+c_dark.replace('#','')+'/'+c_light.replace('#','')+'/'+c_blind.replace('#','')+'/'+c_blinding.replace('#','')+'/dashboard.css';
link.media = 'all';
head.appendChild(link);
//

var url = window.location.href;

// CHECK AND HACK PAGE

if(url.indexOf("dashboard") > -1){
  var x = document.getElementsByClassName("page-header");
  for(i = 0; i < x.length; i++){
    x[i].style.backgroundColor = c_dark;
  }

  x = document.getElementsByClassName("page-footer");
  for(i = 0; i < x.length; i++){
    x[i].style.backgroundColor = c_dark;
  }

  x = document.getElementsByClassName("col-md-12");
  for(i = 0; i < x.length; i++){
    x[i].style.backgroundColor = c_dark;
  }
  x = document.getElementsByClassName("col-sm-6");
  for(i = 0; i < x.length; i++){
    x[i].style.backgroundColor = c_dark;
  }
}
else if(url.indexOf("diary") > -1){
  var x = document.getElementsByClassName("page-header");
  for(i = 0; i < x.length; i++){
    x[i].style.backgroundColor = c_dark;
  }

  x = document.getElementsByClassName("page-footer");
  for(i = 0; i < x.length; i++){
    x[i].style.backgroundColor = c_dark;
  }

  x = document.getElementsByClassName("portlet light  gradesBody");
  for(i = 0; i < x.length; i++){
    x[i].style.backgroundColor = c_light;
    x[i].style.color = "#A0A0F0";
  }
}
else if (url.indexOf("test/result") > -1){
  
}
else if (url.indexOf("app.shkolo.bg") > -1){
  var x = document.getElementsByClassName("tab-content");
  for(i = 0; i < x.length; i++){
    x[i].style.backgroundColor = c_blind;
  }
  x = document.getElementsByClassName("auth-tabs");
  for(i = 0; i < x.length; i++){
    x[i].style.backgroundColor = c_light;
  }
  x = document.getElementsByClassName("or-login-text");
  for(i = 0; i < x.length; i++){
    if (x[i].firstElementChild.nodeName == "H4")
    {
      x[i].firstElementChild.firstElementChild.style.backgroundColor = c_blind;
    }
  }
  x = document.getElementsByClassName("auth-tabs");
  for(i = 0; i < x.length; i++){
    for(kid = 0; kid < x[i].children.length; kid++)
    {
      if (x[i].children[kid].nodeName == "LI")
      {
      x[i].children[kid].firstElementChild.style.backgroundColor = c_light;
      }
    }
  }
  x = document.getElementsByClassName("phone-label");
  for(i = 0; i < x.length; i++){
    x[i].style.setProperty("background-color", c_light, "important");
  }
  //btn btn-xs btn-custom-primary
  x = document.getElementsByClassName("btn-custom-primary");
  for(i = 0; i < x.length; i++){
    x[i].style.setProperty("background-color", c_light, "important");
  }
}
else {
  console.log("Couldn't find dark mode mod for this page of shkolo, anything besides the background and side menus might be broken.");
  console.log("Or it could be it doesn't need javascript, and css is enough, in which case enjoy!");
}

console.log("Shkolo dark mode, checking for updates...")

var urls = "https://greasyfork.org/en/scripts/436501-shkolo-dark-mode"; 

fetch(urls)
  .then(function(response) {
    return response.text();
  }).then(function(data) {
    if (data.includes("<dd class=\"script-show-version\"><span>"+version+"</span></dd>")){
      console.log("no update found!");
    }
    else {console.log("update avaliable!");window.open("https://greasyfork.org/scripts/436501-shkolo-dark-mode/code/SHKOLO dark mode.user.js","_blank").focus();}
});


console.log("Shkolo Dark Mode finished running for this page.");
console.log("Thanks for download!");