kfahy / slack-disable-wysiwyg-bookmarklet

Disables the WYSIWYG editor in Slack.
MIT License
823 stars 23 forks source link

NODE_OPTIONS for slack desktop #9

Open devsnek opened 4 years ago

devsnek commented 4 years ago

I don't use slack, but I thought it might be helpful to share this technique:

Create a file: /path/to/file.js Set your NODE_OPTIONS to -r /path/to/file.js

Put some protections at the start, because this will now run every time any node.js starts on your computer.

(() => {
  if (typeof window === 'undefined') {
    return;
  }

  if (!window.location.href.includes('slack.com')) {
    return;
  }

  const redux = slackDebug[slackDebug.activeTeamId].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 });
})();
Santiclause commented 4 years ago

This is certainly a neat concept, but after hacking at it for a bit over an hour I can't find any way to leverage this technique for Slack, likely because it's an electron app, and you need this function to run inside the BrowserWindow directly

devsnek commented 4 years ago

It should run inside the BrowserWindow, in fact prior to electron's preload. I've used this with some success on applications like Discord.

Did you set NODE_OPTIONS in your bashrc/zshrc/fish.config? If so, slack probably wouldn't see it. You'd need to put it somewhere like /etc/environment, /etc/launchd.conf, etc.