glajchs / slack-customizations

Some customizations to slack, such as some keybindings, dark theme, etc
MIT License
21 stars 1 forks source link

Not working with Slack 4.0.0 on Windows #14

Open matt1981m opened 5 years ago

matt1981m commented 5 years ago

With 4.0, slack has changed the file structure used and as such ssb-interop.js & index.js are no longer located in the "\resources\app.asar.unpacked\src\static" subfolder under the Slack version directory.

kiwimind commented 5 years ago

Same on MacOS - there is no longer a /src directory in /app.asar.unpacked. All looks to be compiled now.

The only directories under /app.asar.unpacked are /dist and /node_modules

willpower232 commented 5 years ago

This readme has some idea of how to work in Slack 4 https://github.com/leoandreotti/slack-dark-theme

sglajchEG commented 5 years ago

Ty @willpower232 !! I just upgraded to Slack 4.0 today (I was on vacation last week) and the lack of the plugins are killing me. I'll have a look tonight and hopefully patch it up.

glajchs commented 5 years ago

There are a number of things that seem to be drastically different under the covers with Slack 4.0, and here's what I've found so far:

Some of the plugins work off of and require some global (window.X) variables that don't seem to be present anymore, namely "window.TS" seems to be missing. Those plugins won't work (keybinds, random emoji, simple-find). I'm not sure which other plugins might break in this way.

The plugin system as a whole, and some of the individual plugins, were leveraging slack's access to a few node modules (require("fs") being the most important), and that is not accessible anymore. This is a big problem. Due to this, the plugin system doesn't even load. I use the "fs" module in order to find and load files within the $HOME/.slack directory, and that is broken. I did this style to avoid hardcoding which files to load into the file your patching (so you don't have to patch as often), but for now maybe I can just load specific files?

Due to the 2 above things, I haven't even gotten as far as attempting to load the dark theme plugin (which is the reason most people come here), but I'd assume/hope that including it statically as a style tag off of a static link could work.

Finally, the files I was patching don't exist anymore. It was previously in the /app.asar.unpacked directory, but the inspection tools (which thankfully still work) show that it's now loading /usr/lib/slack/resources/app.asar/dist/ssb-interop.bundle.js instead, which is minified and it looks like webpack-ified. There is a way to "unpack" and then "repack" the app.asar file that slack installs, but that hasn't helped me work around the loading issues above.

I'll race towards a "here's how to manually get dark theme working" manual set of instructions, and work on automatic patching and loading of all plugins after that.

glajchs commented 5 years ago

It's even worse than that. Slack 4.0 now has a CSP (content security policy) that restricts where you can load files from, so you can't even point at a file on disk or from the web to load it. You have to insert the styles via a style tag with text content. I manually modified the css file's contents to remove all comments, newlines, and replace quotes with escaped quotes and was able to insert it in a style tag using innerText, but the styles do need updating. This doesn't seem like it will be quick :-(