User:Pling/monobook.js
From Guild Wars 2 Wiki
Jump to navigationJump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/** * Links in "user row" **/ function addTopLink(label, url) { var userpage = document.getElementById('pt-userpage'); if (userpage) { var link = document.createElement('a'); link.href = url; link.appendChild(document.createTextNode(label)); var li = document.createElement('li'); li.appendChild(link); userpage.parentNode.insertBefore(li, userpage.parentNode.firstChild); } } addOnloadHook(function() { /** * Format : addTopLink ('link label', 'link url'); **/ addTopLink('del', '/wiki/Guild Wars 2 Wiki:List of candidates for deletion'); addTopLink('m/s/m', '/wiki/Guild Wars 2 Wiki:List of proposed moves, splits and merges'); addTopLink('checklog', '/wiki/Special:CheckUser/Log'); addTopLink('patrol', '/index.php?title=Special%3ALog&type=patrol&user=&page='); addTopLink('images', '/index.php?title=Special:PrefixIndex&namespace=6&prefix=User_Pling'); addTopLink('pages', '/index.php?title=Special:PrefixIndex&namespace=2&prefix=Pling'); }); /** * All code below this comment is used for adding relevant, categorized pre-defined reasons * on the deletion page. * * @author Johan Sköld [ [[User:Galil]] ] **/ function addEvent(element, event, listener) { if (element.addEventListener) element.addEventListener(event, listener, false); else if (element.attachEvent) element.attachEvent('on'+event, listener); else element['on'+event] = listener; } function addList(id, label) { var wpReason = document.getElementById('wpReason'); if (wpReason) { var list = document.createElement('ul'); list.id = id; wpReason.parentNode.insertBefore(document.createTextNode(label), wpReason); wpReason.parentNode.insertBefore(list, wpReason); } } function addReason(listId, reason) { var wpReason = document.getElementById('wpReason'); if (wpReason) { var list = document.getElementById(listId); if (!list) throw new Error("List does not exist."); var link = document.createElement('a'); link.href = 'javas' + 'cript:void(0);'; addEvent(link, 'click', function() { wpReason.value = reason; }); link.appendChild(document.createTextNode(reason)); var item = document.createElement('li'); item.appendChild(link); list.appendChild(item); } } addEvent(window, 'load', function() { if (/action=delete/i.test(document.location.search)) { /** * This is where the magic happens. The format is quite easy to understand but if * you want help with it, feel free to ask me or poke as we both would probably be * able to help. * * To add a list: * addList('list name', 'list label'); * * * list name = Unique name of the list. Can pretty much only contain letters, * numbers, underscores and dashes. * * list label = Label of the list. This does not have to be unique. * * To add a reason to a list: * addReason('list name', 'reason label'); * * * list name = The unique name of the list to add the reason to. * * reason label = The actual reason. This is used both as label for the link * and inserted into the reason box. **/ addList('general', 'General speedy reasons'); addReason('general', 'Vandalism'); addReason('general', 'Link-spam'); addReason('general', 'Test page'); addReason('general', 'Author\'s request'); addReason('general', 'Housekeeping'); addReason('general', 'Attack page'); addReason('general', 'Recreation of deleted page'); // articles if (wgCanonicalNamespace == '') { addList('article', 'Article speedy reasons'); addReason('article', 'No appropriate information'); addReason('article', 'No verifiable source'); addReason('article', 'Unrelated to Guild Wars 2'); } // files if (wgCanonicalNamespace == 'File') { addList('file', 'Image speedy reasons'); addReason('file', 'Redundant image'); addReason('file', 'Corrupt or unviewable image'); addReason('file', 'User\'s request'); } // categories if (wgCanonicalNamespace == 'Category') { addList('category', 'Category speedy reasons'); addReason('category', 'Empty unused category'); } // users if (wgCanonicalNamespace == 'User' || (wgCanonicalNamespace == 'User_talk')) { addList('user', 'User speedy reasons'); addReason('user', 'User\'s request'); addReason('user', 'Unregistered user'); } // common reasons addList('common', 'Common deletion reasons'); addReason('common', 'Deletion uncontested after three days'); addReason('common', 'Associated page deleted'); addReason('common', 'Move remnant'); addReason('common', 'Copyright violation'); } }); /** * End of "all code below this comment"! **/ /** * WikiSwap **/ function importScript(page, lang) { var url = wgScriptPath + '/index.php?title=' + encodeURIComponent(page.replace(' ','_')) + '&action=raw&ctype=text/javascript&dontcountme=s'; if (lang) url = 'http://' + lang + '.wikipedia.org' + url; var s = document.createElement('script'); s.src = url; s.type='text/javascript'; document.getElementsByTagName('head')[0].appendChild(s); } importScript('User:AT/wikiswap.js'); // This script modifies the output of the "Your signature with timestamp" edit button. (function () { var oldAddButton = window.addButton; if (typeof(oldAddButton) != 'function') return; window.addButton = function () { if (arguments.length > 2) arguments[2] = arguments[2].replace(/^--(~+)$/, '$1'); oldAddButton.apply(this, arguments); }; })();