Skip to content

Instantly share code, notes, and snippets.

@hdsenevi
Last active January 16, 2018 00:52
Show Gist options
  • Save hdsenevi/65882a389eb3ecac6f95a4638165acc3 to your computer and use it in GitHub Desktop.
Save hdsenevi/65882a389eb3ecac6f95a4638165acc3 to your computer and use it in GitHub Desktop.
Dark theme on Slack 3.0.0 above
Dark theme on Slack 3.0.0 above
Paste bellow two files into
Mac: /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/
Restart slack
//do not migrate preload script into TypeScript
require('../stat-cache');
const profiler = require('../utils/profiler');
if (profiler.shouldProfile()) profiler.startProfiling();
var startup = function() {
var url = require('url');
// Skip "?loadSettings=".
var fileUri = url.parse(window.location.href);
var queryParts = fileUri.query.split('&');
var loadSettingsStr = null;
for (var j=0; j < queryParts.length; j++) {
if (queryParts[j].match(/loadSettings/)) {
loadSettingsStr = queryParts[j].replace("loadSettings=", "");
break;
}
}
var loadSettings = JSON.parse(decodeURIComponent(loadSettingsStr));
// Require before the module cache in dev mode
window.loadSettings = loadSettings;
var noCommitVersion = loadSettings.version.split('-')[0];
var shouldSuppressErrors = loadSettings.devMode;
if (!loadSettings.isSpec) {
require('../renderer/bugsnag-setup').setupBugsnag(shouldSuppressErrors, noCommitVersion);
}
if (loadSettings.bootstrapScript) {
require(loadSettings.bootstrapScript);
}
};
document.addEventListener("DOMContentLoaded", function() { // eslint-disable-line
try {
startup();
} catch (e) {
console.log(e.stack);
if (window.Bugsnag) {
window.Bugsnag.notifyException(e, "Renderer crash");
}
throw e;
}
});
// First make sure the wrapper app is loaded
document.addEventListener("DOMContentLoaded", function() {
// Then get its webviews
let webviews = document.querySelectorAll(".TeamView webview");
// Fetch our CSS in parallel ahead of time
const cssPath = 'https://cdn.rawgit.com/widget-/slack-black-theme/master/custom.css';
let cssPromise = fetch(cssPath).then(response => response.text());
let customCustomCSS = `
:root {
/* Modify these to change your theme colors: */
--primary: #61AFEF;
--text: #ABB2BF;
--background: #282C34;
--background-elevated: #3B4048;
}
`
// Insert a style tag into the wrapper view
cssPromise.then(css => {
let s = document.createElement('style');
s.type = 'text/css';
s.innerHTML = css + customCustomCSS;
document.head.appendChild(s);
});
// Wait for each webview to load
webviews.forEach(webview => {
webview.addEventListener('ipc-message', message => {
if (message.channel == 'didFinishLoading')
// Finally add the CSS into the webview
cssPromise.then(css => {
let script = `
let s = document.createElement('style');
s.type = 'text/css';
s.id = 'slack-custom-css';
s.innerHTML = \`${css + customCustomCSS}\`;
document.head.appendChild(s);
`
webview.executeJavaScript(script);
})
});
});
});
// First make sure the wrapper app is loaded
document.addEventListener("DOMContentLoaded", function() {
// Then get its webviews
let webviews = document.querySelectorAll(".TeamView webview");
// Fetch our CSS in parallel ahead of time
const cssPath = 'https://cdn.rawgit.com/widget-/slack-black-theme/master/custom.css';
let cssPromise = fetch(cssPath).then(response => response.text());
let customCustomCSS = `
:root {
/* Modify these to change your theme colors: */
--primary: #61AFEF;
--text: #ABB2BF;
--background: #282C34;
--background-elevated: #3B4048;
}
`
// Insert a style tag into the wrapper view
cssPromise.then(css => {
let s = document.createElement('style');
s.type = 'text/css';
s.innerHTML = css + customCustomCSS;
document.head.appendChild(s);
});
// Wait for each webview to load
webviews.forEach(webview => {
webview.addEventListener('ipc-message', message => {
if (message.channel == 'didFinishLoading')
// Finally add the CSS into the webview
cssPromise.then(css => {
let script = `
let s = document.createElement('style');
s.type = 'text/css';
s.id = 'slack-custom-css';
s.innerHTML = \`${css + customCustomCSS}\`;
document.head.appendChild(s);
`
webview.executeJavaScript(script);
})
});
});
});
/**
* The preload script needs to stay in regular ole JavaScript, because it is
* the point of entry for electron-compile.
*/
require('../stat-cache');
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();
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.
*/
const loadSettings = window.loadSettings = assignIn({},
require('electron').remote.getGlobal('loadSettings'),
{ windowType: 'webapp' }
);
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() {
$.ajax({
url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
success: function(css) {
$("<style></style>").appendTo('head').html(css);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment