User:Fandyllic/global.js

/* ***** */

/* Add a menu item to profile menu with link to user contributions in modernized UI v2 */ $(function {    var $userContribs = $('')        .attr('id', 'MyContribs')        .append( $('') .attr('href', '/wiki/Special:Contributions/' + wgUserName) .text('My Contributions') );   //Add menu item, before My Preferences link, if it exists    $('div.wds-global-navigation__user-menu > div.wds-dropdown__content > ul.wds-list > li:nth-child(3)').before($userContribs); });

/* WORKING AGAIN thanks to suggestion by KockaAdmiralac on dev wiki... */ /* Add a submenu to profile menu with links to favorite wikis in modernized UI v2 */

// FYI fav_wikis1, fav_wikis2, fav_wikis3, and fav_wikis4 are lists of keys that can't uses dashes, so if // *.wikia.com subdomain uses dashes, you need to special case URL contruction var fav_wikis1note = 'Admin wikis'; var fav_wikis1 = { wowwiki: 'WoWWiki', fandyllic: 'Fandyllic Wiki', demoncycle: 'Demon Cycle Wiki', downtonabbey: 'Downton Abbey Wiki', expanse: 'Expanse Wiki', hearthstone: 'Hearthstone Wiki', kuromukuro: 'Kuromukuro Wiki', tea: 'WikiTea', templates: 'Templates Wiki', manycolored: 'Many Colored Wiki' }; var fav_wikis2note = 'Non-admin wikis'; var fav_wikis2 = { anime: 'Animanga Wiki', drama: '(Asian) Drama Wiki', haruhi: 'Haruhi Suzumiya Wiki', littlewitchacademia: 'Little Witch Academia Wiki' }; var fav_wikis3note = 'Contributor wikis'; var fav_wikis3 = { hataraku: 'Hataraku Maou-sama Wiki', hyouka: 'Hyouka Wiki', konosuba: 'KonoSuba Wiki', kiseijuu: 'Parasyte Wiki', steinsgate: 'Steins;Gate Wiki', sao: 'Sword Art Online Wiki' }; var fav_wikis4note = 'Adoptable wikis'; var fav_wikis4 = { arakawaunderthebridge: 'Arakawa Under the Bridge Wiki', kokoroconnect: 'Kokoro Connect Wiki', sidonianokishi: 'Knights of Sidonia Wiki', silverspoon: 'Silver Spoon Wiki', kiminonawa: 'your name. wiki' } $(function {	'use strict';

$('.wds-global-navigation__user-menu .wds-dropdown__content').addClass('wds-is-not-scrollable');

/* Start adding My Favorite Wikis menu */ if (!window.fav_wikis1 || $('#MyFavWikis').length) { return; }

var $favWikiList = $('').addClass('wds-list wds-is-linked'); var $favWikis = $('') //.attr('id', 'MyFavWikis') .addClass('wds-dropdown-level-2') .append(			$('')				.attr('href', '#')				.addClass('wds-dropdown-level-2__toggle')				.attr('data-tracking', 'custom-level-2')				.append( $(' ').text('My Favorite Wikis'), $(' ') ),			$(' ')				.addClass('wds-is-not-scrollable wds-dropdown-level-2__content')				.append($favWikiList)		); // Add note at top for fav_wikis1 $favWikiList.append(		$('')			.text(fav_wikis1note)			.css('font-style', 'italic')	); // Add links from fav_wikis1 list Object.keys(window.fav_wikis1).forEach(function (key) {		$favWikiList.append( $('').append(				$('')					.attr('href', '//' + key + '.wikia.com/')					.attr('target', '_blank')					.text(window.fav_wikis1[key])			) );		//Add a horizontal rule (line) after specified key link        if (key == 'fandyllic') {			$favWikiList.append( $(' ')			);		}	});	// Add horiz rule (line) fav_wikis1 $favWikiList.append(		$(' ')	); // Add note after horiz rule (line) $favWikiList.append(		$('')			.text(fav_wikis2note)			.css('font-style', 'italic')	); // Add links from fav_wikis2 list Object.keys(window.fav_wikis2).forEach(function (key) {       /* Change if (true) to else if special case needs to be added before again */        if (true) { // Use key for URL as normal            $favWikiList.append( $('').append(                       $('')                        .attr('href', '//' + key + '.wikia.com/')                        .attr('target', '_blank')                        .text(window.fav_wikis2[key])                        .append( $(' ')                               .prepend(' ') .append(                                   $('')                                        .attr('href', '//' + key + '.wikia.com/wiki/Special:ListAdmins')                                        .attr('target', '_blank')                                        .text('(Admins)')                            ) )

)               );        }    });

