LearnCPP dark mode

Dark mode for LearnCPP.com lessons

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         LearnCPP dark mode
// @namespace    http://gabrielecoen.blogspot.com/
// @version      0.2
// @description  Dark mode for LearnCPP.com lessons
// @author       You
// @match        https://www.learncpp.com/*
// @grant        none
// ==/UserScript==

var loadScript = function (src, callback) {
  var elem = document.createElement('script');
  elem.type = 'text/javascript';
  elem.onload = callback;
  elem.src = src;
  document.body.appendChild(elem);
};

function start() {

  var config = {
    fontColor: '#CCCCCC',
    bodyBg: '#353535',
    yellowBg: '#262626',
    pinkBg: '#262626',
    codeBg: '#dddddd',
    commentBg: '#262626',
    authorCommentBg: '#1c1c1c'
  };

  // Common

  //// Background colors
  jQuery('body, middle, .post, .widget_text, .textwidget, .comment-respond').css('background-color', config.bodyBg);
  jQuery('td#middle, ul').css('background', config.bodyBg);
  jQuery('.cpp-lightyellowbackground').css('background-color', config.yellowBg);
  jQuery('.cpp-lightredbackground').css('background-color', config.pinkBg);
  jQuery('.crayon-row').css('background-color', config.codeBg);
  jQuery('.comment-container').css('background-color', config.commentBg);
  jQuery('.comment-container').css('border', config.commentBg);
  jQuery('.bypostauthor').css('background-color', config.authorCommentBg);
  jQuery('.bypostauthor').css('border', config.authorCommentBg);


  //// Text colors
  jQuery('body').css('color', config.fontColor);
  jQuery('table, tr, td').children().css('color', config.fontColor);
  jQuery('font').css('color', config.fontColor);
  jQuery('a:link').css('color', config.fontColor);

}

// Load jQuery, if the current web page does not have it
if (typeof jQuery === 'undefined') {
  loadScript('//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', start);
} else { start(); }