Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show number of online records in Intercom. Use http://mrcoles.com/bookmarklet/ to convert raw JS to bookmarklet
/* raw JS file -1 */
var num_online = $(".avatar__activity-indicator.o__on").length;
var users_displayed = $(".ember-view.tbl__user-list-row").length;
var msg = num_online + " online" + (num_online == users_displayed ? " but there could be more, scroll down to load more records":"");
/* alert(msg); */
var className = "bookmarklet_message";
var element = $("." + className);
if( $("." + className).length == 0){
element = $("<div class="+className +" style='font-weight: bold; font-size: 30px; color: red; position: absolute; z-index: 1000000; padding: 0.5em; border: 5px solid red; display: nolne; background-color: rgb(255, 255, 255); border-radius: 0.9em; margin-top: 0.5em; text-align: right; right: 1em;'></div>");
element.hide();
$("BODY").prepend(element);
}
else{
element = element.eq(0);
}
element.text(msg).fadeIn(400).delay(1000).fadeOut(1000);
/* raw JS file - 0 */
javascript:(function()%7Bvar%20num_online%20%3D%20%24(%22.avatar__activity-indicator.o__on%22).length%3Bvar%20users_displayed%20%3D%20%24(%22.ember-view.tbl__user-list-row%22).length%3Bvar%20msg%20%3D%20num_online%20%2B%20%22%20online%22%20%2B%20(num_online%20%3D%3D%20users_displayed%20%3F%20%22%20but%20there%20could%20be%20more%2C%20scroll%20down%20to%20load%20more%20records%22%3A%22%22)%3B%2F*%20alert(msg)%3B%20*%2Fvar%20className%20%3D%20%22bookmarklet_message%22%3Bvar%20element%20%3D%20%24(%22.%22%20%2B%20className)%3Bif(%20%24(%22.%22%20%2B%20className).length%20%3D%3D%20%200)%7Belement%20%3D%20%24(%22%3Cdiv%20class%3D%22%2BclassName%20%2B%22%20style%3D'font-weight%3A%20bold%3B%20font-size%3A%2030px%3B%20color%3A%20red%3B%20position%3A%20absolute%3B%20z-index%3A%201000000%3B%20padding%3A%200.5em%3B%20border%3A%205px%20solid%20red%3B%20display%3A%20nolne%3B%20background-color%3A%20rgb(255%2C%20255%2C%20255)%3B%20border-radius%3A%200.9em%3B%20margin-top%3A%200.5em%3B%20text-align%3A%20right%3B%20right%3A%201em%3B'%3E%3C%2Fdiv%3E%22)%3Belement.hide()%3B%24(%22BODY%22).prepend(element)%3B%7Delse%7Belement%20%3D%20element.eq(0)%3B%7Delement.text(msg).fadeIn(400).delay(1000).fadeOut(1000)%7D)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.