Greasy Fork

Greasy Fork is available in English.

Messenger Blacklist

This is how you really block people

当前为 2019-06-21 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
        });
    });
})();