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.
// ==UserScript==
// @name Wikia Side Rail Social Icons
// @namespace http://userscripts.org/users/Madnessfan34537
// @author Madnessfan34537
// @description Adds social media icons for Destinypedia to the side rail of articles.
// @include http://*.wikia.com/*
// ==/UserScript==
function SocialIcons() {
var userArray = wgPageName.split(":");
$('.WikiaRail').prepend('<div style="right:-1px; top:108px; position: absolute;"><div style="position: absolute;" class="SocialIcon"><div style="float:right;"><a href="https://www.facebook.com/pages/Destinypedia/498321176909780?fref=ts"><img src="http://images.wikia.com/destinypedia/images/8/8f/Facebook_Icon.png"></a></div></div><div style="position: absolute; margin-top:42px" class="SocialIcon"><div style="float:right;"><a href="http://www.twitter.com/DpediaTeam"><img src="http://images.wikia.com/destinypedia/images/9/92/Twitter_Icon.png"></a></div></div><div style="position: absolute; margin-top:84px" class="SocialIcon"><div style="float:right;"><a href="http://halo.wikia.com/wiki/Special:RecentChanges?feed=rss&type=html"><img src="http://images.wikia.com/destinypedia/images/c/c7/RSS_Icon.png"></a></div></div><div style="position: absolute; margin-top:126px" class="SocialIcon"><div style="float:right;"><a href="https://www.bungie.net/en-us/Groups/Detail?groupId=18278"><img src="http://images.wikia.com/destinypedia/images/2/2e/Bungie_Icon.png"></a></div></div><div style="position: absolute; margin-top:168px" class="SocialIcon"><div style="float:right;"><a href="http://www.wikia.com/Mobile%2FGameGuides"><img src="http://images.wikia.com/destinypedia/images/c/c0/Game_Guides_Icon.png"></a></div></div></div>');
}
if (mw.config.get("wgNamespaceNumber") != "user") {
addOnloadHook(SocialIcons);
}
/* Top Ten List module */
$(function() {
// Add the module to the right rail
$('#WikiaRail').bind('DOMNodeInserted', function(event) {
var sidebar = $('#WikiaRecentActivity');
var headerText = 'Vote!';
var topTenList = 'Test List Mark 2';
if (sidebar.size()) {
var listID = topTenList.replace(/ /g,'_');
$('#WikiaRail').unbind('DOMNodeInserted');
var comboString = '<div id="WikiaTopTenModule" class="WikiaTopTenModule module"><h1 class="header">'+ headerText +'</h1><div class="list" id='+ listID +'><div style="text-align:center;" class="loader"><img src="http://static.wikia.com/common/skins/common/images/ajax.gif" alt="Loading..." /></div></div></div>';
$(sidebar).before(comboString);
// Load the top 10 list and insert it into the module
$.getJSON(wgScript,{ 'action': 'ajax', 'rs': 'TopListHelper::checkListStatus', 'title': topTenList, 'cb' : Math.random() }, function(data) {
var canVote = data.canVote;
$('.WikiaTopTenModule .list').load('/wiki/Top_10_list:'+ escape(topTenList) +'?action=render #toplists-list-body ul', function() {
styleList(listID);
if (canVote !== true) {
$('.WikiaTopTenModule .VoteButton').remove();
}
addEventHandlers();
});
});
}
});
// Add event handlers to the top 10 buttons
function addEventHandlers() {
$('.WikiaTopTenModule').on('click', '.VoteButton', function() {
var that = this;
var item = $(this).attr('id');
var list = unescape($(this).parents('.list').attr('id'));
var id = $(this).parents('.list').attr('id');
$(this).parents('.WikiaTopTenModule').find('.header').append('<img class="ajax-loader" src="http://static.wikia.com/common/skins/common/images/ajax.gif" alt="Loading...">');
$(id + ' .VoteButton').css('visibility','hidden');
$.ajax({
url: wgScript,
type: "GET",
dataType: "json",
data: { action: 'ajax', rs: 'TopListHelper::voteItem', title: list+'/'+item }
}).done(function(data) {
$(that).parents('.WikiaTopTenModule').find('.ajax-loader').remove();
var success = data.result;
var html = data.listBody;
if (success !== true) {
$('#' + id + ' .VoteButton').remove();
}
else {
$('#' + id).html(html);
$('#' + id + ' .VoteButton').remove();
styleList(id);
}
}).fail(function(data) {
$(that).parents('.WikiaTopTenModule').find('.ajax-loader').remove();
console.log('An error occurred.');
});
});
}
function styleList(id) {
$('#' + id + ' .NewItemForm').remove();
$('#' + id + ' .create-new-list').remove();
$('#' + id + ' .ItemVotes br').replaceWith(' ');
}
});