Destiny 2 LFG improvements

Fixes some poor design choices on the Destiny 2 LFG page and filters out spam

目前為 2022-12-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Destiny 2 LFG improvements
// @namespace    http://tampermonkey.net/
// @version      1.02
// @description  Fixes some poor design choices on the Destiny 2 LFG page and filters out spam
// @author       Richard "mindphlux" Kämmerer
// @match        https://www.bungie.net/en/ClanV2/FireteamSearch*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bungie.net
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    var clanAdverts = /КЛАН|клан|reclut[a|o]|reclutiamo|recrute/;
    var spamStrings = /help-d2.com|mycarry.net|d2-sherpa.com/;

    // remove bungie advert

    document.querySelector('.promo').remove();

    // add textual description of the activity to the post title
    // so people who can't remember dozens of icons can actually understand what's going on

    function TranslateIcons() {

        var activitySelect = {
            0: "Anything",
            2: "Crucible",
            3: "Trials of Osiris",
            4: "Nightfall",
            5: "Anything",
            6: "Gambit",
            7: "Blind Well",
            12: "Nightmare Hunt",
            14: "Altar of Sorrow",
            20: "Raid: Last Wish",
            21: "Raid: Garden of Salvation",
            22: "Deep Stone Crypt",
            23: "Exo Challenge",
            25: "Empire Hunt",
            27: "Exotic Quest",
            28: "Raid: Vault of Glass",
            33: "Dungeon: Shattered Throne",
            34: "Dungeon: Prophecy",
            35: "Dungeon: Pit of Heresy",
            36: "Dares of Eternity",
            37: "Dungeon: Grasp of Avarice",
            38: "Raid: Vow of the Disciple",
            39: "Campaign",
            40: "The Wellspring",
            41: "S16: Battlegrounds",
            43: "Dungeon: Duality",
            44: "S17: Nightmare Containment",
            45: "S17: Sever",
            47: "S18: Ketchcrash",
            48: "S18: Expedition",
            49: "S18: Pirate Hideout",
            50: "Raid: King's Fall",
            51: "Battlegrounds",
            52: "Dungeon: Spire of the Watcher",
            53: "S19: Operations",
        };

        var lis = document.getElementById('clansList').querySelectorAll('li');
        lis.forEach((item, index) => {
            var activityId = item.querySelector('.activity-icon').getAttribute('data-activity');
            var _title = item.querySelector('.title');

            // removes the post if it's spam or a clan ad
            if(spamStrings.test(_title.innerHTML.toLowerCase()) || clanAdverts.test(_title.innerHTML.toLowerCase())) {
                item.remove();
                return;
            }

            _title.innerHTML = (activitySelect[activityId] != null ? activitySelect[activityId] : "N/A") + " | " + _title.innerHTML;
        });
    }

    TranslateIcons();

})();