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 = "[email protected]";
var email2 = "[email protected]";
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)');
}
});
});