Last active
November 2, 2016 18:56
-
-
Save haridsv/19766f9571c76b7d2a72e12a2ae99f53 to your computer and use it in GitHub Desktop.
Copy all members of a chatter group. Click "Show All" and run the bookmarklet. See the member names in the console log.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:s=document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='https://goo.gl/8V4KtP';void(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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