1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ワードミュートがないマストドンインスタンスで擬似的にワードミュートを実現する

Posted at

Qiitadon で使ってる Mastodon のバージョンは少々古いので, ワードミュート機能が実装されていません。

ということで, ブラウザで見ているときに限りそれっぽいことを実現するユーザースクリプトを書いてみました。

TamperMonkey などのユーザースクリプトを実行する拡張機能を導入し, 以下のスクリプトを書きます。

// ==UserScript==
// @name         Mastodon Pseudo Word Mute
// @namespace    http://junjo-ponpo.com/
// @version      0.1
// @description  擬似的にワードミュートする
// @author       ブルーレヰ
// @include      *://qiitadon.com/*
// @require      https://code.jquery.com/jquery-3.3.1.js
// @grant        none
// ==/UserScript==

/* globals $ */

$(function() {
    "use strict";

    /* ミュートしたい単語のリスト */
    const wordmute_list = [
        'うんこ',
        'ちんちん',
        '残業',
    ];

    const observer = new MutationObserver(records => {
        wordmute_list.forEach(element => {
            $('div.status__wrapper').find(`p:contains("${element}")`).closest('article').css('display', 'none');
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
});

細かいカスタマイズは各自でお願いします。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?