Feedless Facebook

Remove the news feed from Facebook to prevent distraction

  1. // ==UserScript==
  2. // @name Feedless Facebook
  3. // @author Adam Novak, miXwui
  4. // @version 1.5
  5. // @description Remove the news feed from Facebook to prevent distraction
  6. // @include /https?:\/\/www.facebook.com\/*/
  7. // @noframes
  8. // @run-at document-end
  9. // @grant none
  10. // @namespace https://greasyfork.org/users/22981
  11. // ==/UserScript==
  12.  
  13. // (C) 2020 Adam Novak, miXwui
  14. // MIT license
  15. // Inspired by the Chrome extension "Feedless Facebook":
  16. // https://github.com/owocki/feedlessfacebook
  17.  
  18. let hackPage = function() {
  19. let facebook = document.getElementById('facebook');
  20. if (facebook !== null) {
  21. // This is a real main Facebook page
  22.  
  23. const main = facebook.querySelector('[role="main"]');
  24.  
  25. // Find the newsfeed
  26. const newsfeed = facebook.querySelector('[role="feed"]');
  27. const hider = document.getElementById('hideFeed')
  28.  
  29. if (main && newsfeed && !hider) {
  30. // This is a real main page we haven't done yet
  31.  
  32. // Create a way to show and re-hide the news feed
  33. let button = document.createElement('button');
  34. button.id = 'hideFeed'
  35. newsfeed.parentNode.insertBefore(button, newsfeed)
  36. // Define a way to show and hide the news feed
  37. var feedShown = true
  38. let toggleFeed = function() {
  39. if (feedShown) {
  40. // Hide
  41. newsfeed.style.display='none';
  42. button.innerText = '[+] Show Newsfeed';
  43. feedShown = false;
  44. } else {
  45. // Show
  46. newsfeed.style.display='block';
  47. button.innerText = '[-] Hide Newsfeed';
  48. feedShown = true;
  49. }
  50. }
  51. // Toggle the feed when the button is clicked
  52. button.addEventListener('click', toggleFeed);
  53. // Actually hide the feed
  54. toggleFeed();
  55. }
  56. }
  57. }
  58.  
  59. hackPage();
  60.  
  61. // Not sure the button disappears without a setTimeout
  62. // A rerender or something is clearing out the added button element
  63. // or something but I'm too lazy to spend the time to figure it out eh
  64. setTimeout(hackPage, 1000);
  65.  
  66.  
  67.