$('div.wds-global-navigation__user-menu > div.wds-dropdown__content > ul.wds-list > li:nth-child(3)') .before($favWikis);

/* Star adding Other Wikis menu */ if (!window.fav_wikis2 || $('#MyFavWikis2').length) { return; }

var $favWikiList2 = $('').addClass('wds-list wds-is-linked'); var $favWikis2 = $('') //.attr('id', 'MyFavWikis2') .addClass('wds-dropdown-level-2') .append(			$('<a>')				.attr('href', '#')				.addClass('wds-dropdown-level-2__toggle')				.attr('data-tracking', 'custom-level-2')				.append( $(' ').text('Other Wikis'), $('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" width="12" height="12" class="wds-icon wds-icon-tiny wds-dropdown-chevron"><path d="M6.003 10.002a.997.997 0 0 1-.707-.293L.293 4.706a1 1 0 1 1 1.414-1.414l4.296 4.295 4.293-4.293A1 1 0 1 1 11.71 4.71l-5 5a.997.997 0 0 1-.707.293" fill-rule="evenodd"> ') ),			$(' ')				.addClass('wds-is-not-scrollable wds-dropdown-level-2__content')				.append($favWikiList2)		);

// Add note at top for fav_wikis3 $favWikiList2.append(		$('<li>')			.text(fav_wikis3note)			.css('font-style', 'italic')	); // Add links from fav_wikis3 list Object.keys(window.fav_wikis3).forEach(function (key) {       $favWikiList2.append( $('<li>').append(               $('<a>')                    .attr('href', '//' + key + '.wikia.com/')                    .attr('target', '_blank')                    .text(window.fav_wikis3[key])                    .append( $(' ')                           .prepend(' ') .append(                               $('<a>')                                   .attr('href', '//' + key + '.wikia.com/wiki/Special:ListAdmins')                                    .attr('target', '_blank')                                    .text('(Admins)')                            ) )           )        );	});

// Add horiz rule (line) fav_wikis3 $favWikiList2.append(		$(' ')	); // Add note after horiz rule (line) $favWikiList2.append(		$('<li>')			.text(fav_wikis4note)			.css('font-style', 'italic')	); // Add links from fav_wikis4 list Object.keys(window.fav_wikis4).forEach(function (key) {       // Need to special case because key can't use dashes        if (key == 'arakawaunderthebridge') {            $favWikiList2.append( $('<li>').append(                   $('<a>')                        .attr('href', '//arakawa-under-the-bridge.wikia.com/')                        .attr('target', '_blank')                        .text(window.fav_wikis4[key])                        .append( $(' ')                               .prepend(' ') .append(                                   $('<a>')                                        .attr('href', '//arakawa-under-the-bridge.wikia.com/wiki/Special:ListAdmins')                                        .attr('target', '_blank')                                        .text('(Admins)')                            ) )

)           );        }        else if (key == 'sidonianokishi') { $favWikiList2.append(               $('<li>').append( $('<a>') .attr('href', '//sidonia-no-kishi.wikia.com/') .attr('target', '_blank') .text(window.fav_wikis4[key]) .append(                           $(' ')                                .prepend(' ')                                .append( $('<a>') .attr('href', '//sidonia-no-kishi.wikia.com/wiki/Special:ListAdmins') .attr('target', '_blank') .text('(Admins)') )                       )

)               );        }        else { $favWikiList2.append(               $('<li>').append( $('<a>') .attr('href', '//' + key + '.wikia.com/') .attr('target', '_blank') .text(window.fav_wikis4[key]) .append(                           $(' ')                                .prepend(' ')                                .append( $('<a>') .attr('href', '//' + key + '.wikia.com/wiki/Special:ListAdmins') .attr('target', '_blank') .text('(Admins)') )                       )                )            );        }	});

$('div.wds-global-navigation__user-menu > div.wds-dropdown__content > ul.wds-list > li:nth-child(3)') .before($favWikis2); });

/* Add three favorite wikis links to profile menu in modernized UI */ /* DISABLE to test submenu version $(function {	$('div.wds-global-navigation__user-menu > div.wds-global-navigation__dropdown-content > ul.wds-list > li:nth-child(3)').not('#MyFavWikis').before('<li id="MyFavWikis" style="padding-top:0.8em;"> My Favorite Wikis <a href="http://downtonabbey.wikia.com/" class="wds-global-navigation__dropdown-link" data-tracking-label="myfavwikis.1">Downton Abbey Wiki</a> <a href="http://expanse.wikia.com/" class="wds-global-navigation__dropdown-link" data-tracking-label="myfavwikis.2">Expanse Abbey Wiki</a> <a href="http://wow.wikia.com/" class="wds-global-navigation__dropdown-link" data-tracking-label="myfavwikis.3">WoWWiki</a> </li>'); });

//A script that adds a "Go to bottom" button in the footer of the Oasis theme. //Based on BackToTop by Noemon from Dead Space Wiki (function(window, $, mw) {   'use strict';    var translations = {    //    ar:         'انتقل إلى أسفل',    //    af:         'Gaan na onder',    //    be:         'перайсці ўніз',    //    bg:         'Отидете надолу',    //    bs:         'Idite dole',    //    ca:         'Vés a baix',    //    cs:         'Jděte dolů',    //    da:         'Gå til bunden',    //    de:         'Gehe nach unten',    //    el:         'Πηγαίνετε κάτω',        en:         'Go to bottom'//,    //    eo:         'Iru al fundo',    //    es:         'Ir al fondo',    //    eu:         'Joan beherantz',    //    fa:         'به پایین بروید',    //    fr:         'Aller au fond',    //    ga:         'Téigh go dtí bun',    //    gl:         'Ir a fondo',    //    hi:         'नीचे जाएं',    //    hr:         'Idi na dno',    //    id:         'Ke bawah',    //    it:         'Vai in basso',    //    ja:         '下に行く', //   ko:         '하단으로 이동', //   la:         'Ad deorsum', //   mk:         'Оди до дното', //   ms:         'Pergi ke bawah', //   nl:         'Ga naar beneden', //   no:         'Gå til bunnen',' //   pl:         'Przejdź na dół', //   pt:         'Ir para o fundo', //   'pt-br':    'Ir para o fundo', //   ro:         'Du-te jos', //   ru:         'Вниз', //   sco:        'Rach gu bonn', //   sl:         'Pojdi do dna', //   sr:         'Иди до дна', //   sv:         'Gå till botten', //   tl:         'Pumunta sa ibaba', //   uk:         'Іди донизу', //   vi:         'Đi xuống dưới cùng', //   zh:         '转到底部', //   'zh-hans':  '转到底部', //   'zh-hant':  '轉到底部' },   buttonStart = typeof window.JumpToBottomStart === 'number' ? window.JumpToBottomStart : 0,   scrollSpeed = typeof window.JumpToBottomSpeed === 'number' ? window.JumpToBottomSpeed : 600,   fadeSwitch = typeof window.JumpToBottomFade === 'number' ? window.JumpToBottomFade : 600,   theText = (typeof window.JumpToBottomText === 'string' && window.JumpToBottomText) || translations['en'] || translations.en; if (window.JumpToBottomLoaded) { return } window.JumpToBottomLoaded = true; $(addJumpToBottom); function hideFade { $("#jumptobottom").hide; $(window).scroll(function {           if (($(this).scrollTop > buttonStart) && ($(this).scrollTop < ($('#mw-content-text').height - $('.wds-global-footer').height))) {                switch (fadeSwitch) {                    case 0:                        $('#jumptobottom').show;                        break;                    default:                        $('#jumptobottom').fadeIn;                        break;                }            } else {                switch (fadeSwitch) {                    case 0:                        $('#jumptobottom').hide;                        break;                    default:                        $('#jumptobottom').fadeOut;                        break;                }            }        }); }   $('body').on('click', '#jumptobottom', function {        $('body,html').animate({ scrollTop: $('#mw-content-text').height - $('.wds-global-footer').height + 250 }, scrollSpeed);       return false;    }); function addJumpToBottom { if (skin == 'oasis') { $(' ', {               id: 'jumptobottom',                style: 'float: right; margin-top: -1px; border-right: none'            }) .append(               $(' ', { type: 'button', style: 'height: 20px;', text: theText })           )            .appendTo('#WikiaBarWrapper .toolbar > .tools'); hideFade; }   } }(this, jQuery, mediaWiki));

/* - */

/* Purge button to left of page header contrib buttons on modernized UI v2*/ $(function {	var currServer = mw.config.get('wgServer');	var newPageName = wgPageName.replace(/\?/,"\%3F");	var newTitle = wgTitle;	if (wgCanonicalNamespace) newTitle = wgCanonicalNamespace + ":" + wgTitle;	$('div.page-header__contribution-buttons > div.wds-button-group > a:first-child').not('#custom-purge').before('<a id="custom-purge" class="wds-button wds-is-squished wds-is-secondary" href="'+currServer+'/index.php?title=' + newPageName + '&action=purge" id="PurgeButton" style="margin-right:0.5em;"> Purge </a>'); });

/* History button for diffs */ /* (doesn't work on some namespaces like User: and User talk: */ /*   because w:Special:MyPage/global.js and Special:MyPage/wikia.js */ /*   never get loaded) */ $(function {	$("h1:contains('Changes:')").after('<a class="wds-button wds-is-squished wds-is-secondary" data-id="history" href="/' + wgPageName + '?action=history" style="margin-left:1.5em;">History</a>'); })

/* Back to top button on Wikia bottom tool bar */ importScriptPage('MediaWiki:BackToTopButton/code.js', 'dev');

/* Edit button (classic editor) to right of page name header */ /* DISABLE, since you can now default to source editor, but still access new VE (but not old VE) $(function {    var currServer = mw.config.get('wgServer');	var newPageName = wgPageName.replace(/\?/,"\%3F");	var newTitle = wgTitle;	if (wgCanonicalNamespace) newTitle = wgCanonicalNamespace + ":" + wgTitle;	$('#WikiaPageHeader > h1').after(' <a class="wikia-button" href="'+currServer+'/index.php?title=' + newPageName + '&action=edit">Edit</a> '); });

/* Purge link to right of page name header */ /* NOTE: Stopped working mid-2017 $(function {	var currServer = mw.config.get('wgServer');	var newPageName = wgPageName.replace(/\?/,"\%3F");	var newTitle = wgTitle;	if (wgCanonicalNamespace) newTitle = wgCanonicalNamespace + ":" + wgTitle;	$('.tally > em').before(' <a href="'+currServer+'/index.php?title=' + newPageName + '&action=purge"><img src="http://images3.wikia.nocookie.net/wowwiki/images/8/88/Wiki-purge-icon_15.png"/></a> '); */	/* PAGE TITLE LINK $('#WikiaPageHeader > h1').after(' <a href="http://images3.wikia.nocookie.net/wowwiki/images/8/88/Wiki-purge-icon_15.png/index.php?title=' + newPageName + '&action=purge"><img src="http://images3.wikia.nocookie.net/wowwiki/images/8/88/Wiki-purge-icon_15.png"/> ' + newTitle + '</a> '); */ /* });

/** * To use this script, install it and view:  Special:InterLangList?filtertype=interlanguage */ if (mediaWiki.config.get('wgCanonicalSpecialPageName') === 'Blankpage' && $.getUrlVar('filtertype') === 'interlanguage') { (function ($, mw) {		var url = mw.config.get('wgServer') + '/api.php?action=query&meta=siteinfo&siprop=interwikimap&format=json';		// get local interwiki map		$.getJSON(url, function (data) { var interlanguageWikis = [], map = data.query.interwikimap; for (var i = 0, len = map.length; i < len; i++) { if (map[i].language) { interlanguageWikis[interlanguageWikis.length] = map[i]; }			}			// display results in an HTML table $(function {				// generate html				var wiki, link, html, message;				message = ' The ' + mw.config.get('wgSiteName') + ' appears to be available in ' + interlanguageWikis.length + ' language(s).  Do you know of a version of this wiki in a language not listed here? You can make a request <a title="Community Central:Interlanguage link requests" href="http://community.wikia.com/wiki/Community_Central:Interlanguage_link_requests">here</a> for it to be <a title="Help:Interlanguage links" href="http://community.wikia.com/wiki/Help:Interlanguage_links">interlanguage linked</a>. ';				html = ' ' + message + ' ';				// insert html				document.title = 'Interlanguage wikis';				$('#firstHeading, #WikiaArticle h1').first.text('Interlanguage wikis');				$('#mw-content-text').html(html);			}); });	}(jQuery, mediaWiki)); }

/* Add Contributions to user drop down */ /* NOTE: Broken. $(function {   $('ul.AccountNavigation li:first-child ul.subnav li:first-child').after('<li><a href="/wiki/Special:Contributions/' + encodeURIComponent(wgUserName) + '">Contributions</a></li>'); });

/* Convert "Anonymous" in Comments to IP address from User:Monchoman45                        */ $(function {   var list = document.getElementsByTagName('a');    for(var i in list) {        if(list[i].href && list[i].href.indexOf('Special:Contributions/') && list[i].innerHTML == 'A Wikia contributor') {            list[i].innerHTML = list[i].href.substring(list[i].href.lastIndexOf('/') + 1, list[i].href.length);        }    } }); /* END Convert "Anonymous" in Comments to IP address */

/* Adds a 'Back to page' link under the preview header when previewing an edit. */ $(function {   if (wgAction == "submit") {        $('#WikiaEditBoxHeader p').clone.appendTo('#WikiaPageHeader:first-child');    } });

/* Experimental auto signer http://dev.wikia.com/wiki/Sine */ /* Disable for now importScriptPage('Sine/code.js', 'dev');

/* See User:Fandyllic/langwikicheckerJS for a copy of JS at Thread:484838   */