Skip to content

Instantly share code, notes, and snippets.

@Ddorda
Last active April 22, 2018 07:06
Show Gist options
  • Save Ddorda/c5662f0f99f6c3c0eacd67eb27430ea4 to your computer and use it in GitHub Desktop.
Save Ddorda/c5662f0f99f6c3c0eacd67eb27430ea4 to your computer and use it in GitHub Desktop.
Add RTL support for Slack on Windows
# Based on: slack_rtl_support_mac.sh By Oren Yomtov: https://gist.github.com/orenyomtov/3d0f2412afa1c4a9eb207d3d4310e988
# Tested on Win10
# Prerequisites: Node.js
# Node.js can be downloaded from: https://nodejs.org/en/download/
# if can't run scripts, open powershell an run:
# cat path/to/script.ps1 | powershell
Write-Output "Getting Slack Directory"
$slackdir = Get-Process -name 'slack' | Select-Object -First 1 | Select -ExpandProperty "path" | Split-Path
Write-Output "Killing Slack"
Stop-Process -name "slack"
Write-Output "Installing asar"
npm install -g asar
Set-Location "$slackdir\resources"
Write-Output "Creating temporary directory to extract the source code into"
New-Item -ItemType directory -Path temp-sourcecode
Write-Output "Extracting Slack’s source code"
asar extract app.asar temp-sourcecode
Write-Output "Editing Slack’s source code to add RTL support"
$jsCode = @"
if (typeof window !== 'undefined') {
window.addEventListener('DOMContentLoaded', function() {
jQuery('body').bind('DOMSubtreeModified', function() {
jQuery('.ql-editor, .c-message__body').attr('dir', 'auto').css('text-align', 'left');
});
}, false);
}
"@
Add-Content .\temp-sourcecode\src\stat-cache.js $jsCode
Write-Output "Repacking Slack’s source code"
asar pack temp-sourcecode app.asar
Write-Output "Deleting temporary directory"
Remove-Item -Recurse -Force .\temp-sourcecode
Start-Process "$slackdir\slack.exe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment