-
-
Save swthomas55/6028667e845f85f463cd452ce4dfd6e9 to your computer and use it in GitHub Desktop.
Scrape thumbnails from slack
This file contains hidden or 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
// Works with the "Workspace Directory" | |
// 1. Visit https://yourteam.slack.com/team | |
// 2. Paste this code in your console | |
// 2a. If there are more members than fit on the screen, you must scroll the directory one screen at a time | |
// and paste the middle block for each screen-full. | |
// Then run the last line again to fill 'data'. | |
// 3. In console: JSON.stringify(data) and copy value. It will contain a map from the Slack username to image URL and | |
// a relative link to the pop-up with user details. I'm still working on retrieving those details. | |
// 4. Use this 'jq' script to clean it up (I will work on folding this back into the javascript). | |
// jq 'with_entries(select(.value.image)|{key,"value":({"image":(.value.image//""|gsub("url\\(";"")|gsub("[)\"]";"";"g")),"link":.value.link})})' | |
// { | |
// "user1": { | |
// "image": "https://ca.slack-edge.com/T03G0NWG1-XXXXXXXXX-b0d7eeca45a7-192", | |
// "link": "/team/XXXXXXXXX" | |
// },... | |
var store = {} | |
$('div.member_details').each(function(i, e) { | |
var el = $(this); | |
var userimage = el.find('span.member_preview_link').css('background-image'); | |
// .replace('url(','').replace(')','').replace(/\"/gi, ""); | |
var email = el.find('span.c-unified_member__secondary-name')[0]; | |
var link=el.find('a.c-unified_member').attr('href'); | |
if (email !== undefined) { | |
store[email.innerHTML] = {image:userimage, link:link}; | |
} | |
}); | |
var data = $.each(store, function(k, value) { if (value) { console.log(k + " =>", value); } } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment