User:Ultimate Dark Carnage/global.js

cacheSkip = []; cacheSkipLimit = 1000;

importScriptPage('User:Monchoman45/ChatHacks.js', 'c'); importScriptPage('MessageBlocker/code.js', 'dev');

importArticles({   type: 'script',    articles: [        'u:dev:NullEditButton/code.js',        'u:dev:AntiUnicruft/code.js',        'u:dev:BackToTopButton/code.js',        'u:dev:PortableCSSPad/code.js',        'u:dev:WHAM/code.js',        'u:dev:QuickModTools/loader.js',        'u:dev:CacheCheck/code.js',        'u:dev:MassNullEdit/code.js'    ] });

function Reader(theme, version){ this.theme = theme || 'default'; this.version = version || '1.0.1'; this.skin = mw.config.get('skin', skin); this.loaded = false; this.compact = false; this.page = mw.config.get('wgPageName', wgPageName); this.username = mw.config.get('wgUserName', wgUserName); this.isCSSPage = (location.href.indexOf('.css') > -1) ? true : false; this.isJavaScriptPage = this.isJSPage = (location.href.indexOf('.js') > -1) ? true : false; this.action = mw.config.get('wgAction', wgAction); this.language = mw.config.get('wgUserLanguage', wgUserLanguage); this.availableThemes = this.canonicalThemes = ['default', 'light', 'dark', 'wikia']; }

Reader.prototype.create = function{ var compact = arguments[0] || this.compact; if (!$('#ReaderPage').length){ $('.WikiaSiteWrapper, .global-navigation').hide; var reader = $(' ', {           'class': 'ReaderMode ReaderPage' + ((compact === true) ? ' ReaderCompact' : ''),           'id': 'ReaderPage',            html: [                $(' ', { 'class': 'ReaderHeader ReaderPageHeader', 'id': 'ReaderPageHeader', html: [ $(' ', {                           'class': 'WikiaLogo LogoContainer table-cell',                            'id': 'WikiaLogoContainer',                            html: $('', { 'href': 'http://www.wikia.com', 'class': 'header-link wikia-logo-link', html: function{ var src = ''; $.get('/wiki/Special:WikiActivity', function(data){                                       var gc = $(data).find('.global-navigation')[0],                                            logo = $(gc).find('.wikia-logo img').attr('src');                                        src = logo;                                    }); return $(' ', {                                       'src': src                                    }); }                           })                        }),                        $(' ', {                            'class': 'LocalNavigation WikiNavigation table-cell',                            'id': 'LocalNavigation',                            html: function{                                var mainNav = $('.WikiHeader > nav');                                mainNav.find('.navbackground').remove;                                var wikiNav =                                    'Navigation ' +                                    mainNav.html;                                return wikiNav;                            }                        }), $(' ', {                           'class': 'UserNavigation table-cell',                            'id': 'UserNavigation',                            html: [                                $('', { 'href': '/wiki/User:' + encodeURIComponent(wgUserName), 'class': 'user-nav-link', html: [ $(' ', {                                       'src': (function{ var src = ''; $.get('/wiki/User:' + wgUserName.replace(/ /gi, '_'), function(data){                                               var img_src = $(data).find('#UserProfileMasthead'),                                                    avatar = $(img_src).find('.avatar').attr('src');                                                src = avatar;                                            }); return src; })                                   }),                                    $(' ', {                                        'class': 'username',                                        'data-user': wgUserName,                                        text: wgUserName                                    }) ]                           })                        ]                        })                    ]                }),                $(' ', {                    'class': 'ReaderArticle Reader', 'id': 'ReaderArticle', html: [ $(' ', {                           'class': 'ReaderArticleHeader',                            'id': 'ReaderArticleHeader',                            html: $(' ', { html: wgPageName.replace(/_/gi, ' ') })                       }),                        $(' ', {                            'class': 'ReaderArticleWrapper mw-content-text',                            'id': 'ReaderArticleWrapper',                            html: function{                                var h = $('.WikiaArticle .mw-content').html;                                return h;                            }                        }) ]               })            ]        });        $('body.mediawiki').append(            $(' ', { 'class': 'reader-wrapper', html: reader })       );    } };

Reader.prototype.checkURL = function(value, target){ var r = new RegExp('[\??&]' + value + '=([^&#]*)', 'gi'), result = r.exec(target); if (result === '' || result === null){ return null; } else { return result[1] || 0; } };

Reader.prototype.addTheme = function(theme){ if (this.availableThemes.indexOf(theme) > -1) return; else { if (typeof theme == 'string') this.availableThemes[this.availableThemes.length] = theme; else if (typeof theme == 'object') this.availableThemes.concat(theme); else return; } };

Reader.prototype.addTrigger = function(t){ if (this.language){ var txt = { en: 'Reader mode', es: 'Modo de lector', fr: 'Mode de lecteur', de: 'Lesemodus', el: 'τρόπος αναγνωστών', ar: 'وضع القارئ', ja: 'リーダーモード', ru: 'режим чтения' }, lang = this.language, theme = t || this.theme, themes = this.availableThemes; button_html = $('', {               'class': 'wikia-button secondary reader-trigger',                'id': 'reader-trigger',                'href': 'javascript:;',                text: txt[lang] || 'Reader Mode',                on: {                    'click': function(event){                        $.showCustomModal($(event.target).text, '' + ' ' +                               ' Which theme do you want to use? ' +                               '' + (function{                                       var radioHTML = ;                                        for (var i = 0; i < themes.length; i++){                                            radioHTML +=                                                 ' ' +                                                    '' + themes[i] + ' ' +                                                    '' +                                                ' ';                                        }                                        return radioHTML;                                    }) + ' ' +                           ' ' +                        ' ',                        {                            width: 650, id: 'ReaderModeModal', buttons: [ {                                   message: 'Cancel', id: 'ReaderModeModalCancel', handler: function{ var d = $('#ReaderModeModal'); d.closeModal; }                               },                                {                                    message: 'Confirm', defaultButton: true, id: 'ReaderModeModalConfirm', handler: function{ var v = $('#ReaderModeForm .dynamic-buttons [type="radio"]:checked'), val = v.val; if (location.href.match(/[\?&](?:theme|readermode)=[^&#]*/gi)){ window.location.href += ((window.location.href.indexOf('?') > -1) ? '?readermode=1' : '&readermode=1') + '&theme=' + val; } else { window.location.href += '?readermode=1&theme=' + val; }                                       setTimeout(function{                                            var d = $('#readerModeModal');                                            d.closeModal;                                        }, 1000); }                               }                            ]                        });                    }                }            }), quickReaderMode = $('', {                'class': 'wikia-button QuickReaderMode',                'id': 'QuickReaderMode',                'href': 'javascript:;',                on: {                    click: function{                        if (location.href.match(/[\?&](?:theme|readermode)=[^&#]*/gi)){                            window.location.href += ((window.location.href.indexOf('?') > -1) ? '?readermode=1' : '&readermode=1') + '&theme=' + theme;                       } else {                            window.location.href += '?readermode=1&theme=' + theme;                        }                    }                },                text: 'Reader mode (quick)'            }); $('#WikiaPageHeader').append(button_html, ' ', quickReaderMode); } };

Reader.prototype.init = function(theme, loadUserScripts){ var t = theme || this.theme, loaded = this.loaded, sc = (loadUserScripts === true) ? 'User:' + endodeURIComponent(wgUserName) + '/reader' + ((t != 'default') ? '-' + t : ) + '.js' : , st = (loadUserScripts === true) ? 'User:' + endodeURIComponent(wgUserName) + '/reader' + ((t != 'default') ? '-' + t : ) + '.css' : ; if (loaded === false){ this.addTrigger; if (sc && st) importArticles({           type: 'style',            articles: [st]        }, {            type: 'script',            articles: [sc]        }); loaded = this.loaded = true; }   if (location.href.match(/[\?&](?:.*)=[^&#]*/gi)){ var m = decodeURIComponent(this.checkURL('readermode', location.href)), th = decodeURIComponent(this.checkURL('theme', location.href)); m = Number(m); if (m === 0){ return false; } else if (m == 1){ $('body.mediawiki').addClass('theme-' + th + ' reader-mode-enabled'); Reader.create; }   } };

var RM = new Reader; RM.init;