User:Cafeinlove/global.js

importArticles({   type: 'script',    articles: [        /*        * PurgeButton        * @author Uberfuzzy, Grunny, Pecoes        */        'u:dev:PurgeButton/code.js',        /*        * Ajax Batch Delete        * @description Delete listed multiple pages        * Does not need to go to Special:BlankPage to use        * Includes the option to protect after deleting        * Includes the option to grab a whole category's contents        * @author Ozank Cx        */        'u:dev:AjaxBatchDelete/code.2.js'    ] });

(function {   addSandboxLink;

// Add `My Sandbox` link to the peronal menu list on the top right function addSandboxLink { var dropdown = document.querySelector( "#globalNavigation .wds-list" ), li = document.createElement( "li" ), a = document.createElement( "a" ), isKorean = location.host.split(".")[0] == "ko", linkName = isKorean ? "내 연습장" : "My Sandbox", articleName = isKorean ? "연습장" : "Sandbox"; li.appendChild( a ); a.appendChild( document.createTextNode( linkName ) ); a.className = "wds-global-navigation__dropdown-link"; a.setAttribute( "href", "/wiki/User:Cafeinlove/" + articleName ); dropdown.insertBefore( li, dropdown.childNodes[2] ); }

});

/** * Grab whole code within certain tags on double-click * 2017, User:Cafeinlove | MIT License */ const codeBlockTags = ["code", "pre", "samp", "var"];

(function(selectors) {

var targetArray = []; var nodeList;

selectors.forEach( function(e) {		nodeList = document.getElementsByTagName(e);		targetArray = targetArray.concat( Array.from(nodeList) );	});

targetArray.forEach( function(e) {		e.addEventListener("dblclick", function { selectCode(e); });	});

function selectCode(el) { var range = document.createRange; var selection = window.getSelection; range.selectNodeContents(el); selection.removeAllRanges; selection.addRange(range); }

})(codeBlockTags);