Greasy Fork

Greasy Fork is available in English.

RED de-colourise Next Userclass

Remove the red/green of the Next Userclass and also add a Hide/Show completed link

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         RED de-colourise Next Userclass
// @version      0.1
// @description  Remove the red/green of the Next Userclass and also add a Hide/Show completed link
// @author       Chameleon
// @include      http*://*redacted.ch/user.php?id=*
// @grant        none
// @namespace http://greasyfork.icu/users/87476
// ==/UserScript==

(function() {
  'use strict';

  var progressDiv=document.getElementsByClassName('box_userinfo_progress');
  if(progressDiv.length==0)
    return;

  progressDiv=progressDiv[0];
  var hideCompleted=window.localStorage.classProgressShowComplete != "false";
  var lis=progressDiv.getElementsByTagName('li');
  hideShow(lis, hideCompleted);
  for(var i=0; i<lis.length; i++)
  {
    var sp=lis[i].getElementsByTagName('span')[0];
    if(!sp)
      continue;
    var c=sp.getAttribute('class');
    sp.setAttribute('class', c+' nocolor');
  }

  var a=document.createElement('a');
  progressDiv.firstElementChild.appendChild(document.createTextNode(' ('));
  progressDiv.firstElementChild.appendChild(a);
  progressDiv.firstElementChild.appendChild(document.createTextNode(')'));
  a.innerHTML = (hideCompleted ? 'Show':'Hide')+' completed';
  a.href='javascript:void(0);';
  a.addEventListener('click', toggleCompleted.bind(undefined, a, lis), false);

  var style=document.createElement('style');
  document.head.appendChild(style);
  style.innerHTML='.nocolor { color:'+getComputedStyle(document.body).color+' !important;}';
})();

function toggleCompleted(a, lis)
{
  var hideCompleted=window.localStorage.classProgressShowComplete != "false";
  if(hideCompleted)
  {
    window.localStorage.classProgressShowComplete = "false";
    a.innerHTML='Hide completed';
  }
  else
  {
    window.localStorage.classProgressShowComplete = "true";
    a.innerHTML='Show completed';
  }
  hideShow(lis, !hideCompleted);
}

function hideShow(lis, hideCompleted)
{
  for(var i=0; i<lis.length; i++)
  {
    var li=lis[i];
    if(hideCompleted && li.innerHTML.indexOf('class="r99')!=-1)
    {
      li.style.display='none';
    }
    else
    {
      li.style.display='';
    }
  }
}