Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Greasemonkey (Firefox) or Tampermonkey (Chrome or Safari) script that integrates IBM Verse to a standalone IBM Sametime client. It adds an additional icon/action to the profile badges in IBM Verse
// ==UserScript==
// @name Add Standalone client to Verse
// @namespace https://gist.github.com/nidayand/
// @version 0.7
// @description Integrate IBM Verse to standalone Sametime client (or IBM Notes client)
// @author nidayand
// @match https://mail.notes.na.collabserv.com/verse*
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
// @grant GM_xmlhttpRequest
// @updateURL https://gist.github.com/nidayand/767796526ce4ae7af0c3/raw/Add%2520Standalone%2520client%2520to%2520Verse.user.js
// ==/UserScript==
/* jshint -W097 */
'use strict';
$(document).ready(function(){
var pgCallSametime = function(email){
GM_xmlhttpRequest({
method: "GET",
url: "http://localhost:59449/stwebapi/chat?userId="+email+"&unique="+(new Date().getTime()),
onload: function(response) {
//Don't care
}
});
}
var loaderImg = "data:image/gif;base64,R0lGODlhEAAQAPQAAAAAAP///wYGBsbGxnp6evj4+NjY2CgoKFZWVujo6IiIiJiYmBoaGmZmZjg4OLa2tqioqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAAFUCAgjmRpnqUwFGwhKoRgqq2YFMaRGjWA8AbZiIBbjQQ8AmmFUJEQhQGJhaKOrCksgEla+KIkYvC6SJKQOISoNSYdeIk1ayA8ExTyeR3F749CACH5BAkKAAAALAAAAAAQABAAAAVoICCKR9KMaCoaxeCoqEAkRX3AwMHWxQIIjJSAZWgUEgzBwCBAEQpMwIDwY1FHgwJCtOW2UDWYIDyqNVVkUbYr6CK+o2eUMKgWrqKhj0FrEM8jQQALPFA3MAc8CQSAMA5ZBjgqDQmHIyEAIfkECQoAAAAsAAAAABAAEAAABWAgII4j85Ao2hRIKgrEUBQJLaSHMe8zgQo6Q8sxS7RIhILhBkgumCTZsXkACBC+0cwF2GoLLoFXREDcDlkAojBICRaFLDCOQtQKjmsQSubtDFU/NXcDBHwkaw1cKQ8MiyEAIfkECQoAAAAsAAAAABAAEAAABVIgII5kaZ6AIJQCMRTFQKiDQx4GrBfGa4uCnAEhQuRgPwCBtwK+kCNFgjh6QlFYgGO7baJ2CxIioSDpwqNggWCGDVVGphly3BkOpXDrKfNm/4AhACH5BAkKAAAALAAAAAAQABAAAAVgICCOZGmeqEAMRTEQwskYbV0Yx7kYSIzQhtgoBxCKBDQCIOcoLBimRiFhSABYU5gIgW01pLUBYkRItAYAqrlhYiwKjiWAcDMWY8QjsCf4DewiBzQ2N1AmKlgvgCiMjSQhACH5BAkKAAAALAAAAAAQABAAAAVfICCOZGmeqEgUxUAIpkA0AMKyxkEiSZEIsJqhYAg+boUFSTAkiBiNHks3sg1ILAfBiS10gyqCg0UaFBCkwy3RYKiIYMAC+RAxiQgYsJdAjw5DN2gILzEEZgVcKYuMJiEAOwAAAAAAAAAAAA==";
var retries = 3;
var calling = 0;
var stCheck = function(email, callback, override){
if (calling >0 && typeof override == undefined)
return;
calling +=1;
GM_xmlhttpRequest({
method: "GET",
url: "http://localhost:59449/stwebapi/getstatus?userId="+email+"&unique="+(new Date().getTime()),
onload: function(response) {
if (response.readyState === 4 && response.status === 200){
var res = JSON.parse(response.response);
var msg = res.statusMessage;
if (res.returnCode && res.returnCode == 500){
//User not found return not available
calling = 0;
callback(99,"Not available","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAvVBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADr0nPMAAAAPnRSTlMAAQIDBAUHCAoPExUXHB0eIikuLzY4QEdMTU9RVFtcXV5wfH6DjpSYmpumrcDBw8XIys/a4Ojp6+3v8fX3+eruKtAAAACSSURBVBgZlcFVFoIAAEXBi92F3d3d+fa/LNEjR9AfneEv0fZRlnXdj83oynbJ8zKWQ5mnglzCPCzlUqPvh5Nc2qymBhO5VLiqTEZOt2BMWkBHDiZDaQdUZdukKEoaAUk9XQZZg6YscQhs1Qvh9YCRXspSBSKmD4jmSr2DHkzeEq3Z8TTfSSafPI39Ocy3WIjf3QGv+Cx7krGe5wAAAABJRU5ErkJggg==");
return;
}
if (res.status ==0){
//Not available
/* It might be that the first request fails (Sametime issue). Try again after 2 sec*/
if (override && calling <= retries){
calling = 0;
callback(0,"Not available","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAvVBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADr0nPMAAAAPnRSTlMAAQIDBAUHCAoPExUXHB0eIikuLzY4QEdMTU9RVFtcXV5wfH6DjpSYmpumrcDBw8XIys/a4Ojp6+3v8fX3+eruKtAAAACSSURBVBgZlcFVFoIAAEXBi92F3d3d+fa/LNEjR9AfneEv0fZRlnXdj83oynbJ8zKWQ5mnglzCPCzlUqPvh5Nc2qymBhO5VLiqTEZOt2BMWkBHDiZDaQdUZdukKEoaAUk9XQZZg6YscQhs1Qvh9YCRXspSBSKmD4jmSr2DHkzeEq3Z8TTfSSafPI39Ocy3WIjf3QGv+Cx7krGe5wAAAABJRU5ErkJggg==");
return;
} else {
setTimeout(function(){
stCheck(email, callback, true);
},500);
}
} else if (res.status == 1){
//available (fa-comment, 20px)
callback(1,msg, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAvVBMVEUAAABw7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A9w7A/d70I1AAAAPnRSTlMAAQIDBAUHCAoPExUXHB0eIikuLzY4QEdMTU9RVFtcXV5wfH6DjpSYmpumrcDBw8XIys/a4Ojp6+3v8fX3+eruKtAAAACSSURBVBgZlcFVFoIAAEXBi92F3d3d+fa/LNEjR9AfneEv0fZRlnXdj83oynbJ8zKWQ5mnglzCPCzlUqPvh5Nc2qymBhO5VLiqTEZOt2BMWkBHDiZDaQdUZdukKEoaAUk9XQZZg6YscQhs1Qvh9YCRXspSBSKmD4jmSr2DHkzeEq3Z8TTfSSafPI39Ocy3WIjf3QGv+Cx7krGe5wAAAABJRU5ErkJggg==");
calling = 0;
} else if (res.status == 2 || res.status == 4){
//away
callback(2,msg, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAvVBMVEUAAAD/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP/tDP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RGviHiIESsua+NzAbCeACQAEM0AJDS4fP3+R+qoN61LIJoYOqi6AAAAAElFTkSuQmCC");
calling = 0;
} else if (res.status == 3){
//dnd
callback(3,msg, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAvVBMVEUAAAD7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwP7AwPGWxXwAAAAPnRSTlMAAQIDBAUHCAoPExUXHB0eIikuLzY4QEdMTU9RVFtcXV5wfH6DjpSYmpumrcDBw8XIys/a4Ojp6+3v8fX3+eruKtAAAACSSURBVBgZlcFVFoIAAEXBi92F3d3d+fa/LNEjR9AfneEv0fZRlnXdj83oynbJ8zKWQ5mnglzCPCzlUqPvh5Nc2qymBhO5VLiqTEZOt2BMWkBHDiZDaQdUZdukKEoaAUk9XQZZg6YscQhs1Qvh9YCRXspSBSKmD4jmSr2DHkzeEq3Z8TTfSSafPI39Ocy3WIjf3QGv+Cx7krGe5wAAAABJRU5ErkJggg==");
calling = 0;
}
}
else if (response.readyState === 4){
calling = 0;
}
}
});
}
setInterval(function(){
$(".ic-bizcard-section1").each(function(cardid){
//Check if there already is an appended entry
var card = $(this);
if (card.attr('aria-hidden')=="false" && !(card.find($(".ic-bizcard-sametime-pgothager")).length)){
//Get the email address
var email = card.find($(".ic-bizcard-email-anchor"))[0].innerHTML;
//Get the position of Sametime
card.find($(".ic-bizcard-sametime")).each(function(stid){
var st = $(this);
//Add loader
st.after($("<button tabindex=\"-1\" title=\"Retrieving Sametime status\" class=\"ic-bizcard-sametime-pgothager action act-chat bcKeyNav\" style=\""+(card.attr('aria-label') !== undefined ? "left:300px;top:40px;":"")+"opacity:1;\"><img style=\"width:18px\" src=\""+loaderImg+"\"/></button>"));
stCheck(email, function(id,msg,img){
//Remove loaderImg
card.find($(".ic-bizcard-sametime-pgothager")).each(function(id){
$(this).remove();
});
if (id!=99){
st.after($("<a title=\""+msg+"\"class=\"ic-bizcard-sametime-pgothager action act-chat bcKeyNav\" style=\""+(card.attr('aria-label') !== undefined ? "left:300px;top:40px;":"")+"opacity:1;cursor:default\" data-pgothager=\""+email+"\"><img style=\"width:18px\" src=\""+img+"\"/></a>"));
$(".ic-bizcard-sametime-pgothager").on("click", function(){
pgCallSametime($(this).attr("data-pgothager"));
return false;
});
} else {
st.after($("<button tabindex=\"-1\" class=\"ic-bizcard-sametime-pgothager\" style=\"display:none\"></button>"));
}
});
});
}
//Cleanup closed boxes
if (card.attr('aria-hidden')=="true"){
card.find($(".ic-bizcard-sametime-pgothager")).each(function(id){
$(this).remove();
});
}
});
},2000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment