User:Parkour2906/global.js

// IgnoreMentions by Andrewds1021 if (window.andrewds1021 && window.andrewds1021.ignore_notifications   && window.andrewds1021.ignore_notifications.has_run) return; if (!window.andrewds1021) { window.andrewds1021 = { ignore_notifications: {} }; } else if (!window.andrewds1021.ignore_notifications) { window.andrewds1021.ignore_notifications = {}; } window.andrewds1021.ignore_notifications.filters = { types: [ "post-at-mention", "thread-at-mention" ],   not: { wiki_ids: [ 571430, // Wings of Fire Wiki 590952, // Wings of Fire Fanon Wiki 2079504, // Stupid Wings of Fire Wiki 1113133, // Murder Mystery 2 Wiki 2051222 // The Experimental Coding Wiki ]   } };

(function {    "use strict";    if (window.andrewds1021 && window.andrewds1021.ignore_notifications && window.andrewds1021.ignore_notifications.has_run) return;   if (!window.andrewds1021) {        window.andrewds1021 = {            ignore_notifications: {}        };    } else if (!window.andrewds1021.ignore_notifications) {        window.andrewds1021.ignore_notifications = {};    }    window.andrewds1021.ignore_notifications.has_run = true;    var unblock_groups = [        "helper",        "staff",        "vstf",        "wiki-manager"    ];    var notification_types = [        "discussion-upvote",        "discussion-post",        "announcement-target",        "post-at-mention",        "thread-at-mention"    ];    var notif_def = jQuery.Deferred;    function getNotifications(obj) {        jQuery.ajax(obj.request).then(function (data) { if (data && data.notifications) obj.notifs = obj.notifs .concat(data.notifications.filter(function (val) { return !val.read; }));           if (data && data._links && data._links.next) { var page = mw.util.getParamValue("page", data._links.next); var time = mw.util.getParamValue("startingTimestamp", data._links.next); if (page && time) { obj.request.data.page = page; obj.request.data.startingTimestamp = time; getNotifications(obj); } else { notif_def.resolve(obj.notifs); }           } else { notif_def.resolve(obj.notifs); }       });    }    var unblock_def = jQuery.Deferred;    function getUnblocks(obj) {        obj.api.get(obj.request).then(function (data) { if (data && data.users) data.users.forEach(function (val) {               obj.ids.push(String(val.userid));            }); if (data && data["query-continue"] && data["query-continue"].groupmembers               && data["query-continue"].groupmembers.gmoffset) { obj.request.gmoffset = data["query-continue"].groupmembers.gmoffset; getUnblocks(obj); } else { unblock_def.resolve(obj.ids); }       });    }    mw.loader.using([ "mediawiki.api", "mediawiki.util" ]).then(function { if (window.andrewds1021.ignore_notifications.hide) mw.util.addCSS(             "#notificationContainer .wds-notification-card:not(.wds-is-unread) {"            + "    display: none;"            + "}"            + "#notificationContainer.wds-has-lines-between .wds-notification-card {"            + "    border-bottom: 0;"            + "}"            + "#notificationContainer.wds-has-lines-between .wds-notification-card"            + ".wds-is-unread ~ .wds-notification-card.wds-is-unread {"            + "    border-top: 1px solid #bed1cf;"            + "}"        ); getNotifications({           notifs: [],            request: {                url: "https://services.fandom.com/on-site-notifications/notifications",                type: "GET",                crossDomain: true,                traditional: true,                xhrFields: {                    withCredentials: true                },                data: {                    contentType: notification_types                },                dataType: "json"            }        }); getUnblocks({           api: new mw.Api,            ids: [],            request: {                action: "query",                list: "groupmembers",                gmgroups: unblock_groups.join("|"),                gmlimit: 500            }        }); });   function cleanFilterProperty(prop) {        if (prop && ((typeof prop == "string") || (typeof prop == "number"))) {            prop = [prop];        } else if (!Array.isArray(prop)) {            prop = [];        }        prop = prop.filter(function (val, idx, arr) { return idx == arr.indexOf(val); });       return prop;    }    function cleanFiltersAndGetNames(filters) {        if (filters && (typeof filters == "object")) {            filters = [filters];        } else if (!Array.isArray(filters)) {            filters = [];        }        filters.forEach(function (val) { val.not = cleanFiltersAndGetNames(val.not); val.wiki_ids = cleanFilterProperty(val.wiki_ids); val.wiki_names = cleanFilterProperty(val.wiki_names); val.user_ids = cleanFilterProperty(val.user_ids); val.user_names = cleanFilterProperty(val.user_names); val.types = cleanFilterProperty(val.types); });       return filters;    }    var filters = cleanFiltersAndGetNames(window.andrewds1021.ignore_notifications.filters);    var whitelist = !!window.andrewds1021.ignore_notifications.whitelist;    function matchesFilters(notif, filters, white) {        var matches = false;        var filt, wiki, user, type;        for (var i = 0; !matches && (i < filters.length); i++) {            filt = filters[i];            wiki = (filt.wiki_ids.length == 0) && (filt.wiki_names.length == 0);            wiki = wiki || filt.wiki_ids.some(function (val) { return val == notif.community.id; });           wiki = wiki || filt.wiki_names.some(function (val) { return val == notif.community.name; });           user = (filt.user_ids.length == 0) && (filt.user_names.length == 0);            if (white) {                user = user || notif.events.latestActors.some(function (val) { return (filt.user_ids.indexOf(val.id) != -1) || (filt.user_names.indexOf(val.name) != -1); });           } else {                user = user || notif.events.latestActors.every(function (val) { return (filt.user_ids.indexOf(val.id) != -1) || (filt.user_names.indexOf(val.name) != -1); });           }            type = filt.types.length == 0;            type = type || filt.types.some(function (val) { return val == notif.events.latestEvent.type; });           matches = wiki && user && type                && !matchesFilters(notif, filt.not, !white);        }        return matches;    }    function containsUnblocked(users, unblock) {        return users.some(function (val) { return unblock.indexOf(val.id) != -1; });   }    function listsAllUsers(event) {        return event.totalUniqueActors == event.latestActors.length;    }    jQuery.when(notif_def, unblock_def).then(function (notifs, unblock) { var to_dismiss = []; notifs.forEach(function (val) {           if (listsAllUsers(val.events) && !containsUnblocked(val.events.latestActors, unblock) && (matchesFilters(val, filters, whitelist) != whitelist))               to_dismiss.push(val.refersTo.uri);        }); if (!to_dismiss.length) return; jQuery.ajax({           url: "https://services.fandom.com/on-site-notifications"                + "/notifications/mark-as-read/by-uri",            type: "POST",            crossDomain: true,            xhrFields: {                withCredentials: true            },            data: JSON.stringify(to_dismiss),            contentType: "application/json; charset=UTF-8"        }).then(function  {            to_dismiss.forEach(function (val) { var cards = document.querySelectorAll("#notificationContainer"                   + " li.wds-is-unread[data-uri=\"" + val + "\"]") for (var i = 0; i < cards.length; i++) { cards[i].classList.remove("wds-is-unread"); }           });            var counter = document.getElementById("onSiteNotificationsCount");            var num_unread = NaN;            if (counter) num_unread = parseInt(counter.textContent);            if (!isNaN(num_unread)) {                num_unread = Math.max(num_unread - to_dismiss.length, 0);                counter.textContent = num_unread;            }        }); }); });

// AnnouncementsIgnore window.announcementsIgnore = { option: 'opt-out-all', exceptWikiIds: [ 571430, // Wings of Fire Wiki 590952, // Wings of Fire Fanon Wiki 2079504, // Stupid Wings of Fire Wiki 1113133, // Murder Mystery 2 Wiki 2051222 // The Experimental Coding Wiki ] };

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:AjaxThreadUnfollow/code.js',        'u:dev:MediaWiki:AnnouncementsIgnore.js',        'u:dev:MediaWiki:EditBio/code.js',        'u:dev:MediaWiki:Matrix.js',        'u:dev:MediaWiki:PortableCSSPad/code.js'    ] });

// Responsive Mobile Skin $('head').append('');