Feedless Facebook

Remove the news feed from Facebook to prevent distraction

スクリプトをインストールするには、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       Feedless Facebook
// @author     Adam Novak, miXwui
// @version    1.5
// @description Remove the news feed from Facebook to prevent distraction
// @include    /https?:\/\/www.facebook.com\/*/
// @noframes
// @run-at     document-end
// @grant      none
// @namespace https://greasyfork.org/users/22981
// ==/UserScript==

// (C) 2020 Adam Novak, miXwui
// MIT license
// Inspired by the Chrome extension "Feedless Facebook":
// https://github.com/owocki/feedlessfacebook

let hackPage = function() {
  let facebook = document.getElementById('facebook');
  if (facebook !== null) {
    // This is a real main Facebook page

    const main = facebook.querySelector('[role="main"]');

    // Find the newsfeed
    const newsfeed = facebook.querySelector('[role="feed"]');
    
    const hider = document.getElementById('hideFeed')

    if (main && newsfeed && !hider) {
      // This is a real main page we haven't done yet

      // Create a way to show and re-hide the news feed
      let button = document.createElement('button');
      button.id = 'hideFeed'
      newsfeed.parentNode.insertBefore(button, newsfeed)
      // Define a way to show and hide the news feed
      var feedShown = true
      let toggleFeed = function() {
        if (feedShown) {
          // Hide
          newsfeed.style.display='none';
          button.innerText = '[+] Show Newsfeed';
          feedShown = false;
        } else {
          // Show
          newsfeed.style.display='block';
          button.innerText = '[-] Hide Newsfeed';
          feedShown = true;
        }
      }
      // Toggle the feed when the button is clicked
      button.addEventListener('click', toggleFeed);
      // Actually hide the feed
      toggleFeed();
    }
  }
}

hackPage();

// Not sure the button disappears without a setTimeout
// A rerender or something is clearing out the added button element
// or something but I'm too lazy to spend the time to figure it out eh
setTimeout(hackPage, 1000);