User:BaneDiaries/wikia.js

// Adding button to header with useful links; // @author: BaneDiaries // status: in-development; $(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>"+ "<a id=\"num5\" href=\"javascript:void(0)\">Merge</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		$('#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);				// re-set mw.util.$content for any scripts that may use it				mw.util.content = newContent;			}		}); temp.remove; alert("Content refreshed!"); });	$('.DiscordIntegratorModule').remove; // Removing discord integrator from rail }); /* // Notes section. Thanks to the guy from stack overflow who made this possible:| $('#WikiaRail').append('<section class=\"chat-module rail-module\"><h2 class=\"headernote\">Notes: <ul id=\"notes\" class=\"actualnotes\"></ul><input type=\"text\" id=\"txtNote\" placeholder=\"Add Note\"> <div class=\"entry-button wds-is-secondary wds-button wds-is-squished\" id=\"btnSave\">Save <div class=\"entry-button wds-is-secondary wds-button wds-is-squished\" id=\"btnClear\">Clear! '); var list = document.getElementById("notes"); // Loop through localStorage for (var i = 0; i < localStorage.length; i++){ // Make sure that we only read the notes from local storage if(localStorage.key(i).indexOf("note") !== -1){ // For each item, create a new  element var item = document.createElement("li"); item.className = " itemCSS"; // Populate the  with the contents of the current // localStorage item's value item.textContent = localStorage.getItem(localStorage.key(i)); // Append the  to the page's <ul> list.appendChild(item); }  }   var btn = document.getElementById("btnSave"); var note = document.getElementById("txtNote"); var btnclean = document.getElementById("btnClear"); var noteCount = 1; btn.addEventListener("click", function{    var noteVal = note.value;     if(noteVal.trim !== ""){       localStorage.setItem("note" + noteCount, noteVal);       var lstItem = document.createElement("li");       lstItem.textContent = noteVal;       noteCount++;     }    btnclean.addEventListener("click", function{ localStorage.clear; }  }); $('.headernote').css({ 'margin': '0 !important', 'text-align': 'center', 'font-size': '25px !important', 'font-style': 'italic', 'font-family': 'Raleway' }); $('.actualnotes li').css({ 'background': 'purple', 'padding': '10px', 'margin': '5px', 'font-family': 'Raleway', 'text-align': 'center', 'font-size': '17px', 'font-style': 'italic', 'border': '1px solid' }); $('#txtNote').css({ 'background': 'transparent', 'border': 'none', 'text-align': 'center', 'margin-left': '20%', 'float': 'center', 'color': 'white', 'font-style': 'italic' }); $('#btnClear').css({ 'float': 'right' }); });