Renbow h4x

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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( );