Answered in this thread
Until now, Facebook Messenger still doesn't offer an option to filter messages within a specific date range. The only option left is to scroll manually through the entire message thread, either by pressing Page up
or Ctrl + Home
, which is very very time-consuming.
So, I wrote a script to automate all the tedious stuff!
-
In Chrome, press
Cmd+Option+C
(orCtrl+Shift+C
on Windows) and click on a "timestamp message" in Messenger.- A "timestamp message" is the timestamp that are sometimes inserted at the top of the messages.
- For example, in Chinese it might appear as "2023/09/26 上午12:51".
-
Switch to the Console tab, and paste the following:
/* select row div */
x = $0; while (x.tagName !== 'DIV' || x.role !== 'row') { x = x.parentNode; } while (x.parentNode.children.length <= 3) { x = x.parentNode; }
- Assuming the timestamp message in your language appears as "YYYY/MM/DD" (eg. "2023/09/26"). Paste the following to Console, and change the TARGET to
TARGET = ['YYYY/MM/']
.- Facebook tends to represent timestamps in different formats.
- For example, in Chinese it might appear as "2023年9月26日 上午12:51" for dates that are near but change to "2022/08/17 上午10:23" when the date is far away.
- If you are not sure what format it might be, you can list all the possibilities, eg.
TARGET = ['2023/09/', '2023年9月']
.
/* set the month; you can list all the possibilities here */
TARGET = ['2023/09/'];
intId = setInterval(() => {
x = x.parentNode.firstChild; x.scrollIntoView();
for (let n of x.parentNode.childNodes) {
d = n.querySelector('div[data-scope="date_break"]');
for (let t of TARGET) {
if (d && d.innerText.startsWith(t)) { clearInterval(intId); return; }
}
}
while (x.parentNode.children.length > 1000) { x.parentNode.lastChild.remove(); }
}, 1000);
- If anything goes wrong, to make it stop simply paste the following to the Console.
clearInterval(intId);
DISCLAIMER: Please use it at your own risk. If you feel unsure please stop and seek for other approach.