How can I refresh the ProtonMail web inbox page once with Tampermonkey?

162
March 11, 2022, at 11:10 AM

I have multiple ProtonMail accounts, and am trying to add an avatar to replace the default first letter of my name in the upper right hand corner of the ProtonMail web interface so I can more easily differentiate which inbox I'm in, like this:

I've worked out the Tampermonkey script below that loads images from my localhost server (on OS X; this could easily load images from imgur, etc.) according to the email address in the browser location bar, and that works.

The issue is that the images only show after I force reload the page once.

Is it possible to force a reload of the page once via Tampermonkey using jQuery or Javascript?

I can't simply use location.reload(); in the script, as that will refresh over and over; I only need to refresh the page once after the inbox loads.

Or is there another way to get the avatars to show on first page load?

// ==UserScript==
// @name         ProtonMail Avatars
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  ProtonMail Avatars
// @author       Me
// @match        https://mail.protonmail.com/*
// @icon         
// @require      https://code.jquery.com/jquery-3.4.1.min.js
// @grant        GM_addStyle
// ==/UserScript==
/* globals jQuery, $, waitForKeyElements */
jQuery(document).ready(function() {
 $(window).bind("load", function() {
  var term = document.title;
  var email1 = "email1@protonmail.com";
  var email2 = "email2@protonmail.com";
  if (term.indexOf(email1)!= -1) {
   $(".user-initials span").css("display","none");
    $(".user-initials").css('background-image','url(http://localhost/email1.png)');
}
 if (term.indexOf(email2)!= -1) {
  $(".user-initials span").css("display","none");
   $(".user-initials").css('background-image','url(http://localhost/email2.png)');
}
 });
});
Rent Charter Buses Company
READ ALSO
I want to make a key combination press on click

I want to make a key combination press on click

I want to make Key Combination Press(WINDOWS + SHIFT + LEFT Arrow) On click on a button

113
How to show a message after check validate of checkbox button?

How to show a message after check validate of checkbox button?

I am using JavaScript to check ValidateThe above input items I use required to check validate

118
add a button below textarea in powerportals using jquery

add a button below textarea in powerportals using jquery

I was wondering if there is away to add a button below a textarea using jqueryI have generated html like below in power portals page

115
Separate panel for Tree view with multi-select checkbox having extra white space

Separate panel for Tree view with multi-select checkbox having extra white space

I am making multi-select tree view with jquery and I need to separate the list to left and right layoutAnd for the separating part, I found a way to do it

140