NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Customized avatar for Managebac
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Locally show your avatar in managebac.com if your avatar is empty
// @author BlueWhiteElectron
// @copyright 2018, BlueWhiteElectron (https://openuserjs.org/users/BlueWhiteElectron)
// @license MIT
// @match https://*managebac.com/*
// @include https://*managebac.com/*
// @grant GM_Log
//require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/md5.js
// @require http://www.myersdaily.org/joseph/javascript/md5.js
// ==/UserScript==
(function() {
'use strict';
var email = "test@gmail.com";
//在www.gravatar.com注册后 把你的注册邮箱写在后面
//register at www.gravatar.com and type your email above
function update() {
var div_small = document.getElementsByClassName("avatar empty")[0];
var div_large;
var collection = document.getElementsByClassName("avatar large square empty");
if (collection.length >= 1)
{
div_large = collection[0];
}
if (div_small.childElementCount<1) {
var email_hash = md5(email);
var avatar = document.createElement("img");
var large_avatar = document.createElement("img");
var url = "https://www.gravatar.com/avatar/"+email_hash;
avatar.setAttribute("src", url+"?s=50");
large_avatar.setAttribute("src", url+"?s=100");
div_small.appendChild(avatar);
div_large.appendChild(large_avatar);
}
}
var timer;
timer = setInterval(update, 1000);
})();