Slack dark mode

From Ever changing code
Revision as of 14:28, 16 May 2019 by Pio2pio (talk | contribs) (Created page with "This was always a problem. So there 2 methods: * open Web Slack and apply any dark-mode plugins, this works very well apart you cannot make direct calls * use Powershell snipp...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This was always a problem. So there 2 methods:

  • open Web Slack and apply any dark-mode plugins, this works very well apart you cannot make direct calls
  • use Powershell snippet below to enable DarkMode, worked for Windows 10, 3.4.0 64-bit version
    • Execute dARK.ps1 below script. Does not require elevated privilages
    • Restart Slack Ctrl+Q, then start Slack
    • Each update to the app will require to re-run the script


<syntaxhighlightjs lang="powershell"> // Ark Labs presents - Slack dARK mode

$slackBaseDir = "$env:LocalAppData\Slack" $installations = Get-ChildItem $slackBaseDir -Directory | Where-Object { $_.Name.StartsWith("app-") } $version = $installations | Sort-Object { [version]$_.Name.Substring(4) } | Select-Object -Last 1 Write-Output "Select highest intalled Slack version: $version";

$modAdded = $false; $customContent = @'

// slack-dARK-mode |-)

document.addEventListener('DOMContentLoaded', function() {

$.ajax({
  url: 'https://raw.githubusercontent.com/laCour/slack-night-mode/master/css/raw/black.css',
  success: function(css) {
    $("<style></style>").appendTo('head').html(css);
  }
});

}); '@

if ((Get-Content "$($version.FullName)\resources\app.asar.unpacked\src\static\index.js" | %{$_ -match "// laCour - slack-night-mode"}) -notcontains $true) {

   Add-Content "$($version.FullName)\resources\app.asar.unpacked\src\static\index.js" $customContent
   Write-Host "Mod Added To index.js";
   $modAdded = $true;

} else {

   Write-Host "Mod Detected In index.js - Skipping";

}

if ((Get-Content "$($version.FullName)\resources\app.asar.unpacked\src\static\ssb-interop.js" | %{$_ -match "// laCour - slack-night-mode"}) -notcontains $true) {

   Add-Content "$($version.FullName)\resources\app.asar.unpacked\src\static\ssb-interop.js" $customContent
   Write-Host "Mod Added To ssb-interop.js";
   $modAdded = $true;

} else {

   Write-Host "Mod Detected In ssb-interop.js - Skipping";

}

if ($modAdded -eq $true) {

   if((Get-Process "slack" -ErrorAction SilentlyContinue) -ne $null) {
       Write-Host "Mod Complete - Mod Will Take Effect After Slack Is Restarted";
   } else {
       Write-Host "Mod Complete";
   }

} else {

   Write-Host "Mod Already Active - No Further Action Is Needed.";

} </syntaxhighlightjs>