User:Hippietrail/filtercontribs.js

/*

Original version: User:Hippietrail/filtercontribs.js

function filtercontribs { if (wgNamespaceNumber == -1 && wgCanonicalSpecialPageName == 'Contributions') { hippFcSetupGui; } } addOnloadHook(filtercontribs);

function hippFcSetupGui { var fs = document.getElementById('bodyContent').getElementsByTagName('form')[0].getElementsByTagName('fieldset')[0];

var cb = document.createElement('input'); cb.setAttribute('id', 'filter'); cb.setAttribute('type', 'checkbox'); cb.setAttribute('onclick', 'hippFcToggle(this)');

var label = document.createElement('label'); label.setAttribute('for', 'filter');

// TODO localize label.appendChild(document.createTextNode('Show only articles changed since my last edit'));

fs.appendChild(cb); fs.appendChild(label); }

function hippFcToggle(cb) { if (cb.checked) hippFcFilterOn; else hippFcFilterOff; }

function hippFcFilterOn { var hash = new Object;

var list = document.getElementById('bodyContent').getElementsByTagName('ul')[0].getElementsByTagName('li');

if (list != null) { for (i = 0; i < list.length; i++) { var spans = list[i].getElementsByTagName('span'); for (j = 0; j < spans.length; ++j) if (spans[j].className == 'mw-uctop') list[i].style.display = 'none';

var title = list[i].getElementsByTagName('a')[3].firstChild.nodeValue;

if (hash[title] == true) list[i].style.display = 'none'; else hash[title] = true; } } }

function hippFcFilterOff { var list = document.getElementById('bodyContent').getElementsByTagName('ul')[0].getElementsByTagName('li');

if (list != null) { for (i = 0; i < list.length; i++) { if (list[i].style.display == 'none') list[i].style.display = null; } } }

/*