Google Calendar Web Material

Google Calendar Web Material event flairs

Versione datata 19/04/2016. Vedi la nuova versione l'ultima versione.

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==
// @author        Balázs Orbán ([email protected])
// @name          Google Calendar Web Material
// @description   Google Calendar Web Material event flairs
// @match         https://calendar.google.com/*
// @version       1.0
// @namespace https://greasyfork.org/users/39251
// ==/UserScript==

var event_flair = [
  ["Work out", "Work", "url(https://goo.gl/6uktJo)"],
  ["Matematikk", "Fysikk", "url(https://goo.gl/PW8YmH)"],
  ["code", "programming", "url(https://goo.gl/uIiBCo)"],
  ["Run", "jog", "url(https://goo.gl/H7KTYU)"],
  ["Clean", "wash", "url(https://goo.gl/2A76Xn)"],
  ["Spanish", "German", "url(https://goo.gl/z1fy1s)"],
  ["Photography", "photo", "url(https://goo.gl/7LjvkO)"]
];

var target = document.querySelector('#gridcontainer');
var observer = new MutationObserver(function(mutations) {
  mutations.forEach(function(mutation) {
      console.log("changed");
      var select = document.querySelectorAll('.chip dd, .cbrdcc');
      for (i = 0; i < select.length; i++) {
          compareFunction = function(e) {
              return select[i].innerText.indexOf(e) !== -1;
          };
          for (j = 0; j < event_flair.length; j++) {
              if (event_flair[j].filter(compareFunction).length) {
                  select[i].style.backgroundImage = event_flair[j][event_flair[j].length - 1];
                  //TESTING//console.log(event_flair[j][0] + " " + event_flair[j][event_flair[j].length-1]);
              }
          }
      }
  });
});
var config = {
  attributes: true,
  childList: true,
  characterData: true
};
observer.observe(target, config);