Skip to content

Instantly share code, notes, and snippets.

@spencerhakim
Last active November 21, 2019 23:07
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 spencerhakim/73432e68bca525bbd5f439a8909bc712 to your computer and use it in GitHub Desktop.
Save spencerhakim/73432e68bca525bbd5f439a8909bc712 to your computer and use it in GitHub Desktop.
Disable Slack WYSIWYG userscript
// ==UserScript==
// @name Disable Slack WYSIWYG
// @namespace https://gist.github.com/spencerhakim
// @version 1.0
// @description Disables the WYSIWYG editor in Slack
// @author Spencer Hakim
// @match https://app.slack.com/client/*
// @grant unsafeWindow
// ==/UserScript==
window.addEventListener('load', function () {
'use strict';
const slackDebug = window.unsafeWindow.slackDebug;
const BULK_ADD_EXPERIMENTS = slackDebug.redux.actions.experimentsStoreBulkAddExperiments.getType();
const IGNORE_ME = Symbol('Ignore Disable Slack WYSIWYG');
slackDebug.reduxWatcher.addWatcher((state, action) => {
// Ignore other actions, or actions marked as ignorable
if (action.type !== BULK_ADD_EXPERIMENTS || action[IGNORE_ME]) {
return;
}
// Get the experiments, except for the WYSIWYG ones
let {
wysiwyg_composer,
wysiwyg_composer_ios,
wysiwyg_composer_webapp,
...newExperiments
} = state.experiments;
// If the WYSIWYG experiments are already disabled, do nothing
if (!wysiwyg_composer && !wysiwyg_composer_ios && !wysiwyg_composer_webapp) {
return;
}
console.warn("Disabling WYSIWYG...");
slackDebug[slackDebug.activeTeamId].redux.dispatch({
type: BULK_ADD_EXPERIMENTS,
payload: newExperiments,
error: false,
[IGNORE_ME]: true
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment