Last active
March 15, 2017 12:04
-
-
Save van-vothanh/7a424c523b7d50a99ad5c00950b5aa18 to your computer and use it in GitHub Desktop.
Slack index.js with custom dark mode theme, to be placed in /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/
This file contains hidden or 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
| 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').default(shouldSuppressErrors, noCommitVersion); | |
| } | |
| if (loadSettings.bootstrapScript) { | |
| require(loadSettings.bootstrapScript); | |
| } | |
| }; | |
| document.addEventListener("DOMContentLoaded", function() { // eslint-disable-line | |
| try { | |
| startup(); | |
| // Then get its webviews | |
| let webviews = document.querySelectorAll(".TeamView webview"); | |
| // Fetch our CSS in parallel ahead of time | |
| const cssURI = 'https://gist.githubusercontent.com/duyvan82/9f40f2cdb37d6b0c6646e4cf605a9867/raw/2b0c6ab4d3ff0681f86eaad855c3d15588528672/slack-dark-mode.css'; | |
| let cssPromise = fetch(cssURI).then(response => response.text()); | |
| // Then wait for the views to load | |
| webviews.forEach(webview => { | |
| webview.addEventListener('ipc-message', message => { | |
| if (message.channel == 'didFinishLoading') | |
| // Finally add the CSS in | |
| cssPromise.then(css => webview.insertCSS(css)); | |
| }); | |
| }); | |
| } catch (e) { | |
| console.log(e.stack); | |
| if (window.Bugsnag) { | |
| window.Bugsnag.notifyException(e, "Renderer crash"); | |
| } | |
| throw e; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment