MediaWiki:SocialWidgets.js

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

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

/* Widgets */ var twitter = '' + 'Follow @AoTWiki' + ' '; 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;"> ' + ' '; };

/* 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 + getInstagram(270) + ' ' +     ' ';    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) + getInstagram(290); $('#home-social-widgets').html(homeModule); // Inserts homepage module }

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