/* * @title Mastodon 連合 or ローカルタイムライン用正規表現フィルタ * @description 名前にも適用されます。 * @include * * @license MIT License * @javascript_url */ /* TODO: -$('.column:last') に直付けしなくなったから $('.column:last') が消えた時に察知して対象を変える必要がある (もっかい $('.columns-area') に MutationObserver つけることにして XPath のあたりでホームの status をスルーさせる) -入力欄に見たくない文字列が常時表示されてるの精神衛生上よくない -省略された URL、media の有無、拡張子、sensitive の有無、必要そうならつける */ ((d = document, o, x, i, c, b, r, n) => { r = new RegExp(decodeURIComponent((d.cookie.split('let_filter_regexp=')[1] || '').split(';')[0]) || 'きのこ|たけのこ|すぎのこ', 'i'); o = new MutationObserver(s => s.forEach(t => { x = d.evaluate('.//div[@class="status" and not(@style)]', t.target, null, 6, x); // この辺速い方がいいかなって思って jQuery 使ってない for (i = 0; i < x.snapshotLength; i++) { n = x.snapshotItem(i); [...n.querySelectorAll('img[alt]')].forEach(f => { f.parentNode.insertBefore(Object.assign( d.createElement('span'), { style: 'display: none;', textContent: f.alt } ), f); }); if ( r.test(n.querySelector('.display-name').textContent) || r.test(n.querySelector('.status__content').textContent) ) n.style.display = 'none'; } })); c = $('#mute-buttons'); if (!c[0]) c = $('
') .css({ position: 'fixed', height: '1em', bottom: '2em', right: 0, zIndex: 99 }) .attr('id', 'mute-buttons').appendTo($('.columns-area')); b = $('').text('?') .click(function (e) { if (b.text() == '?') { b.text('?'); o.observe($('.column:last')[0], { childList: 1, subtree: 1 }); } else { b.text('?'); o.disconnect(); $('.status').filter(":hidden").show(); } }); c.append(b.click()).append( $('').val(r.source).css('width', '10em') .change(function (e, s) { s = this.value; if (s.length) { try { s = new RegExp(s); } catch(e) {} if (typeof s == 'object') { b.text('?'); o.disconnect(); r = s; d.cookie = `let_filter_regexp=${encodeURIComponent(r.source)}; path=\x2F; expires=Tue, 19 Jan 2038 03:14:07 GMT`; } else b.text('?'); } else b.text('?'); b.click(); }) ); })();