vjudge black theme

black color scheme, unthemed

La data de 01-06-2022. Vezi ultima versiune.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         vjudge black theme
// @namespace    https://github.com/notwatermango/vjudge-dark-theme
// @version      0.1
// @description  black color scheme, unthemed
// @author       notwatermango
// @match        https://vjudge.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=vjudge.net
// @grant        GM_addStyle
// ==/UserScript==

(function () {
  'use strict';
  var colors = {
    superblack: '#0A0908'
  };
  function overrideStyleAttribute(elm, prop, value) {
    elm.setAttribute("style", elm.getAttribute("style") + `; ${prop}: ${value} !important; `);
  }

  function applyFuncWhenElmLoaded(sel, func, delay = 100) {
    var elm = document.querySelectorAll(sel);
    if (!elm || elm.length == 0) return setTimeout(applyFuncWhenElmLoaded, delay, sel, func);
    for (let i = 0, len = elm.length; i < len; i++) func(elm[i]);
  }
  var body_elm = document.querySelectorAll('body')[0];
  overrideStyleAttribute(body_elm, "color", "white");
  overrideStyleAttribute(body_elm, "background", "none");
  overrideStyleAttribute(body_elm, "background-color", colors.superblack);
  applyFuncWhenElmLoaded(
    'body',
    function (elm) {
      overrideStyleAttribute(elm, "color", "white");
      overrideStyleAttribute(elm, "background", "none");
      overrideStyleAttribute(elm, "background-color", colors.superblack)
    }
  );


  function rank_functions() {
    applyFuncWhenElmLoaded(
      '#contest-rank-table tr.this td.meta',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#003540");
        overrideStyleAttribute(elm, "color", "#fff");
      }
    );
    applyFuncWhenElmLoaded(
      '.modal-content, .modal-body',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#003540");
        overrideStyleAttribute(elm, "color", "#fff");
      }, 1500
    );
    applyFuncWhenElmLoaded(
      '#solutionModal #info-panel td',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#121212");
        overrideStyleAttribute(elm, "color", "#fff");
      }, 1500
    )

    applyFuncWhenElmLoaded(
      '#contest-rank-table tr.this.myself td.meta',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#0a697d");
        overrideStyleAttribute(elm, "color", "#fff");
      }, 1500
    );
    applyFuncWhenElmLoaded(
      '#contest-rank-table td.failed',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#321010");
        overrideStyleAttribute(elm, "color", "#fff");
      }
    );
    applyFuncWhenElmLoaded(
      '#contest-rank-table td.accepted',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#366039");
        overrideStyleAttribute(elm, "color", "#fff");
      }
    );
    applyFuncWhenElmLoaded(
      '#contest-rank-table td.prob.fb',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#037603");
        overrideStyleAttribute(elm, "color", "#fff");
      }
    );
    applyFuncWhenElmLoaded( // needs delay
      '#contest-rank-table th',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#091122");
        overrideStyleAttribute(elm, "color", "#fff");
      },
      1500
    );
    applyFuncWhenElmLoaded( // needs delay
      '#contest-rank-table a ',
      function (elm) {
        overrideStyleAttribute(elm, "color", "#fff");
      },
      1500
    );
    applyFuncWhenElmLoaded(
      ' table.table thead',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#06162e");
      }
    );
    applyFuncWhenElmLoaded(
      ' #description-container dd',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", "#101935");
        overrideStyleAttribute(elm, "color", "#F2FDFF");
        overrideStyleAttribute(elm, "box-shadow", "none");
      }
    );
    applyFuncWhenElmLoaded(
      'table.vjudge_sample tbody tr td',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", colors.superblack);
        overrideStyleAttribute(elm, "color", "white");
      }
    );
    applyFuncWhenElmLoaded(
      'table.vjudge_sample thead tr th, li.list-group-item',
      function (elm) {
        overrideStyleAttribute(elm, "background-color", colors.superblack);
        overrideStyleAttribute(elm, "color", "white");
      }
    );
    //#description-container>dd


  }


  applyFuncWhenElmLoaded(
    '.card-block, .list-group-item, .card, .btn',
    function (elm) {
      overrideStyleAttribute(elm, "color", "white");
      overrideStyleAttribute(elm, "background", "none");
      overrideStyleAttribute(elm, "background-color", "#121212")
    }
  );
  // 86c2f7

  rank_functions();
  let currentPage = location.href;

  const mutationObserver = new MutationObserver(function (mutations_list) {
    mutations_list.forEach(function (mutation) {
      mutation.addedNodes.forEach(function (added_node) {
        rank_functions();
      });
    });
  });

  function handleHashChange() {
    let urlParam = window.location.hash;
    if (urlParam == '#rank') {
      setTimeout(rank_functions);
      mutationObserver.observe(document.querySelector('#contest-rank-table'), { subtree: false, childList: true });
    } else {
      mutationObserver.disconnect();
    }
  };

  handleHashChange();
  window.addEventListener('hashchange', handleHashChange);

  function onClassChange(element, callback) {
    const observer = new MutationObserver((mutations) => {
      mutations.forEach((mutation) => {
        if (
          mutation.type === 'attributes' &&
          mutation.attributeName === 'class'
        ) {
          callback(mutation.target);
        }
      });
    });
    observer.observe(element, { attributes: true });
    return observer.disconnect;
  }

  onClassChange(body_elm, (node) => {
    node.classList.contains('active')
      ? ''
      : rank_functions();
  });




  //mutationObserver.observe(document.querySelector('#group-contest-table tbody'), {subtree: false, childList: true});
  mutationObserver.observe(body_elm, { subtree: false, childList: true });

  // default #0275d8
  function getStyle(elem, prop) {
    if (elem.currentStyle) {
      return elem.currentStyle[prop];
    }
    return document.defaultView.getComputedStyle(elem, null)[prop];
  }
  function parentHasClass(elm, classname, depth = 0) {
    if (depth == 2) return false;
    if (elm.className.split(' ').indexOf(classname) >= 0) return true;
    return elm.parentNode && parentHasClass(elm.parentNode, classname, depth + 1);
  }
  function fixLinkColor() {
    if (document.readyState != "complete") {
      return setTimeout(fixLinkColor, 100);
    }
    var elms = document.querySelectorAll("a");
    console.log(elms.length);
    for (let i = 0, len = elms.length; i < len; i++) {
      if (!elms[i].classList.contains('btn') && !parentHasClass(elms[i], 'name')) {
        overrideStyleAttribute(elms[i], "color", "#86c2f7");
      }
    }
  };

  fixLinkColor();


})();