User:Thundercraft5/common.js

/** User:Thundercraft5/common.js * Licensed Under CC-BY-SA-3.0. * * =====Contents===== * *Personal Adjustments *	*Upper icons adjustment *	*Top Menu *	* * * Major Scripts *	*blockListLookup *	*rangeBlockLinks *	*blockListTools

/* global mw, test */ /* jshint esversion: 5, forin: true, immed: true, indent: 4, latedef: false, newcap: true, noarg: true, undef: true, undef: true, unused: true, browser: true, jquery: true, onevar: true, eqeqeq: true, multistr: true, maxerr: 999999

//#==================================================# //# PERSONAL ADJUSTMENTS //#==================================================# window.dontWantRoleSpecificJS = true; mw.requestIdleCallback = function(callback) { setTimeout(callback, 0); }; mw.requestIdleCallbackInternal = mw.requestIdleCallback;

// Temporary Loading of development script "CodeFiddle" $.getScript('/wiki/User:Thundercraft5/CodeFiddle.js?action=raw&ctype=text/javascript'); $.getScript('/wiki/User:Thundercraft5/FullscreenCodeEditor.js?action=raw&ctype=text/javascript'); $(' ', {	rel: "stylesheet",	href: "/wiki/User:Thundercraft5/CodeFiddle.css?action=raw&ctype=text/css", }).appendTo('head'),

mw.loader.using('mediawiki.Uri', function {	if (mw.config.get('wgPageName').startsWith('Special:Comment')) {		var split = mw.config.get('wgPageName').split('/').slice(1);		if (!split.length) return;		window.location.replace(new mw.Uri('/wiki/' + split[0] + "?" + $.param({ commentId: split[1], replyId: split[2] })));	} });

$(document.body).on('click', 'ul[class^="ActionDropdown_list__"] > li:first-of-type, [class^="Comment_wrapper__"]', function(e) {	if (e.ctrlKey) {		if ($('[class^="EditorForm_editor-form"]').length) return;		var el = $(e.target).parents('[class^="Comment_wrapper__"]');		var replyId = el.attr('data-reply-id');

window.navigator.clipboard.writeText('comment"); } });

document.addEventListener('keydown', function(e) {	var key = e.key.toLowerCase;	if (key === "l" && e.ctrlKey) {		e.preventDefault;		document.querySelector('.oo-ui-iconElement-icon.oo-ui-icon-gotoLine').click;	} else if (key === "s" && e.ctrlKey) {		e.preventDefault;		document.querySelector('.oo-ui-iconElement-icon.oo-ui-icon-pilcrow').click;	} });

// Edit counter if (mw.config.get('wgRelevantUserName') === mw.config.get('wgUserName') && mw.config.get('wgPageName').startsWith('Special:Contributions')) $('#firstHeading').after($(' ', { css: { "font-size": "14px", "font-weight": "initial", },   html: [ 'Edit counter: ', '[',       $('', {            text: 'daily',            click: function {                $(this).html($(' ') .attr({                       src: 'https://images.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif',                        border: 0,                    }) .css('vertical-align', 'baseline') );

var date = new Date; date.setDate(new Date.getDate - 1);

new mw.Api.get({                   action: 'query',                    format: 'json',                    list: 'usercontribs',                    ucuser: 'Thundercraft5',                    ucprop: "",                    ucend: date.toISOString,                    uclimit: 1000,                }).then(function(d) {                    $(this).text('daily');                    mw.notify('You have made ' + d.query.usercontribs.length + ' edits today.', { type: "success" });                }.bind(this)); },       }),        ']',        ' &bull; ',        '[',        $('', { text: 'weekly', click: function { $(this).html($(' ')                   .attr({ src: 'https://images.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif', border: 0, })                   .css('vertical-align', 'baseline')                );

var date = new Date; var day = date.getDay, diff = date.getDate - day + (day === 0 ? -6 : 1);

date = new Date(date.setDate(diff));

new mw.Api.get({                   action: 'query',                    format: 'json',                    list: 'usercontribs',                    ucuser: 'Thundercraft5',                    ucprop: "",                    ucend: date.toISOString,                    uclimit: 1000,                }).then(function(d) {                    $(this).text('weekly');                    mw.notify('You have made ' + d.query.usercontribs.length + ' edits this week.', { type: "success" });                }.bind(this)); },       }),        ']',    ] }));

// Wiki button customization $('div.wds-community-header__wiki-buttons > .createpage') .off('click') .html($(' ', { class: "wds-icon top-note__message-icon wds-icon-small", html: $(' ', {				"xlink:href": "#wds-icons-comment-small",			}), }))		.attr('href', mw.util.getUrl('Special:SocialActivity')) .removeClass('createpage') .attr('title', 'View the wiki\'s social activity') .addClass('wds-button-socialactivity-link') .remove .insertAfter('.wds-community-header__wiki-buttons > a:first-child') .next .clone .html($(' ', { class: "wds-icon wds-icon-small", html: $(' ', {					"xlink:href": "#wds-icons-poll",				}), }))			.attr('title', 'View the wiki\'s abuse log') .attr('href', mw.util.getUrl('Special:AbuseLog')) .addClass('wds-button-abuselog-link') .insertAfter('.wds-button-socialactivity-link');

$.getScript('https://dev.fandom.com/wiki/MediaWiki:BlockListTools.js?action=raw&ctype=text/javascript');