Since I'm providing additional details, I'm writing my own answer based on the original (instead of editing it).
Yes, there is a way to do this, but this method works only for the web-based Facebook and Messenger; you can't do something similar for the mobile apps.
Basically, Facebook uses timed requests on the server side to check if the client is still available. So the front end (loaded Facebook web page) will periodically send an HTTP request (XHR) with the idle time to their servers.
Here's an example of such request:
Note: I've replaced the user ID which normally would be a number.
If you read the URL above, you'll see the part saying idle=117. This denotes the total number of seconds the account has been idle for. The state=offline stands for whether the chat is turned on or off.
So, to disable this, just add the following rule to your ad blocker's custom list of filters:
To disable on both, Facebook and Messenger, you can add the following two lines:
Or the single line, using regex:
A few drawbacks of this method are that you'll not be able to receive messages in real time and you'll not appear online even if the chat is on. You'll have to refresh the page to receive new messages.
In order to avoid both of these drawbacks, here's one workaround. You can add this line instead:
Or, add this for both, Facebook and Messenger:
The end result of this will be the following:
- When your chat is off, you'll not appear online, your last activity won't be reported, and you won't be able to receive messages in real time.
- When your chat is on, you will appear online, your last activity will be reported, and you'll be able to receive messages in real time.
Unfortunately, there seems to be no other solution since Facebook's front end can fetch messages only when the client periodically reports that they're active, hence the fetching is done once the last activity is reported. Both of these actions are made possible by a single back-end script (*-edge-chat.facebook.com/pull), through the same request; therefore, you can't have one without the other.