Skip to content

Instantly share code, notes, and snippets.

@jeebak
Last active December 15, 2019 08:01
Show Gist options
  • Select an option

  • Save jeebak/b6fee546f2d8c4f4cecc4efab63373d6 to your computer and use it in GitHub Desktop.

Select an option

Save jeebak/b6fee546f2d8c4f4cecc4efab63373d6 to your computer and use it in GitHub Desktop.

Revisions

  1. jeebak revised this gist Dec 15, 2019. 1 changed file with 1 addition and 40 deletions.
    41 changes: 1 addition & 40 deletions hack-mac-slack.bash
    Original file line number Diff line number Diff line change
    @@ -4,43 +4,4 @@
    # https://github.com/widget-/slack-black-theme
    # https://github.com/laCour/slack-night-mode/

    # Linux: TARGET="/usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js"
    # Snap: TARGET="/snap/slack/6/usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js"
    # ... it's on a read-only squashFS filesystem
    # Windows: TARGET="%systemdrive%%homepath%\AppData\Local\slack\app-3.1.1\resources\app.asar.unpacked\src\static\ssb-interop.js"
    # ... where app-3.1.1 is the current version
    BASE="/Applications/Slack.app/Contents/Resources"
    CUSTOM_CSS="https://raw.githubusercontent.com/laCour/slack-night-mode/master/css/raw/black.css"

    # Slack 3.x
    TARGET="$BASE/app.asar.unpacked/src/static/ssb-interop.js"

    # Slack 4.x
    if [[ ! -e "$TARGET" ]]; then
    npx asar extract "$BASE"/app.asar{,.unpacked}
    TARGET="$BASE/app.asar.unpacked/dist/ssb-interop.bundle.js"
    REPACK="true"
    fi

    if [[ -f "$TARGET" ]]; then
    if ! grep "$CUSTOM_CSS" "$TARGET" > /dev/null 2>&1; then
    # https://github.com/laCour/slack-night-mode/issues/73#issuecomment-287467332
    cat << EOT >> "$TARGET"
    document.addEventListener('DOMContentLoaded', function() {
    $.ajax({
    url: '$CUSTOM_CSS',
    success: function(css) {
    \$('<style></style>').appendTo('head').html(css);
    }
    });
    });
    EOT
    [[ "$REPACK" = "true" ]] && npx asar pack "$BASE"/app.asar{.unpacked,}
    echo "Restarting Slack"
    osascript -e 'quit app "Slack"'
    sleep 3
    open -a Slack
    fi
    fi
    # No longer relevant
  2. jeebak revised this gist Jul 17, 2019. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion hack-mac-slack.bash
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,19 @@
    # ... it's on a read-only squashFS filesystem
    # Windows: TARGET="%systemdrive%%homepath%\AppData\Local\slack\app-3.1.1\resources\app.asar.unpacked\src\static\ssb-interop.js"
    # ... where app-3.1.1 is the current version
    TARGET="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js"
    BASE="/Applications/Slack.app/Contents/Resources"
    CUSTOM_CSS="https://raw.githubusercontent.com/laCour/slack-night-mode/master/css/raw/black.css"

    # Slack 3.x
    TARGET="$BASE/app.asar.unpacked/src/static/ssb-interop.js"

    # Slack 4.x
    if [[ ! -e "$TARGET" ]]; then
    npx asar extract "$BASE"/app.asar{,.unpacked}
    TARGET="$BASE/app.asar.unpacked/dist/ssb-interop.bundle.js"
    REPACK="true"
    fi

    if [[ -f "$TARGET" ]]; then
    if ! grep "$CUSTOM_CSS" "$TARGET" > /dev/null 2>&1; then
    # https://github.com/laCour/slack-night-mode/issues/73#issuecomment-287467332
    @@ -27,6 +37,7 @@ document.addEventListener('DOMContentLoaded', function() {
    });
    EOT
    [[ "$REPACK" = "true" ]] && npx asar pack "$BASE"/app.asar{.unpacked,}
    echo "Restarting Slack"
    osascript -e 'quit app "Slack"'
    sleep 3
  3. jeebak revised this gist May 6, 2018. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions hack-mac-slack.bash
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,11 @@
    # https://github.com/widget-/slack-black-theme
    # https://github.com/laCour/slack-night-mode/

    # Linux: TARGET="/usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js"
    # Snap: TARGET="/snap/slack/6/usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js"
    # ... it's on a read-only squashFS filesystem
    # Windows: TARGET="%systemdrive%%homepath%\AppData\Local\slack\app-3.1.1\resources\app.asar.unpacked\src\static\ssb-interop.js"
    # ... where app-3.1.1 is the current version
    TARGET="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js"
    CUSTOM_CSS="https://raw.githubusercontent.com/laCour/slack-night-mode/master/css/raw/black.css"

  4. jeebak revised this gist Apr 28, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion hack-mac-slack.bash
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    # https://github.com/laCour/slack-night-mode/

    TARGET="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js"
    CUSTOM_CSS="https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css"
    CUSTOM_CSS="https://raw.githubusercontent.com/laCour/slack-night-mode/master/css/raw/black.css"

    if [[ -f "$TARGET" ]]; then
    if ! grep "$CUSTOM_CSS" "$TARGET" > /dev/null 2>&1; then
  5. jeebak revised this gist Mar 12, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion hack-mac-slack.bash
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,9 @@ document.addEventListener('DOMContentLoaded', function() {
    });
    EOT
    echo "Restart Slack"
    echo "Restarting Slack"
    osascript -e 'quit app "Slack"'
    sleep 3
    open -a Slack
    fi
    fi
  6. jeebak created this gist Jun 9, 2017.
    27 changes: 27 additions & 0 deletions hack-mac-slack.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/usr/bin/env bash

    # https://gist.github.com/DrewML/0acd2e389492e7d9d6be63386d75dd99
    # https://github.com/widget-/slack-black-theme
    # https://github.com/laCour/slack-night-mode/

    TARGET="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js"
    CUSTOM_CSS="https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css"

    if [[ -f "$TARGET" ]]; then
    if ! grep "$CUSTOM_CSS" "$TARGET" > /dev/null 2>&1; then
    # https://github.com/laCour/slack-night-mode/issues/73#issuecomment-287467332
    cat << EOT >> "$TARGET"
    document.addEventListener('DOMContentLoaded', function() {
    $.ajax({
    url: '$CUSTOM_CSS',
    success: function(css) {
    \$('<style></style>').appendTo('head').html(css);
    }
    });
    });
    EOT
    echo "Restart Slack"
    fi
    fi