Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save elibosley/6acb8850ad1f9f208c30d7c7e2842b89 to your computer and use it in GitHub Desktop.

Select an option

Save elibosley/6acb8850ad1f9f208c30d7c7e2842b89 to your computer and use it in GitHub Desktop.

Revisions

  1. elibosley revised this gist Nov 1, 2017. 2 changed files with 18 additions and 20 deletions.
    31 changes: 13 additions & 18 deletions archive-all-facebook-messages.js
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,17 @@
    function archive_all(testOnly) {
    var someMessages, archiveButton;

    if (testOnly === "undefined") { testOnly = false; }

    someMessages = $("li._k- span.accessible_elem");
    console.log("Found", someMessages.length, "messages to archive in your inbox.");

    archiveButton = null;
    someMessages.each(function () {
    if (testOnly) {
    console.log("*DEBUG Only* Archived:", $(this).text());
    } else {
    archiveButton = $(this).parent().parent().parent().prev().children()[1];
    archiveButton.click();
    }
    });
    function archive_all(testOnly) {

    messages = $("._5blh")
    console.log("Found", messages.length, "messages on messsenger.");
    if (!testOnly) {
    location.reload();
    for (i = 0; i < messages.length; i++) {
    try {
    messages[i].click()// open dialog
    $("li:contains('Archive')").last().click()
    }
    catch (TypeError) {
    console.log("TypeError")
    }
    }
    }
    }
    }
    7 changes: 5 additions & 2 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,15 @@ Because who doesn't have an inbox full of "I got a new phone", event-based group

    Surprisingly, Facebook has not implemented a way to archive many messages in your inbox. This script provides that solution.

    UPDATE:
    THIS SCRIPT HAS BEEN UPDATED TO WORK AND IS TESTED AS WORKING (OCTOBER 31st, 2017 (spooky)). LET ME KNOW IF IT DOESN'T WORK FOR YOU!

    Quickstart
    ----------

    Load [Facebook Messages](https://www.facebook.com/messages/) in a new tab.

    Open the JavaScript console and paste [the contents of jquery.min.js](http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js) into the console.
    Open the JavaScript console and paste [the contents of jquery.min.js](https://code.jquery.com/jquery-git.min.js) into the console.

    Paste the contents of `archive-all-facebook-messages.js` into the console.

    @@ -25,6 +28,6 @@ When you're ready to run for real:
    Caveats
    -------

    - Currently only detects the list of messages visible to the user in the page. You can work around this by repeatedly scrolling the message list pane to the bottom until all messages are loaded. I plan to automate this step soon.
    - Currently only detects the list of messages visible to the user in the page. You can work around this by repeatedly scrolling the message list pane to the bottom until all messages are loaded. I plan to automate this step soon. (Maybe)
    - There is no way to whitelist certain messages from being archived. Currently, you can manually unarchive select messages from the archived view.
    - Sometimes the messages page remains cached after the script reloads it. Reloading it once by hand solves this.
  2. @tedmiston tedmiston revised this gist Dec 26, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion archive-all-facebook-messages.js
    Original file line number Diff line number Diff line change
    @@ -16,5 +16,7 @@ function archive_all(testOnly) {
    }
    });

    if (!testOnly) { location.reload(); }
    if (!testOnly) {
    location.reload();
    }
    }
  3. @tedmiston tedmiston revised this gist Dec 25, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,4 @@ Caveats

    - Currently only detects the list of messages visible to the user in the page. You can work around this by repeatedly scrolling the message list pane to the bottom until all messages are loaded. I plan to automate this step soon.
    - There is no way to whitelist certain messages from being archived. Currently, you can manually unarchive select messages from the archived view.
    - Sometimes the message page remains cached after the script reloads. Reloading it once by hand solves this.
    - Sometimes the messages page remains cached after the script reloads it. Reloading it once by hand solves this.
  4. @tedmiston tedmiston revised this gist Dec 25, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -26,4 +26,5 @@ Caveats
    -------

    - Currently only detects the list of messages visible to the user in the page. You can work around this by repeatedly scrolling the message list pane to the bottom until all messages are loaded. I plan to automate this step soon.
    - No way to whitelist certain messages from being archived. Currently, you can manually unarchive select messages from the archived view.
    - There is no way to whitelist certain messages from being archived. Currently, you can manually unarchive select messages from the archived view.
    - Sometimes the message page remains cached after the script reloads. Reloading it once by hand solves this.
  5. @tedmiston tedmiston revised this gist Dec 25, 2014. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions archive-all-facebook-messages.js
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,5 @@ function archive_all(testOnly) {
    }
    });

    if (!testOnly) {
    location.reload();
    }
    if (!testOnly) { location.reload(); }
    }
  6. @tedmiston tedmiston revised this gist Dec 25, 2014. 1 changed file with 17 additions and 15 deletions.
    32 changes: 17 additions & 15 deletions archive-all-facebook-messages.js
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,22 @@
    function archive_all(testOnly) {
    if (typeof(testOnly) === "undefined") { testOnly = false };
    var someMessages, archiveButton;

    var someMessages = $("li._k- span.accessible_elem");
    console.log("Found", someMessages.length, "messages to archive in your inbox.");
    if (testOnly === "undefined") { testOnly = false; }

    var archiveButton = null;
    someMessages.each(function(){
    if (testOnly) {
    console.log("*DEBUG Only* Archived:", $(this).text());
    } else {
    archiveButton = $(this).parent().parent().parent().prev().children()[1];
    archiveButton.click();
    }
    });
    someMessages = $("li._k- span.accessible_elem");
    console.log("Found", someMessages.length, "messages to archive in your inbox.");

    if (!testOnly) {
    location.reload();
    }
    archiveButton = null;
    someMessages.each(function () {
    if (testOnly) {
    console.log("*DEBUG Only* Archived:", $(this).text());
    } else {
    archiveButton = $(this).parent().parent().parent().prev().children()[1];
    archiveButton.click();
    }
    });

    if (!testOnly) {
    location.reload();
    }
    }
  7. @tedmiston tedmiston revised this gist Dec 25, 2014. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -8,17 +8,17 @@ Surprisingly, Facebook has not implemented a way to archive many messages in you
    Quickstart
    ----------

    1. Load [Facebook Messages](https://www.facebook.com/messages/) in a new tab.
    Load [Facebook Messages](https://www.facebook.com/messages/) in a new tab.

    2. Open the JavaScript console and paste [the contents of jquery.min.js](http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js) into the console.
    Open the JavaScript console and paste [the contents of jquery.min.js](http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js) into the console.

    3. Paste the contents of `archive-all-facebook-messages.js` into the console.
    Paste the contents of `archive-all-facebook-messages.js` into the console.

    4. If you want to only test the results before actually running the archiving, there's a param for that:
    If you want to only test the results before actually running the archiving, there's a param for that:

    archive_all(testOnly=true);

    5. When you're ready to run for real:
    When you're ready to run for real:

    archive_all();

  8. @tedmiston tedmiston revised this gist Dec 25, 2014. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -8,17 +8,17 @@ Surprisingly, Facebook has not implemented a way to archive many messages in you
    Quickstart
    ----------

    Load [Facebook Messages](https://www.facebook.com/messages/) in a new tab.
    1. Load [Facebook Messages](https://www.facebook.com/messages/) in a new tab.

    Open the JavaScript console and paste in [the contents of jquery.min.js](http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js).
    2. Open the JavaScript console and paste [the contents of jquery.min.js](http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js) into the console.

    Paste the contents of `archive-all-facebook-messages.js` into the console.
    3. Paste the contents of `archive-all-facebook-messages.js` into the console.

    If you want to only test the results before actually running the archiving, there's a param for that:
    4. If you want to only test the results before actually running the archiving, there's a param for that:

    archive_all(testOnly=true);

    When you're ready to run for real:
    5. When you're ready to run for real:

    archive_all();

  9. @tedmiston tedmiston revised this gist Dec 25, 2014. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,9 @@ Surprisingly, Facebook has not implemented a way to archive many messages in you
    Quickstart
    ----------

    Load https://www.facebook.com/messages/ in a new tab.
    Load [Facebook Messages](https://www.facebook.com/messages/) in a new tab.

    Open the JavaScript console and paste in the contents of jQuery from this file:
    http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
    Open the JavaScript console and paste in [the contents of jquery.min.js](http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js).

    Paste the contents of `archive-all-facebook-messages.js` into the console.

  10. @tedmiston tedmiston revised this gist Dec 25, 2014. 3 changed files with 1 addition and 2 deletions.
    1 change: 0 additions & 1 deletion Archive All Facebook Messags
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    .
    File renamed without changes.
    2 changes: 1 addition & 1 deletion README.md → readme.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ Load https://www.facebook.com/messages/ in a new tab.
    Open the JavaScript console and paste in the contents of jQuery from this file:
    http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js

    Paste the contents of `archive-all.js` into the console.
    Paste the contents of `archive-all-facebook-messages.js` into the console.

    If you want to only test the results before actually running the archiving, there's a param for that:

  11. @tedmiston tedmiston revised this gist Dec 25, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Archive All Facebook Messags
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    .
  12. @tedmiston tedmiston created this gist Dec 25, 2014.
    30 changes: 30 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    Facebook - Archive All Messages
    ===============================

    Because who doesn't have an inbox full of "I got a new phone", event-based group chats, and old lingering messages in their Facebook Messages?

    Surprisingly, Facebook has not implemented a way to archive many messages in your inbox. This script provides that solution.

    Quickstart
    ----------

    Load https://www.facebook.com/messages/ in a new tab.

    Open the JavaScript console and paste in the contents of jQuery from this file:
    http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js

    Paste the contents of `archive-all.js` into the console.

    If you want to only test the results before actually running the archiving, there's a param for that:

    archive_all(testOnly=true);

    When you're ready to run for real:

    archive_all();

    Caveats
    -------

    - Currently only detects the list of messages visible to the user in the page. You can work around this by repeatedly scrolling the message list pane to the bottom until all messages are loaded. I plan to automate this step soon.
    - No way to whitelist certain messages from being archived. Currently, you can manually unarchive select messages from the archived view.
    20 changes: 20 additions & 0 deletions archive-all.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    function archive_all(testOnly) {
    if (typeof(testOnly) === "undefined") { testOnly = false };

    var someMessages = $("li._k- span.accessible_elem");
    console.log("Found", someMessages.length, "messages to archive in your inbox.");

    var archiveButton = null;
    someMessages.each(function(){
    if (testOnly) {
    console.log("*DEBUG Only* Archived:", $(this).text());
    } else {
    archiveButton = $(this).parent().parent().parent().prev().children()[1];
    archiveButton.click();
    }
    });

    if (!testOnly) {
    location.reload();
    }
    }