Facebook Anti-Refresh

Prevents Facebook from auto-refreshing the news feed

Install this script?
Author's suggested script

You may also like Facebook Auto Unmute.

Install this script
Autor
areen-c
Dnevne instalacije
1
Ukupno instalacija
17
Ocene
0 0 1
Verzija
1.2
Napravljeno
13/05/2025
Ažurirano
02/06/2025
Size
4,25 КБ
Licenca
MIT
Važi za

Facebook Anti-Refresh Userscript

This userscript prevents Facebook from auto-refreshing your feed when you switch tabs. It keeps your place in the timeline instead of that annoying refresh that makes you lose everything you were reading.

Features

  • 🚫 No more losing your place in the feed
  • 💯 Works with latest Facebook interface
  • 🌐 Supports multiple Facebook domains
  • ⚡ Lightweight and efficient

Installation

  1. Install Tampermonkey or Violentmonkey
  2. Click Install on this page
  3. Script runs automatically on Facebook

How It Works

  • Overrides Page Visibility API
  • Intercepts refresh network requests
  • Blocks visibility events
  • Tracks user activity

Changelog

Version 1.2 (June 2, 2025)

🆕 What's New

Fixed the script completely freezing Facebook. Yeah, that was bad.

🐛 Bug Fixes

  • Fixed "Cannot assign to read only property 'reload'" error - Removed the location.reload override that was causing TypeError spam in console
  • Fixed Facebook becoming unresponsive - Removed overly aggressive MutationObservers that were watching every single DOM change
  • Fixed performance issues - Removed the 5-second re-application loop that was hammering the CPU for no reason

🔧 Technical Changes

  • Simplified network interception - Now only blocks specific refresh endpoints instead of analyzing every request to Facebook
  • Removed unnecessary features that were causing more harm than good:
    • WebSocket interception (wasn't helping with refresh anyway)
    • Service Worker blocking (overkill)
    • Aggressive script injection monitoring
  • Better error handling - Added try-catch blocks so one error doesn't break everything
  • Lighter activity tracking - Only tracks essential user interactions (click, scroll, keypress)

📈 Performance

  • Before: Facebook freezing, console errors, high CPU usage
  • After: Smooth experience, minimal overhead, no errors

💡 Developer Notes

Turns out trying to block EVERYTHING Facebook does is a terrible idea. This version takes a much more targeted approach - only blocking what's actually needed to prevent the refresh. If it works, don't touch it!


Version 1.1 (Original)

⚠️ Known Issue

To close Facebook posts, use ESC key or X button only. Clicking outside triggers redirect to top of feed. Script prevents refresh but not the redirect.

See screenshot below for details.