MediaWiki:SocialWidgets.js

/** * @name SocialWidgets * @author Manuel de la Fuente (https://manuelfte.com) * @version 1.1.17 * @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.1.17');

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

/* Widgets */ var twitter; var facebook; var getFacebook = function (height, width) { return '' + ' ' + ' '; };  var getInstagram = function (width) { return '' + '<iframe scrolling="no" style="border: none; height: 80px; overflow: hidden; width: ' + width + 'px;" src="data:text/html;charset=utf-8,&lt;html&gt;&lt;body style=&quot;margin: 0;&quot;&gt;&lt;a href=&quot;https://instawidget.net/v/user/attackontitanwiki&quot; id=&quot;link-c91a2877988927980b42557dd8987350de1515c8eba6a70a65fabbbbd0fa36c7&quot;&gt;Follow @attackontitanwiki on Instagram&lt;/a&gt;&lt;script src=&quot;https://instawidget.net/js/instawidget.js?u=c91a2877988927980b42557dd8987350de1515c8eba6a70a65fabbbbd0fa36c7&amp;width=' + width + 'px&quot;&gt;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;"> ' + ' '; };

/* Picks different widgets depending on whether the page contains spoilers or not */ if ($.inArray('Spoilers', window.mw.config.get('wgCategories')) > -1) { twitter = '' + 'Tweets by @AoTWiki' + ' ';   facebook = getFacebook(68, 270); } else { twitter = '' + 'Follow @AoTWiki' + ' ';   facebook = getFacebook(200, 270); }

/* Builds sidebar and home modules */ var sidebarModule = '' + 'Join the Attack on Titan/Shingeki no Kyojin Discord server!' + ' ' +   '' + ' Follow us! ' +     ' ' +          twitter + facebook + getInstagram(270) + ' ' +   ' ';  var homeModule = twitter + getFacebook(290, 290) + getInstagram(290);

/* Inserts the module in their corresponding places */ if (cfg.wgIsMainpage !== true) { // If it's not the homepage 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 modules at the top of the sidebar } } else { // If it's the homepage $('#home-social-widgets').html(homeModule); // Inserts home module }

/* Twitter SDK */ window.mw.loader.load('//platform.twitter.com/widgets.js'); });