Loved your script but it doesn't work with the new Facebook UI. I modified your script to get it working with the new one. I don't want to pollute Greasy Fork and would rather update your script, so below is the the code that's working for me. Note the hacky setTimeout, I didn't want to spend too much time debugging. Cheers!
let init = function() {
let facebook = document.getElementById('facebook');
if (facebook !== null) {
const main = facebook.querySelector('[role="main"]');
const newsfeed = facebook.querySelector('[role="feed"]');
if (main && newsfeed) {
let button = document.createElement('button');
newsfeed.parentNode.insertBefore(button, newsfeed)
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);
toggleFeed();
}
}
}
// 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(() => {
init();
}, 0);
Loved your script but it doesn't work with the new Facebook UI. I modified your script to get it working with the new one. I don't want to pollute Greasy Fork and would rather update your script, so below is the the code that's working for me. Note the hacky setTimeout, I didn't want to spend too much time debugging. Cheers!