Renbow h4x

Provide an alert when a user appears to have gained a level

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Renbow h4x
// @namespace   sophie
// @description Provide an alert when a user appears to have gained a level
// @include     https://www.wanikani.com/chat/*
// @include     http://www.wanikani.com/chat/*
// @version     0.1
// @grant       none
// @license     GPL version 3 or later: http://www.gnu.org/copyleft/gpl.html
// ==/UserScript==

function parse( ) {
  var names = window.localStorage.renbow ?
	JSON.parse(window.localStorage.renbow)
	: { };
  var authors = document.querySelectorAll('.forum-post-author > div');
  var nameExpr = /([^\/]*)$/;
  for(var i=0;i<authors.length;++i) {
    var name = nameExpr.exec(authors[i].children[0].href)[1];
    var level = parseInt(authors[i].children[1].textContent,10);
    if(names[name] && names[name] < level)
      alert(name + " has gained a level!");
    names[name] = level;
  }
  window.localStorage.renbow = JSON.stringify(names);
}
window.onload = parse( );