Last Updated: 04/01/2024
JavaScript utility that allows you to auto delete all your Facebook messages on Messenger.com,. Adds a feature to Facebook that should have already been added.
The easiest way to use this code is by saving it as a bookmark on your browser's bookmark bar.
- Log in to your Facebook account and go to messenger.com.
- Once the page loads, click the bookmark you created in the next step.
- Stay on the messages page until all your messages are deleted. Once a message is deleted, it's gone forever. There is no undelete.
To stop the delete process, simply leave the messages page or refresh the page.
Note: If you're on the "Archived Chats" page and the script redirects you back to the regular "Chats" page, simply close the tab, re-open messenger.com, navigate to the "Archived Chats" page, and click the bookmarklet again.
- Press
Ctrl+D
(Windows) orCmd+D
(Mac) on your keyboard to open the "Create a new bookmark" window. - Title it "Delete FB Messages".
- Click the "Edit" button to change the URL of the bookmark.
- Delete everything in the URL field and replace it with the following code:
javascript:!function(e){var t=function(){var n=window.location.href.includes("archived")?e('div[aria-label="Menu"]'):e('div[aria-label="Menu"]');null!==n?(n.click(),setTimeout(o,200)):console.log("No messages to delete")},o=function(){var t=Array.from(document.querySelectorAll('div[role="menuitem"]')).find(e=>e.textContent.includes("Delete chat"));null!==t?(t.click(),setTimeout(n,200)):console.log("Delete button not found")},n=function(){var t=e('div[aria-label="Delete chat"][role="button"]');null!==t?(t.click(),setTimeout(i,600)):console.log("Confirm button not found")},i=function(){var o=window.location.href.includes("archived")?e('div[aria-label="Menu"]'):e('div[aria-label="Menu"]');null!==o?setTimeout(t,600):console.log("No more messages")};console.log("Deleting messages"),t()}(function(e){return document.querySelector(e)});
- Save the bookmark, preferably to your bookmarks bar for faster access.
You can also run this code using your web browser's console:
- Navigate to messenger.com.
- Press
Ctrl+Shift+I
(Windows) orCmd+Option+I
(Mac) to open the developer tools. - If you don't see the console at the bottom of the window, press the
Esc
key. - Copy the code from the bookmark creation section above and paste it into the console.
- Press
Enter
to run the code.
The console will display "Deleting messages" to indicate that the script is working. Your messages should start deleting. When the script has finished deleting all your messages, it will display "No more messages" in the console.
You can stop the delete process at any time by closing your browser, refreshing the page, or navigating away from messenger.com.
If you see a warning that says "Stop" in red, don't worry. It's just a precaution to stop people from accidentally XSS attacking themselves. This code does not make any external calls and only contains a few lines of code. If you are not comfortable running things from your web console, then don't! Always read and understand what any code will do before running it in the console, regardless of whether you're on Facebook or another site.
This script is provided "as is" without warranty of any kind. The authors are not responsible for any consequences that may arise from using this script. Use at your own risk. Always backup important data before running scripts that can modify or delete your data.
If the script doesn't seem to be working:
- Make sure you are logged into your Facebook account and on messenger.com.
- Check that you have pasted the script correctly into the bookmark URL or console.
- If you get an error in the console, try refreshing the page and running the script again.
- If messages are not being deleted, the script may need to be updated due to changes in Facebook's UI. Please open an issue on the GitHub repository.
- This script can only delete messages that are loaded on the current page. If you have a large number of messages, you may need to scroll down to load more messages and then run the script again.
- The script may need to be updated in the future if Facebook changes the structure of their messages page or archived chats page.
If you'd like to contribute to this project, please:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature
) - Commit your changes (
git commit -m 'Add your feature'
) - Push to the branch (
git push origin feature/your-feature
) - Open a Pull Request
-
2024-04-01: Updated script to work with the latest version of messenger.com, including archived chats. Improved selectors, deletion process, error handling, and documentation.
- Updated by Seth Rose
- https://www.sethrose.dev
- @TheSethRose on š¯•¸
-
2017-01-28: Originally created by Matthew Dunham.
This project is licensed under the MIT License - see the LICENSE file for details.