MediaWiki:UsefulDropdown/code.js

$(function { $('.page-header__contribution-buttons').append(""+ ""+ " Useful "+ ""+ ""+ ""+ " "+ ""+ ""+ "Protect Article"+ "AJAX Refresh</li>"+ "<a id=\"num3\" href=\"javascript:void(0)\">Stub</a></li>"+ "<a id=\"num4\" href=\"javascript:void(0)\">Delete</a></li>"+ "</ul>"+ "  ");

// Protection $('a#num1').click(function {   var protectiontime = prompt('Expiry:');    if(protectiontime) {        new mw.Api.post({ action: 'protect', title: mw.config.get('wgPageName'), reason: '', expiry: protectiontime, protections: 'edit=sysop', token: mw.user.tokens.get('editToken') }).done(function(d) { if(d.error) { new BannerNotification('Error while protecting article: ' + d.error.code, 'error').show; } else { new BannerNotification('Successfully protected article', 'success').show; }       }).fail(function { new BannerNotification('Error while protecting article', 'error').show; });   } });

// AJAX refresh $('a#num2').on("click", function refreshArticle {				var $temp = $(' ');				$temp.load(window.location.href + ' #mw-content-text', function { var $newContent = $temp.children('#mw-content-text'); if ($newContent.length) { $('#mw-content-text').replaceWith($newContent); mw.util.$content = $newContent; }					}		);				$temp.remove; 				alert("Content refreshed!");			});

// Adding stub template $('a#num3').click(function { 	   new mw.Api.post({ action: 'edit', title: wgPageName, summary: "Adding to help needed.", prependtext: " \n", token: mw.user.tokens.get('editToken') }).done(function(d) { if(d.error) { new BannerNotification('Error adding template: ' + d.error.code, 'error').show; } else { new BannerNotification('Successfully added to help needed!', 'success').show; }	       }).fail(function { new BannerNotification('Error while adding template', 'error').show; });					});

// adding deletion template $('a#num4').click(function { 					new mw.Api.post({ action: 'edit', title: wgPageName, summary: "Adding to candiates for deletion", prependtext: " \n", token: mw.user.tokens.get('editToken') }).done(function(d) { if(d.error) { new BannerNotification('Error adding template: ' + d.error.code, 'error').show; } else { new BannerNotification('Successfully added to candidates for deletion!', 'success').show; }										}).fail(function { new BannerNotification('Error while adding template', 'error').show; });									}); });