Skip to content

Instantly share code, notes, and snippets.

@joshmckibbin
Last active May 6, 2025 19:03
Show Gist options
  • Save joshmckibbin/b3de1c4621e02c3294f355a22a667831 to your computer and use it in GitHub Desktop.
Save joshmckibbin/b3de1c4621e02c3294f355a22a667831 to your computer and use it in GitHub Desktop.

Revisions

  1. joshmckibbin revised this gist May 6, 2025. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions outlook-mb-switcher-bm.html
    Original file line number Diff line number Diff line change
    @@ -25,10 +25,10 @@
    }
    }

    if ( emailIndex >= emails.length - 1 ) {
    emailIndex++;

    if ( emailIndex > emails.length - 1 ) {
    emailIndex = 0;
    } else {
    emailIndex++;
    }

    localStorage.setItem( 'outlookEmailIndex', emailIndex );
  2. joshmckibbin created this gist May 6, 2025.
    36 changes: 36 additions & 0 deletions outlook-mb-switcher-bm.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    javascript:(function() {
    const emails = [
    '[email protected]',
    '[email protected]',
    '[email protected]'
    ];

    const baseUrl = 'https://outlook.office365.com/mail/';

    if ( ! window.location.href.includes( baseUrl ) ) {
    alert( 'This bookmarklet only works on Outlook email pages.' );
    return;
    }

    var emailIndex = localStorage.getItem( 'outlookEmailIndex' );

    if ( emailIndex === null ) {
    emailIndex = 0;

    for( const [i, email] of emails.entries() ) {
    if ( window.location.href.includes(email) ) {
    emailIndex = i;
    break;
    }
    }
    }

    if ( emailIndex >= emails.length - 1 ) {
    emailIndex = 0;
    } else {
    emailIndex++;
    }

    localStorage.setItem( 'outlookEmailIndex', emailIndex );
    window.open( baseUrl + emails[emailIndex], '_self' );
    })();