MediaWiki:SocialWidgets.js

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

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

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) { 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 ($('#ad-container').length) { // Checks if there are ads $('#ad-container').after(sidebarModule, $('#wikia-recent-activity')); // Inserts module and Recent Wiki Activity (if there is) below ads } 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' }); });