User:Llanunall/wikia.js

$(document).ready(function {	// prevent double loading	if (window.AITDLOADED) return;

// declare loaded window.AITDLOADED = true;

function addAITDLink { $('',{   			text:  'Read alone in the dark.',    			title: 'Activate a no distractions reading environment',    			href:  '#',    			click: function  {				var newURL = new URL(window.location.href);                                    newURL.searchParams.set('alone', '1');				    newURL.hash = '';				window.location.href = newURL.href;                        }		}).insertAfter('.page-header__separator'); }

function isAITDMode { var currentPage = new URL(window.location.href);

return currentPage.searchParams.get('alone') === '1'; }

function activateAITD { var $styles = 'body{overflow:hidden !important;}#globalNavigation{display:none;}#AITDModal{position:fixed;margi:0;top:0;left:0;width:100%;height:100%;background:#000;padding:50px 0% 50px 0%;color:#fff;font-family:times new roman;font-size:14pt;z-index:200000;overflow-y:scroll;max-width:100%;}#AITDModal p{margin-bottom:25px;text-align:left;width:75%;margin-right:auto;margin-left:auto;}'; $('' + $styles + ' ').appendTo('head'); $(' ', {			id: 'AITDModal',		}).appendTo('body'); $('', {			text: 'x',			href: '#',			title: 'Read with others',			css: {				position: 'fixed',				top: '0',				left: '97%'			},			click: function {				$('#AITDModal').remove;				$('#AITDStyle').remove;			}		}).appendTo('#AITDModal'); $('#AITDModal').append($('#mw-content-text').html); }

// add the button addAITDLink; // check if AITD is activated if (isAITDMode && wgNamespaceNumber === 0) { activateAITD; } });