User:Lience/global.js

// Notifications // For the chathacks. Notifs appear when you're pinged. // Author: Сиба (Siberian Watcher) // Idea: Grozny_Dude // Notifications function sendNotification(title, options) {if (Notification.permission === "granted") {var notification = new Notification(title, options);} else if (Notification.permission !== 'denied') {Notification.requestPermission(function (permission) {if (permission === "granted") {var notification = new Notification(title, options);}});}} var waitMainRoom = setInterval(function {   if (typeof mainRoom !== 'undefined') {        mainRoom.socket.on("chat:add", function { if($('.Chat:first li:last-child').has('.ping').length && !$('.Chat:first li:last-child').hasClass('notified')) { // часть регекспов стырено с ChatLogger.js, часть велосипедил сам // update от KockaAdmiralac: прокачали регекспы. Те, которые из ChatLogger sendNotification($('.Chat:first li:last-child .username').text, {                   body: $('.Chat:first li:last-child .ping').html                            .replace(/( |   ){2,}/g, ' ')                            .replace(/]*>/g, '$1')                            .replace(new RegExp('([^<]*)','g'), function(match,page,title) {return '[' + '['+page.replace(/_/g,' ')+'|'+title+']]'})                            .replace(/\[\[([^\]]*?) {2,}/g, '[' + '[$1 ')                            .replace(/\[\[([^|]*)\|\1]]/g, '[' + '[$1]]')                            .replace(/[^<]*<\/a>/g, '$1')                            .replace('[' + '['+wgServer+'/wiki/]]', wgServer+'/wiki/')                            .replace(/<\/?(span|sub|sup)(\s[a-zA-Z]*\=\".*\")*?>/g, '')                            .replace(//g, 'img:$1') .replace(/]*src="https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9]*)"[^>]*><\/iframe>/g, 'yt:$1'), icon: $('.Chat:first li:last-child > img').attr('src').replace(/scale\-to\-width\-down\/28/, 'scale-to-width-down/150'), dir: 'auto' });               $('.Chat:first li:last-child').addClass('notified');            }        }); clearInterval(waitMainRoom); } }, 250);

// Spoiler alerts // $(function{ localStorage.setItem("SiderailSpoilerWarningRead", "no"); });

// Scripts //

$(function {   // Wide-mode codeeditor    if($(".codeeditor").length > 0) var wideModeCodeeditor = setInterval(function {       if($(".codeeditor .editpage-widemode-trigger").length > 0) {           clearInterval(wideModeCodeeditor); $(".codeeditor .editpage-widemode-trigger").click; }   }, 100);    // Always view removed replies    $(".message-removed.hide").removeClass("hide");    // Empty delete reason    if(mw.config.get('wgAction') && mw.config.get('wgAction') === 'delete') $("#wpReason").val("");    /**     * Name:        Global navbar modifications     * Author:      KockaAdmiralac <1405223@gmail.com>     * Description: Modifies the global navbar to add useful buttons     */    var page = mw.config.get("wgPageName"),    globalLinks = {        "User": "Special:Mypage",        "Talk": "Special:Mytalk",        "Settings": "Special:Preferences",        "RC": "Special:RecentChanges?hideminor=0",        "Contribs": "Special:Contributions/" + mw.config.get('wgUserName'),        "Sandbox": (mw.config.get('wgCityId') === "1289615" ? "" : "w:c:ru.undertale:") + "User:Mamvik/Блокнотик",       "Message Wall": "Message Wall Greeting:Mamvik",        "Full profile": (mw.config.get('wgCityId') === "1289615" ? "" : "w:c:ru.undertale:") + "User:Mamvik/Профайл",       "Global JS": (mw.config.get('wgCityId') === "177" ? "" : "w:") + "Special:Mypage/global.js",        "Global CSS": (mw.config.get('wgCityId') === "177" ? "" : "w:") + "Special:Mypage/global.css",   }, linksContent = "";    for(var prop in globalLinks) linksContent += "" + prop + "";    $(".notifications-container").first.before(' ' + linksContent + ' '); });

/* Import some shit */ importArticles({ type: 'script', articles: [   'w:c:dev:MediaWiki:ChatHacks.js' ]});