Destiny 2 "Find Fireteam" improvements

Fixes some poor design choices on the Destiny 2 "Find Fireteam" page and filters out spam

目前为 2022-12-23 提交的版本。查看 最新版本

// ==UserScript==
// @name         Destiny 2 "Find Fireteam" improvements
// @namespace    http://tampermonkey.net/
// @version      1.07
// @description  Fixes some poor design choices on the Destiny 2 "Find Fireteam" 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|iamo]|recherche|recrute|recruit[e|ing|ment]|buscamo[s]/;
    var spamStrings = /help-d2.com|mycarry.net|d2-sherpa.com|d2xur.com|game-job.ru|skygold.gg/;
    var defaultTitle = /(.*)\/\/(.*)/;

    var platformSelect = document.querySelector('select[name=platform]');
    var activitySelect = document.querySelector('select[name=activityType]');
    var languageSelect = document.querySelector('select[name=lang]');

    var activities = {
        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: "Dungeon: 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",
    };

    // remove bungie advert

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

    // to prevent the browser from entering an endless loop of page reloads we're using a hash to see if we already reloaded

    function ReloadPage(page) {
        if(window.location.hash == page || window.location.hash == null) return;
        location.href = "https://www.bungie.net/en/ClanV2/FireteamSearch?platform=" +
            platformSelect[platformSelect.selectedIndex].value +
            "&activityType=" +
            activitySelect[activitySelect.selectedIndex].value +
            "&lang=" + languageSelect[languageSelect.selectedIndex].value +
            "#" +
            page;
    }

    // reroute dropdowns to our own function so the userscript still works after using the select boxes

    platformSelect.onchange = (e) => {
        e.preventDefault();
        e.stopPropagation();
        ReloadPage("platform");
    }

    activitySelect.onchange = (e) => {
        e.preventDefault();
        e.stopPropagation();
        ReloadPage("activity");
    }

    languageSelect.onchange = (e) => {
        e.preventDefault();
        e.stopPropagation();
        ReloadPage("language");
    }

    // 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

    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;
        }

        // remove the original post title if it was left blank (which is then replaced by Bungie with the same info we already added)
        var newTitle = (activities[activityId] != null ? activities[activityId] : "N/A");
        if(!defaultTitle.test(title.innerHTML)) {
            newTitle += " | " + title.innerHTML;
        }
        title.innerHTML = newTitle;
    });

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址