Last active
November 21, 2019 23:07
-
-
Save spencerhakim/73432e68bca525bbd5f439a8909bc712 to your computer and use it in GitHub Desktop.
Disable Slack WYSIWYG userscript
This file contains 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
// ==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