びしょの日記 (vipshota’s diary)

これはショタコン的視点からの雑多な日記帳です。まじめな記事が5割、ふまじめな記事が5割でできています。将来黒歴史になる予定です。

ツイッター(Twitter)の新UIからプロモーションを消す

chrome.google.com

だいたい消せればいいという。スクリプト仕様は自己責任で。

f:id:vipshota:20190811000258p:plain:w300

$(function () {
    var timerId = setInterval(function () {
        $('span:contains("プロモーション").css-901oao').each(function () {
            if ($(this).text().indexOf('プロモーション') == 0 && $(this).parent().parent().find('time').length == 0) {
                var p = $(this).parent().parent().parent().parent().parent().parent();
                if (p.css('display') != 'none') {
                    p.css('display', 'none');
                    console.log("ツイート上のプロモーションを非表示にした");
                }
            }
            else if ($(this).text().indexOf('によるプロモーション') > 0 && $(this).parent().parent().find('time').length == 0) {
                var p = $(this).parent().parent().parent().parent();
                if (p.css('display') != 'none') {
                    p.css('display', 'none');
                    console.log($(this).text() + 'トレンドのプロモーションを非表示にした');
                }
            }
        });
    }, 1000);
});

javascript歴3日なので、間違っていたり、こうすると可読性が上がるよというのがあれば、ぜひ教えてほしいです。

AdBlock Plusなどを使った方法は下記に書いてあるけど・・・

takachan.hatenablog.com

mrwk.hateblo.jp

まだどれも万全ではないみたい