User:Servian/wikia.js
From Drunkapedia
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* add a button that increases the content size and hides the rail */
function CreateContentResizeButton() {
if(wgTitle != wgMainPageTitle) {
$('ul.wikia-menu-button').after('<ul class="wikia-menu-button" id="resizeButton" style="margin-left:10px"><a onclick="ExpandContent();" data-id="resizeButton" style="color:#fff;" title="Expands the content area. Note that this will hide the side rail."> Expand <--> </a></ul>');
}
}
addOnloadHook(CreateContentResizeButton);
function ExpandContent() {
$('header#WikiaPageHeader.WikiaPageHeader details').css({"width": '980px'});
$('article#WikiaMainContent.WikiaMainContent').css({"width": '1000px'});
$('div#catlinks.catlinks').css({"width": '1000px'});
$('div#WikiaRail.WikiaRail').css({"display": 'none'});
$('ul#resizeButton').replaceWith('<ul class="wikia-menu-button" id="resizeButton" style="margin-left:10px"><a onclick="CompressContent();" data-id="resizeButton" style="color:#fff;" title="Compress the content area back to its original width, and restore the side rail."> Compress >--< </a></ul>');
}
function CompressContent() {
$('header#WikiaPageHeader.WikiaPageHeader details').css({"width": '670px'});
$('article#WikiaMainContent.WikiaMainContent').css({"width": '680px'});
$('div#catlinks.catlinks').css({"width": '638px'});
$('div#WikiaRail.WikiaRail').css({"display": 'block'});
$('ul#resizeButton').replaceWith('<ul class="wikia-menu-button" id="resizeButton" style="margin-left:10px"><a onclick="ExpandContent();" data-id="resizeButton" style="color:#fff;" title="Expands the content area. Note that this will hide the side rail."> Expand <--> </a></ul>');
}
/* Adding the following CSS support is recommended for WikiActivity2RecentChanges()...
/- Widen area for Random Page and Wiki Activity buttons -/
.WikiHeader .buttons {
width: 290px;
}
*/
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);
/* Add history to the Edit dropdown menu for pages */
function HistoryDropdownMenuItem() {
$('ul.wikia-menu-button li:first-child ul li:first-child').before('<li><a href="/index.php?title='+ encodeURIComponent (wgPageName) +'&action=history">History</a></li>');
}
addOnloadHook(HistoryDropdownMenuItem);
/* The above solution works better
function History4EditProfile() {
$('a.wikia-button[data-id$="editprofile"]').before('<a class="wikia-button" href="/wiki/' + wgPageName + '?action=history" accesskey="h" data-id="history">History</a>');
if ( (wgCanonicalNamespace == 'User') || (wgCanonicalNamespace == 'User_talk') ) {
$('ul.wikia-menu-button').before('<a class="wikia-button" href="/wiki/' + wgPageName + '?action=history" accesskey="h" data-id="history">History</a>');
}
}
addOnloadHook(History4EditProfile);
*/
function Return2PatrolledPage() {
$('p#mw-returnto > a').before('<a href="/wiki/' + wgPageName + '">' + wgTitle + '</a> or ');
}
addOnloadHook(Return2PatrolledPage);