User:Fandyllic/wikia.js

//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 = {        en:         'Go to bottom'    },    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) { switch (fadeSwitch) { case 0: $('#jumptobottom').show; break; default: $('#jumptobottom').fadeIn; break; }           } else { switch (fadeSwitch) { case 0: $('#jumptobottom').hide; break; default: $('#jumptobottom').fadeOut; break; }           }        });    }    $('#jumptobottom').click(function { var botPos = document.body.scrollHeight $('body,html').animate({           scrollTop:$(document).height            }, 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));

/* Add link to Recent Changes after Recent Wiki Activity right rail module */ (function {   if(!$('#WikiaRail').exists) {        return;    }    var interval = setInterval(function { if($('#wikia-recent-activity').exists) { clearInterval(interval); $('#wikia-recent-activity .activity-items').after(           $('', { href: '/wiki/Special:RecentChanges' })                .text('See recent changes...')            ); }   }, 100); });

/* Change upper right jaggy button to go to Recent Changes and not Wiki Activity on modernized navigation v2 */ $(function {	$('div.wds-community-header__wiki-buttons > a.wds-button:nth-child(2)').replaceWith('  '); }); /* Add Recent Changes menu item link to Explore menu before Wiki Activity on modernized navigation v2 */ $(function {	$('ul.wds-tabs > li.wds-tabs__tab:nth-child(5) > div.wds-dropdown > div.wds-dropdown__content > ul.wds-list > li:first-child').not('#RC').before('Recent Changes'); });

/* Changes redlinks on Special:WantedFiles to upload links */ $(function {   if ("Special:WantedFiles" == wgPageName) {        $('ol.special a.new').each(function { var m = $(this).attr('href').match(/title=File:([^&]+)/); if (undefined == m[1]) return; $(this).attr('href', '/index.php?title=Special:Upload&wpDestFile=' + m[1]); });   } });

function ChangeRCDetailsArrowIcons { /* Details hidden */ $('a.mw-arr-r > img').replaceWith(''); /* Details showing */ $('a.mw-arr-d > img').replaceWith(''); } addOnloadHook(ChangeRCDetailsArrowIcons);

/* Add "View History" button for Message Wall and threads Add "Edit Greeting" when on user MW page to edit MW Greeting */ function WallTools { if (wgCanonicalNamespace == 'Thread') { $('#WallBrickHeader').append('View History'); }	if (wgCanonicalNamespace == 'Message_Wall' && wgAction != 'history') { $('.WikiaMainContent').prepend(' View History '); if (wgTitle == wgUserName) { $('.UserProfileActionButton').prepend('<img alt="" class="sprite edit-pencil" height="16" src="data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D" width="22"> Edit Greeting	</a>'); }	} } addOnloadHook(WallTools);

/* They aren't really icons, but looked sort of like buttons This is partially broken and can't be edited anymore on CC  Now it shows the labels, but without the rounded corner background */ // Additional UserRights Icons in profile mastheads //importScript('User:Fandyllic/wikia.js/userRightsIcons.js'); // END Additional UserRights Icons in profile mastheads

// ChatHacks // importScriptPage('User:Monchoman45/ChatHacks.js', 'c'); // END ChatHacks

/* Add Recent Changes menu item link to On the Wiki menu */ /* "Modernized" look breaks this $(function {	$('ul.nav > li.nav-item:first-child > ul.subnav-2 li.subnav-2-item:first-child').before('<a class="subnav-2a" data-canonical="recentchanges" href="/wiki/Special:RecentChanges">Recent Changes</a></li>'); }); /* Add Recent Changes before Wiki Activity in Contribute drop-down */ /* "Modernized" look breaks this $(function {	$('a[data-id="wikiactivity"]').replaceWith('<a data-id="recentchanges" accesskey="g" href="/wiki/Special:RecentChanges">Recent Changes</a></li><a data-id="wikiactivity" accesskey="g" href="/Special:WikiActivity">Wiki Activity</a>'); });

/* Dynamically replace favicon with the old curly W with JQuery */ /* DISABLE to see actual favicon $(function {   var link = document.createElement('link');    link.type = 'image/x-icon';    link.rel = 'shortcut icon';    link.href = 'http://images3.wikia.nocookie.net/central/images/archive/6/64/20120405205346%21Favicon.ico';    document.getElementsByTagName('head')[0].appendChild(link); }); /* END dynamically replace favicon with the old curly W */

/* Disable for now function ImgDescEditLink2ImgLink { $('ol.special > li > a.new').each(function {   this.setAttribute("href", this.getAttribute("href").replace(/\&action\=edit/, ""));  }); } addOnloadHook(ImgDescEditLink2ImgLink);

/* Disable for now function ImgDescEditLink2Upload { $('ol.special > li > a.new').each(function {   this.setAttribute("href", this.getAttribute("href").replace(/\&action\=edit\&redlink\=1/, ""));    this.setAttribute("href", this.getAttribute("href").replace(/File:/, "Special:Upload&wpDestFile="));  }); } addOnloadHook(ImgDescEditLink2Upload);

/* Add Recent Changes button after Contribute drop-down */ /* Doesn't seem to work anymore... function RecentChangesAfterContribute { $('nav.contribute').after(' <a data-id="recentchanges" class="wikia-button recentchanges-button secondary" href="/wiki/Special:RecentChanges">RC</a>'); }

/* addOnloadHook(RecentChangesAfterContribute); */

/* Change Wikia Activity button into Recent Changes */ /* Doesn't work with New Wiki Navigation function WikiActivity2RecentChanges { $('a.wikia-button[data-id$="wikiactivity"]').replaceWith('<a data-id="recentchanges" class="wikia-button secondary" accesskey="g" title="Special:RecentChanges" href="/wiki/Special:RecentChanges"><img height="0" width="0" class="sprite activity" src="http://images1.wikia.nocookie.net/common/skins/common/blank.gif">Recent Changes</a>'); } addOnloadHook(WikiActivity2RecentChanges); /*

/* Adding the following CSS support is recommended for WikiActivity2RecentChanges... /- Widen area for Random Page and Wiki Activity buttons -/ .WikiHeader .buttons { width: 290px; }

/* Add History and What Links Here links to 3rd wiki menu after 1st item */ /* function ToolsMenuItems { $('section header nav ul li:nth-last-child(2) ul li:first-child').after('<a href="/index.php?title='+ encodeURIComponent(wgPageName) +'&action=history">History</a></li><a href="/wiki/Special:WhatLinksHere/'+ encodeURIComponent(wgPageName) +'">What Links here</a></li>'); } addOnloadHook(ToolsMenuItems);

/* Add history to the Edit dropdown menu for User pages */ /* Wikia made this the default functionality and now also for User pages function UserHistoryDropdownMenuItem { if ( (wgCanonicalNamespace == 'User') || (wgCanonicalNamespace == 'User_talk') ) { $('ul.wikia-menu-button li:first-child ul li:first-child').after('<a href="/index.php?title='+ encodeURIComponent (wgPageName) +'&action=history">History</a></li>'); } }

addOnloadHook(UserHistoryDropdownMenuItem);

/* Works, but disable for now. */ /* function Talk4Forum { if (wgCanonicalNamespace == 'Forum') { $('ul.wikia-menu-button').after('<a class="wikia-button" href="/wiki/Forum talk:' + wgTitle +'" style="margin-left:1em;">Forum talk</a>'); } } addOnloadHook(Talk4Forum);