Skip to content

Instantly share code, notes, and snippets.

@subfission
Created August 27, 2018 22:00
Show Gist options
  • Select an option

  • Save subfission/50e56fdec4b336f33b65cb8651e8e995 to your computer and use it in GitHub Desktop.

Select an option

Save subfission/50e56fdec4b336f33b65cb8651e8e995 to your computer and use it in GitHub Desktop.
Slack full customization file
// This file belongs in /Applications/Slack.app/Resources/app.asar.unpacked/src/static/ssb-interop.js
/**
* The preload script needs to stay in regular ole JavaScript, because it is
* the point of entry for electron-compile.
*/
if (window.location.href !== 'about:blank') {
const preloadStartTime = process.hrtime();
const { ipcRenderer, remote } = require('electron');
ipcRenderer.on('SLACK_SET_DESKTOP_INTEROP_METADATA', (_event, ...args) =>
args.forEach(({ key, value }) => window[key] = value)
);
const { init } = require('electron-compile');
const { assignIn } = require('lodash');
const path = require('path');
const { isPrebuilt } = require('../utils/process-helpers');
const profiler = require('../utils/profiler.js');
if (profiler.shouldProfile()) profiler.startProfiling();
//tslint:disable-next-line:no-console
process.on('uncaughtException', (e) => console.error(e));
/**
* Patch Node.js globals back in, refer to
* https://electron.atom.io/docs/api/process/#event-loaded.
*/
const processRef = window.process;
process.once('loaded', () => {
window.process = processRef;
});
/**
* loadSettings are just the command-line arguments we're concerned with, in
* this case developer vs production mode.
*
* Note: we are using one of property in loadSettings to call electron-compile init,
* so can't get rid of calling remote synchronously here.
*/
const loadSettings = window.loadSettings = assignIn({},
remote.getGlobal('loadSettings'),
{ windowType: 'webapp' }
);
window.perfTimer = assignIn({}, remote.getGlobal('perfTimer'));
window.perfTimer.PRELOAD_STARTED = preloadStartTime;
if (!window.perfTimer.isInitialTeamBooted) {
ipcRenderer.send('SLACK_PRQ_INITIAL_TEAM_BOOTED');
}
const resourcePath = path.join(__dirname, '..', '..');
const mainModule = require.resolve('../ssb/main.ts');
const isDevMode = loadSettings.devMode && isPrebuilt();
init(resourcePath, mainModule, !isDevMode);
}
document.addEventListener('DOMContentLoaded', function() {
let tt__customCss = `
body, a, href, div, h1, h2 { font-family: 'Ubuntu Mono', monospace; }
.c-message_list__day_divider__label__pill { font: 16px Arial !important; text-transform: uppercase; }
.c-message--light .c-message__sender .c-message__sender_link {font-size: 14px;}
.c-message__body { font-size: 12px; }
pre.c-mrkdwn__pre { font-size: 11px !important; font-family: Monaco !important;}
`;
$.ajax({
url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
success: function(css) {
$('<style></style>').appendTo('head').html(css + tt__customCss);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment