User:Fandyllic/global.js

/* ***** */

/* NOTE: Need to verify functionality on UCP. STATUS: Seems to work as of 15-Jul-2020. /* 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); });

/* TEST on UCP to see if gets used from ucp.fandom.com */ /* 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 // *.fandom.com or *.wikia.com subdomain uses dashes, you need to special case URL construction /* Known special cases with dashes in subdomain: yuru-camp, little-witch-academia, shield-hero, steins-gate arakawa-under-the-bridge, sidonia-no-kishi Not currently in menu: tora-dora var fav_wikis1note = 'Admin wikis'; var fav_wikis1 = { wowwiki: 'WoWWiki', fandyllic: 'Fandyllic Wiki', chiosschoolroad: "Chio's School Road Wiki (UCP)", cosplay: 'Cosplay Wiki', thedemoncycle: 'Demon Cycle Wiki', downtonabbey: 'Downton Abbey Wiki', expanse: 'Expanse Wiki', hearthstone: 'Hearthstone Wiki', kuromukuro: 'Kuromukuro Wiki', yurucamp: 'Laid-Back Camp Wiki', manycolored: 'Many-Colored Wiki', tea: 'WikiTea', templates: 'Templates Wiki', }; var fav_wikis2note = 'Non-admin wikis'; var fav_wikis2 = { anime: 'Animanga Wiki', drama: '(Asian) Drama Wiki', jpop: 'Japanese Music Wiki', haruhi: 'Haruhi Suzumiya Wiki', littlewitchacademia: 'Little Witch Academia Wiki' }; var fav_wikis3note = 'Contributor wikis'; var fav_wikis3 = { konosuba: 'KonoSuba Wiki', oregairu: 'OreGairu Wiki', kiseijuu: 'Parasyte Wiki', shieldhero: 'Shield Hero Wiki', tensura: 'Reincarnated as a Slime Wiki', steinsgate: 'Steins;Gate Wiki', swordartonline: 'Sword Art Online Wiki' }; var fav_wikis4note = 'Adoptable wikis'; var fav_wikis4 = { arakawaunderthebridge: 'Arakawa Under the Bridge Wiki', sidonianokishi: 'Knights of Sidonia Wiki', netoju: 'Recovery of an MMO Junkie Wiki', silverspoon: 'Silver Spoon Wiki', kiminonawa: 'your name. wiki' }; // Holding area for wikis in menus past var fav_wikis5note = 'Holding area wikis'; var fav_wikis5 = { chunibyo: 'Love, Chunibyo & Other Delusions Wiki', hataraku: 'Hataraku Maou-sama Wiki', hinamatsuri: 'Hinamatsuri Wiki', hyouka: 'Hyouka Wiki', kokoroconnect: 'Kokoro Connect Wiki', toradora: 'Toradora Wiki' }; /* No more in the list */ var wiki_types = { subdomain: 'wikia.com' }; $(function {	'use strict';    $('.wds-global-navigation__user-menu .wds-dropdown__content').addClass('wds-is-not-scrollable');    /* Don't try to add My Favorite Wikis menu, if it appears to already exist */	if (!window.fav_wikis1 || $('#MyFavWikis').length) {		return;	}    /* Start building My Favorite Wikis menu */	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) { var wiki_type = "fandom.com"; var subdomain = "www"; /* Wiki type is fandom.com unless set otherwise by wiki_types key list above */ if (window.wiki_types[key]) { wiki_type = window.wiki_types[key]; }		// For special cases with dashes if (key == 'yurucamp') subdomain = 'yuru-camp'; // Otherwise subdomain is key else subdomain = key; // Add wiki links to part 1 of sub menu 1 $favWikiList.append(			$('').append( $('') .attr('href', '//' + subdomain + '.' + wiki_type + '/') .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) { var wiki_type2 = "fandom.com"; var subdomain2 = "www"; /* Wiki type is fandom.com unless set otherwise by wiki_types key list above */ if (window.wiki_types[key]) { wiki_type2 = window.wiki_types[key]; }       // Need to special case because key can't use dashes if (key == 'littlewitchacademia') { subdomain2 = 'little-witch-academia'; }       else { subdomain2 = key; }		// Add wiki and admin list links to part 2 of sub menu 1 $favWikiList.append(           $('').append( $('') .attr('href', '//' + subdomain2 + '.' + wiki_type2 + '/') .attr('target', '_blank') .text(window.fav_wikis2[key]) .append(                           $(' ')                                .prepend(' ')                                .append( $('') .attr('href', '//' + subdomain2 + '.' + wiki_type2 + '/wiki/Special:ListAdmins') .attr('target', '_blank') .text('(Admins)') )                       )            )        );    });    /* Don't try to add My Favorite Wikis menu, if it appears to already exist */	if (!window.fav_wikis2 || $('#MyFavWikis2').length) {		return;	}    /* Start building My Other Wikis menu */	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('My 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) { var wiki_type3 = "fandom.com"; var subdomain3 = "www"; /* Wiki type is fandom.com unless set otherwise by wiki_types key list above */ if (window.wiki_types[key]) { wiki_type3 = window.wiki_types[key]; }       // Need to special case because key can't use dashes if (key == 'shieldhero') { subdomain3 = 'shield-hero'; }       else if (key == 'steinsgate') { subdomain3 = 'steins-gate'; }       //else if (key == 'toradora') { //   subdomain3 = 'tora-dora'; //}       else { subdomain3 = key }		// Add wiki and admin list links to part 1 (part 3 overall) of sub menu 2 $favWikiList2.append(           $('<li>').append( $('<a>') .attr('href', '//' + subdomain3 + '.' + wiki_type3 + '/') .attr('target', '_blank') .text(window.fav_wikis3[key]) .append(                       $(' ')                            .prepend(' ')                            .append( $('<a>') .attr('href', '//' + subdomain3 + '.' + wiki_type3 + '/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) { var wiki_type4 = "fandom.com"; var subdomain4 = "www"; /* Wiki type is fandom.com unless set otherwise by wiki_types key list above */ if (window.wiki_types[key]) { wiki_type4 = window.wiki_types[key]; }       // Need to special case because key can't use dashes if (key == 'arakawaunderthebridge') { subdomain4 = 'arakawa-under-the-bridge'; }       else if (key == 'sidonianokishi') { subdomain4 = 'sidonia-no-kishi'; }       else { subdomain4 = key; }		// Add wiki and admin list links to part 2 (part 4 overall) of sub menu 2 $favWikiList2.append(           $('<li>').append( $('<a>') .attr('href', '//' + subdomain4 + '.' + wiki_type4 + '/') .attr('target', '_blank') .text(window.fav_wikis4[key]) .append(                       $(' ')                            .prepend(' ')                            .append( $('<a>') .attr('href', '//' + subdomain4 + '.' + wiki_type4 + '/wiki/Special:ListAdmins') .attr('target', '_blank') .text('(Admins)') )                   )            )        );	});    /* Add completed other wikis (favWikis2) HTML blob to profile menu */	$('div.wds-global-navigation__user-menu > div.wds-dropdown__content > ul.wds-list > li:nth-child(3)')		.before($favWikis2);    /* Add completed fav wikis (favWikis) HTML blob to profile menu */	$('div.wds-global-navigation__user-menu > div.wds-dropdown__content > ul.wds-list > li:nth-child(3)')		.before($favWikis); });