User:Hippietrail/filtercontribs.js
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
/*
Original version: [[User:Hippietrail/filtercontribs.js]]
<pre>
*/
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;
}
}
}
/*
</pre>
*/