Skip to content

Instantly share code, notes, and snippets.

@Bonno
Last active June 8, 2018 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bonno/793bf40dba8b14c2dab7d6d6ef5c2c68 to your computer and use it in GitHub Desktop.
Save Bonno/793bf40dba8b14c2dab7d6d6ef5c2c68 to your computer and use it in GitHub Desktop.
  1. After launching Rambox, open the Rambox Dev Tools.
  2. Run this script in the DevTools console

It will pull the team icon from each slack account you're connected to that has finished loading. If you log into another slack account later on in your session, you can run the script again to fill in any missing team icons.

(() => {
const slackWebviews = document.querySelectorAll('webview[src*=".slack.com"]');
const slackTabs = document.querySelectorAll('.x-tab-icon-el[style*="resources/icons/slack.png"]');
[...slackWebviews]
.filter(webview => !webview._slackIconAdded)
.forEach((webview, index) => {
webview.executeJavaScript(`
// lazy man's team icon grabbing method
(() => {
let teamIcon = document.querySelector('.team_icon');
// open team menu if not already open
if (!teamIcon) {
const teamMenu = document.querySelector('#team_menu');
if (teamMenu) {
teamMenu.click();
teamIcon = document.querySelector('.team_icon');
}
}
// bail if no icon found
if (!teamIcon) {
return false;
}
// grab the background image from team icon
const { style: { backgroundImage } } = teamIcon;
// force menu to close after we have the goods
const md = document.createEvent('MouseEvents');
md.initEvent('mousedown', true, true);
document.querySelector('.client_channels_list_container').dispatchEvent(md);
return backgroundImage;
})();
`,
false,
(backgroundImage) => {
if (backgroundImage) {
slackTabs[index].style.backgroundImage = backgroundImage;
webview._slackIconAdded = true;
}
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment