Greasy Fork

Messenger Blacklist

This is how you really block people

目前为 2019-06-21 提交的版本。查看 最新版本

// ==UserScript==
// @name         Messenger Blacklist
// @namespace    AAAAAAAA.com
// @version      1.4
// @description  This is how you really block people
// @author       ducktrshessami
// @match        *://www.messenger.com/*
// @run-at       document-end
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==

(function() {
    const blacklist = [ // Fill this list with their Facebook names
        ""
    ];

    function foo() { // Do the thing
        return blacklist.filter((name) => {
            if (name) {
                var member = $("[data-testid='info_panel'] > div > div > div > div > div > div > div > div > span > div > div > ul > li:has(:contains('" + name + "'))");
                member.hide();
                return member.length;
            }
        });
    }

    async function bar(selector) { // Do the other thing
        var targets = $(selector + ":visible");
        if (targets.length) { // Target acquired
            targets.hide();
            console.log("Target destroyed");
        }
    }

    async function foobar(name) { // Do the last thing
        var latest = $("[aria-label='Conversation List'] > [aria-relevant='additions text'] > div > a > div > div > div:last-child > span > span:first-child");
        const nickname = $("[aria-label='Messages'] > div > div:has([alt='" + name + "']) > div > div > [aria-label] > span:first");
        if (nickname.length) {
            if (latest.prop("innerHTML") == nickname.prop("innerHTML")) { // Target acquired
                latest.parent().parent().hide();
                console.log("Target destroyed");
            }
            else {
                latest.parent().parent().show();
            }
        }
    }

    document.body.addEventListener("DOMNodeInserted", function() { // Wait for page change
        foo().forEach((name) => {
            bar("[title^='Seen by " + name + " ']"); // Read receipt
            bar("[aria-label='Messages'] > div > div:has([alt='" + name + "'])"); // Message
            foobar(name);
        });
    });
})();