MediaWiki:SocialWidgets.js

/** * @name SocialWidgets * @author Manuel de la Fuente (https://manuelfte.com) * @version 1.2.6 * @license CC-BY-SA-3.0 * @description Inserts widgets for social networks at the top of the sidebar */ /* eslint-env jquery */ $(window).load(function {  'use strict';

console.log('SocialWidgets v1.2.6');

var cfg = window.mw.config.get([   'wgIsMainpage',    'wgPageName'  ]);

/* Widgets */ var twitter = '' + 'Follow @AoTWiki' + ' '; var getFacebook = function (height, width) { return '' + ' ' + ' '; };  var instagram = '' + ' ' +   ' ';

/* Inserts the module in the corresponding places */ if (cfg.wgIsMainpage !== true) { // If it's not the homepage var facebook; /* Changes the widgets if the page contains spoilers */ if ($.inArray('Spoilers', window.mw.config.get('wgCategories')) > -1 || cfg.wgPageName === 'Special:WikiActivity') { twitter = '' + 'Tweets by @AoTWiki' + ' ';     facebook = getFacebook(68, 270); } else { facebook = getFacebook(200, 270); }   /* Builds sidebar module */ var sidebarModule = '' + 'Join the Attack on Titan/Shingeki no Kyojin Discord server!' + ' ' +     '' + ' Follow us! ' +       ' ' +            twitter + facebook + instagram + ' ' +     ' ';    if ($('#TOP_RIGHT_BOXAD').length) { // Checks if there are ads $('#TOP_RIGHT_BOXAD').after(sidebarModule, $('#wikia-recent-activity')); // Inserts module and Recent Wiki Activity (if there is) below ads } else if (cfg.wgPageName === 'Special:WikiActivity') { // If there are no ads, checks if it's Special:WikiActivity $('#WikiaRail').prepend(sidebarModule, $('.CommunityCornerModule')); // Inserts module and Community Corner at the top of the sidebar } else { // If there are no ads and it isn't Special:WikiActivity $('#WikiaRail').prepend(sidebarModule, $('#wikia-recent-activity')); // Inserts module at the top of the sidebar } } else { // If it's the homepage /* Builds homepage module */ var homeModule = twitter + getFacebook(290, 290) + instagram; $('#home-social-widgets').html(homeModule); // Inserts homepage module }

/* Twitter SDK and InstaButton */ window.mw.loader.load('//platform.twitter.com/widgets.js'); window.importArticle({ type: 'script', article: 'MediaWiki:InstaButton.js' }); });