Benutzer:Martin Kraft/hideUserComments.js
aus Wikipedia, der freien encyclopedia
var usersToHide = ['Some_Users_Name', 'Some_Other_Users_Name']; importScript('Benutzer:Martin_Kraft/hideUserComments.js');
- /
/**
- The Purpose of this Script is, to hide the edits of certain uses in Wikipedia talk pages by default.
- Each of the users Edits is then replaced by a small link, that enables you to unhide the post if needed.
- To use this Script just add the following two lines to your common.js:
(function ($) { var usersToHide = window.usersToHide;
if(!usersToHide) return;
$.each(usersToHide, function( i, n ) { var userName = n, selector = '>a[href*="/wiki/Benutzer"][href*=":' + userName + '"]:last-of-type';
$('dd'+selector+',p'+selector).each(function () { var $diskLink = $(this), $edit = $diskLink.parent(), $prevEdit, $lastEdit, $hideTrigger, nodeName = $edit[0].nodeName || 'dd', editIsVisible = true;
$edit.contents().wrapAll('
');
var $hideBlock = $edit.find('>.hide-block');
$hideBlock.find('>dl').each(function () { $edit.append(this); });
// Find previous dls
$prevEdit = $edit;
do {
$lastEdit = $prevEdit;
$prevEdit = $prevEdit.prev(nodeName);
if ($prevEdit.length == 0 ||
($prevEdit.length && $prevEdit.find('>a[href^="/wiki/Benutzer"]:last-child,>dl:first-child').length)) {
$prevEdit = $lastEdit
break;
} else {
$hideBlock = $hideBlock.add($prevEdit);
}
} while ($prevEdit != $lastEdit);
$prevEdit.before('<' + nodeName + '><a href="#" class="hide-'+i+'-trigger">'+userName+'</a></' + nodeName + '>'); $hideTrigger = $prevEdit.parent().find('>'+nodeName+'>.hide-'+i+'-trigger').css({ display: 'block', fontSize: '0.7em', color: '#AAA', textDecoration:'none' }).click(function (e) { e.preventDefault(); editIsVisible = !editIsVisible; $hideTrigger.html((editIsVisible? '▽' : '▷')+' Edit by ' + userName); // '╳' $hideBlock[editIsVisible? 'show' : 'hide'](); });
$hideTrigger.trigger('click'); }); });
})(jQuery);