User:Beetstra/Gadget-Spamblacklistlog.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Beetstra/Gadget-Spamblacklistlog. |
/**
* Support for better display of log entries at en.wikipedia.
* Tested only in Chrome.
*
* Author: [[:User:Beetstra]], December 2016
* License: Quadruple licensed GFDL, GPL, LGPL and Creative Commons Attribution 3.0 (CC-BY-3.0)
*
* Version history:
*
* - start version on handling spamblacklistlog - 20161207
*/
/*jshint unused:true, eqnull:true, browser:true, white:true, indent:4 */
/*global mw, $ */
// <nowiki>
(function () {
// Guard against double inclusions
if (typeof window.BLLogHandler !== 'undefined') {
return;
}
var conf = mw.config.get([
'wgUserGroups',
'wgPageName',
'wgServer',
'wgScriptPath',
'wgUserName'
]);
function makeRawLink(name, url, target) {
var link = document.createElement('a');
link.setAttribute('href', url);
if (target) {
link.setAttribute('target', target);
}
link.appendChild(document.createTextNode(name));
return link;
}
function addRequestLinks(name, href, before, parent) {
parent.insertBefore(document.createTextNode('- '), before);
parent.insertBefore(makeRawLink(name, href), before);
parent.insertBefore(document.createTextNode(' '), before);
}
if ((conf.wgPageName.substr(0, 11) !== 'Special:Log')) {
return;
}
if ((conf.wgPageName == 'Special:Log/spamblacklist')) {
edit_lks = $('span.mw-usertoollinks').toArray();
if (edit_lks.length === 0) {
return;
}
for (i = 0; i < edit_lks.length; i++) {
anchors = edit_lks[i].getElementsByTagName('a');
if (anchors != null && anchors.length > 0) {
anchor = anchors[0];
url = anchor.getAttribute('href');
// https://en.wikipedia.org/wiki/Special:Contributions/2602:306:30EB:1090:14D:864F:F0D1:8D3E
href = url.replace('User_talk:', 'Special:Log/spamblacklist/');
title = anchor.getAttribute('title');
orig_bracket = edit_lks[i].firstChild;
addRequestLinks('user blacklist log', href, orig_bracket, edit_lks[i]);
href = url.replace('/wiki/User_talk:', '/w/index.php?title=Special:AbuseLog&wpSearchUser=');
addRequestLinks('user filter log',href,orig_bracket, edit_lks[i]);
}
}
}
}());
// </nowiki>
// [[Category:Wikipedia scripts|BLLogHandler.js]]