Skip to content

Instantly share code, notes, and snippets.

@srhb
Created December 2, 2019 20:25
Show Gist options
  • Save srhb/6ed50c05184256b85e29716434675104 to your computer and use it in GitHub Desktop.
Save srhb/6ed50c05184256b85e29716434675104 to your computer and use it in GitHub Desktop.
{ pkgs ? import <nixpkgs> {} }:
# From https://github.com/kfahy/slack-disable-wysiwyg-bookmarklet/blob/master/bin/patch-desktop-app
let patch = ''
(() => {
const disableWysiwygEditor = redux => {
const {
wysiwyg_composer,
wysiwyg_composer_ios,
wysiwyg_composer_webapp,
...payload
} = redux.getState().experiments;
redux.dispatch(
{
type: '[19] Bulk add experiment assignments to redux',
payload
}
);
};
let currentTeamId = null;
const seenTeams = {};
setInterval(() => {
if (!window.slackDebug) return;
const { activeTeamId } = window.slackDebug;
const newId = activeTeamId && activeTeamId !== currentTeamId
if (newId && slackDebug[activeTeamId] && slackDebug[activeTeamId].redux) {
currentTeamId = activeTeamId;
const needsPatching = !seenTeams[activeTeamId];
if (needsPatching) {
seenTeams[activeTeamId] = true;
const checkInterval = setInterval(() => {
const team = slackDebug[activeTeamId];
const wysiwygLoaded = Boolean(
document.querySelector('[data-qa="texty_composer_button"]')
);
if (team.redux && wysiwygLoaded) {
disableWysiwygEditor(team.redux);
clearInterval(checkInterval);
}
});
}
}
}, 50);
})();
'';
in
pkgs.slack.overrideAttrs (oa: {
installPhase = oa.installPhase + ''
asar extract $out/lib/slack/resources/app.asar $out/lib/slack/resources/app.asar.unpacked
cat <<EOF >> $out/lib/slack/resources/app.asar.unpacked/dist/ssb-interop.bundle.js
${patch}
EOF
asar pack $out/lib/slack/resources/app.asar.unpacked $out/lib/slack/resources/app.asar
wrapProgram $out/bin/slack --set SLACK_DEVELOPER_MENU=true
'';
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment