User:KockaAdmiralac/chat.js

$(function {   var config = $.extend({ page: 'Project:Policy', modalWidth: 500 }, window.ChatRulesConfig),       vocab = $.extend({ rules: 'Rules', close: 'Close' }, window.ChatRulesVocab);   $.get(mw.util.wikiScript('index'), { title: config.page, action: 'render' }, function(data) { mw.util.addCSS('#ChatRulesModalContent{height:400px;overflow-y:auto}#ChatRulesModalContent ul{list-style-type:square;margin-left:15px}'); var modalContent = ' ' + data + ' ', button = mw.html.element('button', { class: 'ChatRulesButton' }, vocab.rules), interval = setInterval(function {               if($('#chatOptionsButton').length > 0) {                    $('#chatOptionsButton').after(button);                    $('.ChatRulesButton')                        .wrap(mw.html.element('div', { class: 'chat-button' }))                        .click(function { $.showModal(vocab.rules, modalContent, {                               id: 'ChatRulesModal',                                width: config.modalWidth,                                buttons: [{                                    id: 'ChatRulesCloseButton',                                    defaultButton: true,                                    message: vocab.close,                                    handler: function {                                        $('#ChatRulesModal').closeModal;                                    }                                }]                            }); });                   clearInterval(interval);                }            }, 100); }); });