Skip to content

Instantly share code, notes, and snippets.

@haridsv haridsv/bookmarklet
Last active Nov 2, 2016

Embed
What would you like to do?
Copy all members of a chatter group. Click "Show All" and run the bookmarklet. See the member names in the console log.
javascript:s=document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='https://goo.gl/8V4KtP';void(0);
// From: http://stackoverflow.com/a/14570614/95750
var observeDOM = (function(){
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver,
eventListenerSupported = window.addEventListener;
return function(obj, callback){
if( MutationObserver ){
// define a new observer
var obs = new MutationObserver(function(mutations, observer){
if( mutations[0].addedNodes.length || mutations[0].removedNodes.length )
callback();
});
// have the observer observe foo for changes in children
obs.observe( obj, { childList:true, subtree:true });
}
else if( eventListenerSupported ){
obj.addEventListener('DOMNodeInserted', callback, false);
obj.addEventListener('DOMNodeRemoved', callback, false);
}
}
})();
var memberNames = [];
function collectMembers() {
var members = document.getElementsByClassName("memberDisplayName");
for (var i = 0; i < members.length; ++i) {
memberNames.push(members[i].getAttribute("title"));
}
var nextLink = Sfdc.get(".notLastPage");
if (!nextLink.getAttribute("style") || nextLink.getAttribute("style").indexOf("inline") != -1) {
Sfdc.get(".notLastPage a").click();
}
else {
//window.prompt("Copy to clipboard: Cmd+C/Ctrl+C, Enter", memberNames.join("\n"));
console.log(memberNames.join("\n"));
}
}
// Observe a specific DOM element:
observeDOM( Sfdc.get('.groupMembersContainer .content'), function(){
console.log('dom changed');
collectMembers();
});
collectMembers();
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.