7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Slack デスクトップアプリ Darkmode Hack

Last updated at Posted at 2019-06-17

モバイルアプリ版ではリリース済みのダークモードを、Windowsデスクトップアプリなどで強引に適用させるためのハックです。
「Slack公式対応まで待てない!」という方は、自己責任でどうぞ。
※本記事はGitに掲載されている**Slack Black Teheme**の日本語訳(一部抜粋)となります。
alt

対応OS

Windows/Mac/Linux

動作環境

Windows 3.4.3 64-bit

適用方法

①Slackがインストールされているディレクトリを探します。
  • Windows: %homepath%\AppData\Local\slack\
  • Mac: /Applications/Slack.app/Contents/
  • Linux: /usr/lib/slack/ (Debian-based)
②下記ディレクトリを参照して ssb-interop.js を開きます。
※以下、Windowsの場合
C:\Users\{ユーザーID}\AppData\Local\slack\{アプリバージョン}\resources\app.asar.unpacked\src\static

WS000005.JPG

③開いたファイルの末尾に下記のコードを貼り付けて、上書き保存します。

※作業が不安な方は、あらかじめ ssb-interop.js のバックアップを取りましょう。

darkify-slack-script.js
// 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: #09F;
      --text: #CCC;
      --background: #080808;
      --background-elevated: #222;
   }
   `

   // 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);
            })
      });
   });
});
④作業は以上です。Slackを再起動して、ダークモードが反映されていることをご確認ください。
※この作業はデスクトップアプリのバージョンが変更された際、再度作業が必要です。

Color Schemes

下記の箇所を変更することで、カラーテーマを変更可能です。

   :root {
      /* Modify these to change your theme colors: */
      --primary: #09F;
      --text: #CCC;
      --background: #080808;
      --background-elevated: #222;
   }

Default

alt

--primary: #09F;
--text: #CCC;
--background: #080808;
--background-elevated: #222;

One Dark

alt

--primary: #61AFEF;
--text: #ABB2BF;
--background: #282C34;
--background-elevated: #3B4048;

Low Contrast

alt

--primary: #CCC;
--text: #999;
--background: #222;
--background-elevated: #444;

Navy

alt

--primary: #FFF;
--text: #CCC;
--background: #225;
--background-elevated: #114;

Hot Dog Stand

alt

--primary: #000;
--text: #FFF;
--background: #F00;
--background-elevated: #FF0;

以上

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?