Clean Twitter Feed

Remove "promoted" posts

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Clean Twitter Feed
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Remove "promoted" posts
// @author       Sylvain Galibert
// @match       *://twitter.com/*
// @match       *://*.twitter.com/*
// @license MIT 
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Every second, check if there is an article (each post on Twitter is in an article element) which contains the text "Promoted" and hides it.
    // This gets rid of all the fake posts.
    // The interval is needed because Twitter constantly load new articles.
    var i = setInterval(function(){
            const articles = document.querySelectorAll("article");
            for (const article of articles){
                const articleContent = article.innerHTML;
                // This works fine, but it's brittle - TODO: identify better the "Promoted" posts to avoid catching posts which merely contain the word "Promoted".
                // note: search takes a regex expression and is case sensitive by default.
                if (articleContent.search("Promoted") !== -1){
                    article.style.display = "none";
                }
            }

    }, 1000);

})();