fsavje / math-with-slack

Rendered math (MathJax) with Slack's desktop client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slack 4.0.0 doesn't contain src/static/ssb-interop.js

sammorley-short opened this issue · comments

I just tried to install this for Slack 4.0.0 (downloaded via the Mac OSX App Store) and it failed to find the correct file.

When I searched the file directory, no ssb-interop.js file was found:

Slack.app $ sudo find . -name '*.js'                                                                                                                                                                                                                                                                       
Password:
./Contents/Resources/app.asar.unpacked/dist/static/extensions/react-devtools/popups/shared.js
./Contents/Resources/app.asar.unpacked/dist/static/extensions/react-devtools/build/background.js
./Contents/Resources/app.asar.unpacked/dist/static/extensions/react-devtools/build/backend.js
./Contents/Resources/app.asar.unpacked/dist/static/extensions/react-devtools/build/panel.js
./Contents/Resources/app.asar.unpacked/dist/static/extensions/react-devtools/build/main.js
./Contents/Resources/app.asar.unpacked/dist/static/extensions/react-devtools/build/inject.js
./Contents/Resources/app.asar.unpacked/dist/static/extensions/react-devtools/build/contentScript.js

Any ideas which file to point it to instead?

A colleague provided a link to this issue in another repo, where the same problem has been solved. It seems (at least on OSX) one needs to have npm installed, and then one can unpack the .asar file in Slack 4.0 using npx, inject math-with-slack, then repack it.

I will take a look at this as soon as possible, but that will unfortunately be a few weeks.

Took a look at this today. Turns out that Slack has added a Content Security Policy to avoid script injections. One can inject meta tags in the webapp by unpacking and repacking the asar file as suggested by @hwagyesa . However, it does not load the MathJax script from the CDN:

/Applications/Slack.app/Contents/Resources/app.asar/dist/ssb-interop.bundle.js:40
Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js' because it violates the following Content Security Policy directive:
"script-src 'self' https://a.slack-edge.com/ https://cfr.slack-edge.com/ https://fst.slack-edge.com/ 'sha256-HtosUFirHdHvZwGXLdjtfHXYVEjfNmDyX7ffscLm7qw=' 'sha256-V3pNBo9vFI47lnzeFlyJVDxtN3Yf0X6UgalmXzoA69U=' 'sha256-XVjf1UrB+S9bTulVsVW6RjmlY9eDXYYpMiNpLNbVBC0=' 'sha256-F1YT8S1ELkeOyM7rwIMIkVMS8a8FVeXoxmlDjUWZ7Rw=' 'sha256-bnzwnkVhpJR3UZDeyqmzR5+Vty3+pxQYDebbeatN4pU=' 'sha256-NKJOlWPHN59LLYioFQrsjETUtZ+C2AH7plCQfLp7ItY=' 'sha256-D+/bcNwAmFYJ9CfMh57ykwI2161k02TzQhHgIuPRv0I=' 'sha256-jvnF/vs0XdFoP8ZslmhYkCiX84ifYfYKhsPLItnQ+po=' 'sha256-r04w7sZJG0w7qP3YQWJQqrWEAltzCG24RNqrNlDmL6o=' 'sha256-G47a8SPvyDeMvcflK35cUDWqZ6qVRoCf5Z3K0evCOzU=' 'sha256-gZRnrJgs9oG1IkDd5eWANg4/vxp66C0/LYib66mK6Ng=' 'sha256-UvgDsssAGwGDwJDr31x/G3Q7Fuy1B7S5Fw1uHsgBKlE=' 'sha256-sPqPkLDIPKNAk2Vqyp4vscB38LWqm07HVzPEUq6lct4=' 'sha256-5DB6q76v13BY+HEvVt9XeNU1zDEeA4U0De5HHiib54U=' 'sha256-Tu41NFywTKucDrnDukVaLIvsMTz7LqDJswN066TfHNQ=' 'sha256-M+GeuEwdHgLK+IB+9Hmhf8mIrHIv6oKp7xEfGJGmmPY='".

As I've understood it, it isn't possible to modify the CSP on the run, so it seems that using a CDN for script delivery is out of the picture. I also tried injecting a local copy of MathJax, but it was ignored because it wasn't in the electron manifest (and I'm unsure whether it would circumvent the CSP in any case). I guess it technically would be possible to inject the full MathJax library in the same way as the meta tags are injected now, but that is not feasible given that MathJax is over 100 mb.

Does anyone have any ideas on a way forward on this?

The unpack-inject-repack scheme is working for me in the latest version of App Store Slack provided I follow the suggestion in this comment before injecting. There is some discussion of this issue here, but it seems it is unclear why changing this setting helps. When using the version of the app downloaded from Slack's website, the unpack-inject-repack scheme was working for me even without changing the bootSonic setting. Based on the information you've posted, though, it looks like this kind of workaround likely won't be viable for long.

@hwagyesa Could you clarify: do you manage to get math-with-slack running with this method or slack-dark-mode?

@fsavje Both math-with-slack and slack-dark-mode work for me (and at least one of my colleagues) with this method. The script I am using with math-with-slack can be found in my fork of the repository.

Thanks!

Seems this route will work on Mac OS at least. If anyone tests it out on Linux or Windows, please report the results here.

Working on a python script to avoid installing Node.js. In the meanwhile, manually unpacking and packing app.asar using node.js will work.

@hwagyesa's route works on Linux too.

I have Windows, but @hwagyesa didn't update the Windows version of the install script, so I can't test it. Looking forward to your python script install

Dear fsavje,
would it be possible to write a description for non-experts on how to get math-with-slack working on Mac OSX? We use an enormous amount of latex in our slack discussions and since the last update of Slack our life has been a misery. I understand from your exchange with hwagyesa that there is a solution for Mac OS but the description is too technical for me to understand what I need to do to get it working. Thanks so much!

Hi @erikvannimwegen. I don't know if I can give anymore detailed instructions than those by @hwagyesa. However, I hope to have a draft version of the updated script up during the weekend.

Ok great.. if there will be an updated version soon then I guess I don't need to learn.
But just so know, for a lay user it is completely unclear what it means to 'unpack' an .asar file (or what .asar file @hwagyesa refers to), how to do this unpacking 'in Slack 4.0', how to then 'inject' the script, or how to then 'repack it' afterwards (or even what precisely 'it' is in this context). I understand that I could research online until I do know what these things are, but I guess I was hoping there was a way to give 4 or 5 concrete command line commands that together would accomplish those steps. Thanks in any case for the extremely valuable plugin.

Dear @erikvannimwegen, you can perform the following steps to use my script, working for me and others on OSX:

  1. Run in a terminal brew install npm (download Homebrew if you don't have it);
  2. Clone my fork of @fsavje's math-with-slack repository;
  3. Run the math-with-slack.sh script like usual.

The quality of my code is much worse than @fsavje's. If this seems problematic you may wait for his upcoming script.

A draft version of the python script is up now: https://github.com/fsavje/math-with-slack/tree/v3 It should work with both Python 2.7 and 3. It has, however, not been tested on Windows or Linux. Please let me know if it doesn't work.

It seems that Slack 4.0.1 overwrites the local settings JSON file. Any ideas on circumvent this would be welcomed.

@fsavje I've had a quick try with "math-with-slack.py" on Ubuntu 16.04 and haven't been able to get it to work.

I'm using the slack/slack-desktop packages (version 4.0.1) from the https://packagecloud.io/slacktechnologies/slack/debian/ repository (originally from https://slack.com/downloads/linux). I've ran the script and it changes app.asar. "grep fsavje app.asar" matches, though if I unpack then file with "npx asar extract app.asar /tmp/extract" the "ssb-interop.bundle.js" file is missing.

Some things I noticed with the script:

  • "sys.platform == 'linux'" won't work with python 2.7 on my platform, sys.platform returns "linux2". Perhaps use "sys.platform.startswith('linux')"?
  • If the user has not yet launched slack, the local-settings.json file may not yet exist for them. At the moment it seems that he script won't run on Linux if that file doesn't exist.
  • Can you add an option to not create the .mwsbak file?

I submitted a pull request #53 to make the python script work with Windows.

A draft version of the python script is up now: https://github.com/fsavje/math-with-slack/tree/v3 It should work with both Python 2.7 and 3. It has, however, not been tested on Windows or Linux. Please let me know if it doesn't work.

Hi, I'm using Mac OSX. Running your .py script gives me this permission denied error. How can I make sure the script has write permissions?

[Errno 13] Permission denied: '/Applications/Slack.app/Contents/Resources/app.asar.mwsbak'
Cannot make backup. Make sure the script has write permissions.

I've got the following error even the latest releases.
An error message ✘ Cannot find Slack installation. shows on my Mac terminal

Ah ... Sorry.

I should have tried the script below:
https://github.com/fsavje/math-with-slack/blob/v3/math-with-slack.py

just run

$ sudo python math-with-slack.py
sudo python mathwiths.py 
Using Slack installation at: /Applications/Slack.app/Contents/Resources/app.asar
Using local settings file at: /Users/myuser/Library/Containers/com.tinyspeck.slackmacgap/Data/Library/Application Support/Slack/local-settings.json
Install successful. Please restart Slack.

works for me. Thank you @fsavje

It seems that Slack 4.0.1 overwrites the local settings JSON file. Any ideas on circumvent this would be welcomed.

My temporary fix was to hijack /Applications/Slack.app/Contents/MacOS/Slack.

Basically, create rename this Slack executable to Slack_bk, then create a shell script in place of that:

#!/bin/sh
# Contents for /Applications/Slack.app/Contents/MacOS/Slack

tmp_dir=$(mktemp -d)
prev_dir=$(pwd)
cd $tmp_dir
curl -O https://github.com/fsavje/math-with-slack/blob/v3/math-with-slack.py
python math-with-slack.py
cd $prev_dir
rm $tmp_dir

script_path="$( cd "$(dirname "$0")" ; pwd -P )"

exec "${script_path}/Slack_bk" "$@"

Make it executable:

chmod +x /Applications/Slack.app/Contents/MacOS/Slack

Trying this on Ubuntu 18.04.3 now, running just the python file I get:

sudo python ./math-with-slack.py 
Could not find Slack's app.asar file. Please provide path.

if I supply the app file I get a missing local settings file:

sudo python ./math-with-slack.py -a /usr/lib/slack/slack
Could not find local-settings.json. Please provide path.

I can't find any info on where this file might be on Ubuntu.

EDIT: this call seems to have worked for me, in case it helps anyone:

sudo python ./math-with-slack.py -a /usr/lib/slack/resources/app.asar -s /home/alan/.config/Slack/local-settings.json

Actually it ran successfully but didn't change anything.

Actually it ran successfully but didn't change anything.

Same on Ubuntu 16.04

Hello! I also have a problem with unpacking app.asar.

user@host:~$ npx  asar --verbose extract /usr/lib/slack/resources/app.asar asar_extracted/
npx: installed 21 in 2.442s
Unexpected token function

A draft version of the python script is up now: https://github.com/fsavje/math-with-slack/tree/v3 It should work with both Python 2.7 and 3. It has, however, not been tested on Windows or Linux.

Has anyone successfully used this script for Windows? When I run it in Python Shell, I receive a message saying `Not implemented,' and that's it.

I would appreciate input from anyone who has successfully installed math-with-slack on Windows following the recent protections against code injections.

The not implemented message means just that; nobody's implemented the functionality in the script on Windows.

@pturne7 I submitted a pull request at #53 that makes it work on Windows.

I believe that if you download the file math-with-slack.py from here: https://github.com/fsavje/math-with-slack/blob/d15ce28d8394f8a021b88d793a222b80e8566b28/math-with-slack.py

then you'll be able to run it on Windows.

Slack 4.2.0 seems to have finally killed the python script as well (I'm on Mac). The error is KeyError: 'ssb-interop.bundle.js'. And Slack stops launching after this.

I poked around this issue today... it seems that Slack 4.2 has removed old code (including ssb-interop.bundle.js and other files...) that was used to run whatever CSP-free legacy interface was used when setting bootSonic = "never" in the local_settings.json file, so indeed as @level1807 stated this workaround is no longer viable.

It seems that the right place to inject code is now main-preload-entry-point.bundle.js; but as @fsavje stated above, CSP is turned on by default in new versions of Slack, and it blocks the injected code from accessing the Cloudflare CDN. I combed over the source for a while looking for places where the CSP settings might be editable (looking for things like script-src...), but had no success. Does anyone else have any leads on whether it is possible to disable CSP in Slack?

commented

I encontered the same error in Slack 4.2.0. I ran math-math-with-slack.py, then I got these error.

Using Slack installation at: /Applications/Slack.app/Contents/Resources/app.asar
Using local settings file at: /Users/atsuto/Library/Application Support/Slack/local-settings.json
Traceback (most recent call last):
  File "math-with-slack.py", line 248, in <module>
    ori_ssbinterop_size = json_header['files']['dist']['files']['ssb-interop.bundle.js']['size']
KeyError: 'ssb-interop.bundle.js'

FYI, I have fixed this for 4.2.0: https://github.com/thisiscam/math-with-slack/blob/v3/math-with-slack.py

I basically included a local version of MathJax 3 by putting the release of https://github.com/mathjax/MathJax (found on CDNs such as 'https://registry.npmjs.org/mathjax/-/mathjax-3.0.0.tgz') under Resources/dist/node_modules/.

The MathJax config is done here: https://github.com/thisiscam/math-with-slack/blob/v3/math-with-slack.py#L151.

Unfortunately, I had to switch to SVG outputs, which does not seem to require loading static font assets. The current implementation might not be perfect, but it's mostly usable for my case.

commented

It works well. Thanks you for your information 😃

Thanks @thisiscam! I merged your changes with the macro tweaks I have in my fork if anyone needs an example of how to do macros + package imports in MathJax 3.0.0.

@thisiscam's script works in Linux (Ubuntu 19.10) by replacing sys.platform == 'linux' with sys.platform.startswith('linux') as suggested above by @rcurr.

@asefahmed56 fixed as you suggested.
Thanks!

Is there a windows version working?

A draft version of the python script is up now: https://github.com/fsavje/math-with-slack/tree/v3 It should work with both Python 2.7 and 3. It has, however, not been tested on Windows or Linux.

Has anyone successfully used this script for Windows? When I run it in Python Shell, I receive a message saying `Not implemented,' and that's it.

I would appreciate input from anyone who has successfully installed math-with-slack on Windows following the recent protections against code injections.

@pturne7
@jasondlee88

I was able to get it to run on windows and persist through startup by adding the python script to the root of the app.asar file location. Modifying the script to include the "app_path" for where my slack app is stored.

Lastly, close slack, and any background threads. Run the python file from Administrator Shell. This should return "Installed, Restart Slack "

    app_path = args.app_file
elif sys.platform == 'darwin':
    app_path = '/Applications/Slack.app/Contents/Resources/app.asar'
elif sys.platform.startswith('linux'):
    for test_app_file in [
        '/usr/lib/slack/resources/app.asar',
        '/usr/local/lib/slack/resources/app.asar',
        '/opt/slack/resources/app.asar'
    ]:
        if os.path.isfile(test_app_file):
            app_path = test_app_file
            break
elif sys.platform == 'win32':
    app_path = 'C:\\Users\\<username>\\AppData\\Local\\slack\\app-4.2.0\\resources\\app.asar'
    #exprint('Not implemented')```

Good Luck! 

Tried @thisiscam 's python script. Threw an error on line 229 because it didn't like the inspected_file_name 'main-preload-entry-point.bundle.js'. Looking at the json_header dictionary, the file doesn't show up. I changed the inspected_file_name to 'ssb-interop.bundle.js', since that was the file we were previously messing with (pre Slack 4) and it exists in the json_header dictionary. The python script now runs happily, but no change in Slack. Any suggestions from the gurus?

I'm on Ubuntu 18 fwiw.

Hi, I can't get any script to work for Slack 4.3.3.

So far I tried the @fsavje's v3: https://github.com/fsavje/math-with-slack/blob/v3/math-with-slack.py
@thisiscam's fork https://github.com/thisiscam/math-with-slack/blob/v3/math-with-slack.py
and @hwagyesa's fork https://github.com/hwagyesa/math-with-slack/blob/master/mws-4p2.py

The last two don't send any error (message: Install successful. Please restart Slack.) but latex remains unrendered…

Does the problem comes from the Slack version? or am I the only one having no rendering?

Tried @thisiscam 's python script. Threw an error on line 229 because it didn't like the inspected_file_name 'main-preload-entry-point.bundle.js'. Looking at the json_header dictionary, the file doesn't show up. I changed the inspected_file_name to 'ssb-interop.bundle.js', since that was the file we were previously messing with (pre Slack 4) and it exists in the json_header dictionary. The python script now runs happily, but no change in Slack. Any suggestions from the gurus?

I'm on Ubuntu 18 fwiw.

Which Slack version is this?

Hi, I can't get any script to work for Slack 4.3.3.

So far I tried the @fsavje's v3: https://github.com/fsavje/math-with-slack/blob/v3/math-with-slack.py
@thisiscam's fork https://github.com/thisiscam/math-with-slack/blob/v3/math-with-slack.py
and @hwagyesa's fork https://github.com/hwagyesa/math-with-slack/blob/master/mws-4p2.py

The last two don't send any error (message: Install successful. Please restart Slack.) but latex remains unrendered…

Does the problem comes from the Slack version? or am I the only one having no rendering?

I probably want to know this from someone else, but my Slack 4.3.3 is still rendering math right now.

Tried @thisiscam 's python script. Threw an error on line 229 because it didn't like the inspected_file_name 'main-preload-entry-point.bundle.js'. Looking at the json_header dictionary, the file doesn't show up. I changed the inspected_file_name to 'ssb-interop.bundle.js', since that was the file we were previously messing with (pre Slack 4) and it exists in the json_header dictionary. The python script now runs happily, but no change in Slack. Any suggestions from the gurus?
I'm on Ubuntu 18 fwiw.

Which Slack version is this?

It was 4.0.2. But I had other issues with this version, so I scrapped it and now I'm on 4.3.2, only installed from snap. I know math-with-slack doesn't work with the snap install, but I needed a working version of slack for work. I'll troubleshoot this again over the weekend, but it would be great to get a math-with-slack that works with snap (dunno how feasible that is though).

I probably want to know this from someone else, but my Slack 4.3.3 is still rendering math right now.

I have to take it back, I could see some rendering, which means the install is working etc.
However, it was only for the 2 most recent equations in a one-to-one chat. No other equation in any channel I checked was rendered, and no it's gone :-/

Is there any way I can check a log / error messages?

@reinhold-willcox @julou

So on Mac at least, one can do :

SLACK_DEVELOPER_MENU=1   open /Applications/Slack.app/

to start up Slack, and be able to right-click -> inspect element and show the console messages.

I assume on Linux, there should be something similar.

thanks for the hint. I could find the following mathjax related "warning":

Unhandled rejection TypeError: Q.splitText is not a function    
at s.split (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:278547)    
at T.a.updateDocument (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:338471)    
at t.w.updateDocument (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:183729)    
at t.c.updateDocument (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:335709)    
at t.updateDocument (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:2604498)    
at Object.renderDoc (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:178767)    
at d.renderDoc (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:178990)    
at t.w.render (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:181093)    
at /Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:2608181    
at T (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:238752)    
at L.C [as _execute] (https://a.slack-edge.com/bv1-8-8cacda2/gantry-vendors.1f26a77.min.js?cacheKey=gantry-1585009991:1:58913)    
at L._resolveFromExecutor (https://a.slack-edge.com/bv1-8-8cacda2/gantry-vendors.1f26a77.min.js?cacheKey=gantry-1585009991:1:90075)    
at new L (https://a.slack-edge.com/bv1-8-8cacda2/gantry-vendors.1f26a77.min.js?cacheKey=gantry-1585009991:1:83264)    
at Object.T.handleRetriesFor (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:238718)    
at Object.v.MathJax.typesetPromise (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:2608142)    
at /Applications/Slack.app/Contents/Resources/app.asar/dist/main-preload-entry-point.bundle.js:76:35

I wish I can help more on this, but I cannot reproduce this on my Mac. Maybe some more ideas:

const MathJax = window.MathJax;
    MathJax.startup.promise = MathJax.startup.promise
      .then(() => {console.log(element); return MathJax.typesetPromise(element);})
      .catch((err) => console.log('Typeset failed: ' + err.message));
    return MathJax.startup.promise;

and rerun the script to and see what gets printed by the console.

my channels have a mixture of inline $x$ and block $$x$$ formulas…
I followed your instructions. Here is the new error message (the same with the pointer changed to bundle.js:76:57 at the very end):

Unhandled rejection TypeError: Q.splitText is not a function    
at s.split (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:278547)    
at T.a.updateDocument (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:338471)    
at t.w.updateDocument (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:183729)    
at t.c.updateDocument (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:335709)    
at t.updateDocument (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:2604498)    
at Object.renderDoc (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:178767)    
at d.renderDoc (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:178990)    
at t.w.render (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:181093)    
at /Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:2608181    
at T (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:238752)    
at L.C [as _execute] (https://a.slack-edge.com/bv1-8-8cacda2/gantry-vendors.1f26a77.min.js?cacheKey=gantry-1585009991:1:58913)    
at L._resolveFromExecutor (https://a.slack-edge.com/bv1-8-8cacda2/gantry-vendors.1f26a77.min.js?cacheKey=gantry-1585009991:1:90075)    
at new L (https://a.slack-edge.com/bv1-8-8cacda2/gantry-vendors.1f26a77.min.js?cacheKey=gantry-1585009991:1:83264)    
at Object.T.handleRetriesFor (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:238718)    
at Object.v.MathJax.typesetPromise (/Applications/Slack.app/Contents/Resources/app.asar/node_modules/mathjax/es5/tex-svg-full.js:1:2608142)    
at /Applications/Slack.app/Contents/Resources/app.asar/dist/main-preload-entry-point.bundle.js:76:57

And it didn't print out any elements?

sorry, I was printing errors and warning only…
now I attach the log since there are different elements returned before the error depending on where it happens…
app.slack.com-1585052704374.log

Slack just rolled out 4.4.1 on Mac. I have pushed a fix that should support both the 4.3.3 and 4.4.1 here (script url same as before)

sorry, I was printing errors and warning only…
now I attach the log since there are different elements returned before the error depending on where it happens…
app.slack.com-1585052704374.log

I'm not really sure what's happening. Given that Slack just updated on Mac, is it possible you are seeing this because of a new slack version (e.g. 4.3.3 is new on Ubuntu 18)?

Alright, updated slack, run your new py script.
Same problem still…

So I played a bit to understand when the rendering started failing. I can trigger the issue by entering a line which contains only a latex formula. then all rendering in the current slack session is gone. If Slack is restarted, rendering works fine until the block containing this line is met, then no more rendering until new slack relaunch…

by the way, both single and double $ formula trigger it.

Hope you can reproduce it on your side!

I can confirm this behavior. The key is that one has to enter a line that has ONLY a latex formula, i.e. no other text before or after it. This then breaks all rendering. A restart can fix it as long as one avoids trying to render such a 'latex only' line.

I have pushed a fix that should support both the 4.3.3 and 4.4.1 here (script url same as before)

btw I had to install the python packaging module to run this one. Not sure whether this what intended or overlooked…

I have pushed a fix that should support both the 4.3.3 and 4.4.1 here (script url same as before)

btw I had to install the python packaging module to run this one. Not sure whether this what intended or overlooked…

Sorry, I thought that was built-in. Should be fixed by now

@erikvannimwegen @julou So this is on Ubuntu 18, and an example single line formula as in $x$? Is this in the person-to-person chat view, or the thread view (the right panel)?

I don't think I'm able to reproduce this in any ways above on a Mac. Maybe it's time to invoke my virtual machine

I think I found something. The log @julou sent contains typesetting of elements with class div.p-rich_text_block.p-rich_text_block--inline --- something I've not seen on my OSX Slack. The p-rich_text_block--inline is particularly suspicious. Can you try to locate a div with formula that has this class attribute (presumably it should be a div that breaks rendering), and send a screen shot for what that div looks like ?

Update: Ubuntu 16 + Slack 4.4.0 via Debian renders fine.

@erikvannimwegen @julou Can you try the newest version? I pushed a fix that might solve your problem (likely not, but worth a try)

hi @thisiscam
thanks for caring about the issue!

I tried your newest version (using Slack 4.4.1 on MacOS 10.14.6). The problem is not solved yet, and occurs both on thread and person-to-person chat.

But another example from @erikvannimwegen helped me specified better what triggers the bug:
the rendering stops after trying to render a formula on a latex-only line which is not the first line of the post.

This renders fine

$a nice latex equation$

This stops all rendering after being displayed (for any latex formula in slack).

we model the process assuming
$a nice latex equation$

Please let me know if you can reproduce the issue on your mac, otherwise I will try to create a log for a problematic case.

btw I had to install the python packaging module to run this one. Not sure whether this what intended or overlooked…

Sorry, I thought that was built-in. Should be fixed by now

I tried after uninstalling packaging and it indeed works :)

But another example from @erikvannimwegen helped me specified better what triggers the bug:
the rendering stops after trying to render a formula on a latex-only line which is not the first line of the post.

I can reproduce this now.

@julou Looking at mathjax/MathJax#2202, I fixed the problem by simply updating MathJax to 3.0.1 . You can try the updated script and see if it works for you?

yeah… it works! 🍾🍾🍾
Thank you for your patience… I'd never had thought that it could be a bug in mathjax itself!

Not able to get it to work with Slack 4.6.0 (macOS Catalina). The script runs successfully but has no effect.

Not able to get it to work with Slack 4.6.0 (macOS Catalina). The script runs successfully but has no effect.

I had the same experience. I was concerned when the release notes said the app sandbox was now enabled for all web content that Jax would be broken, and I should have trusted that instinct. I had it up and running for less than a day.

Yes I can confirm that Slack 4.6.0 breaks this. One way around is maybe to somehow inject mathjax as a webpack transpiled module into the preload script.. it will be horribly large though and I'm not sure about its feasibility.

Any suggestions are welcomed!

Ok I pushed a commit thisiscam@80112ad, that includes an inline source of MathJax into preload.js.
Things seems to be working, though not sure how much of performance impact it has on rendering/opening a new page.

Never mind: wget downloaded the HTML, not the python script. I love when Github does that.
When I run the latest commit of math-with-slack.py with sudo python math-with-slack.py on MacOS 10.15.4, I get:

  File "math-with-slack.py", line 6
    <!DOCTYPE html>
    ^
SyntaxError: invalid syntax

@thisiscam, does your version works for Slack 4.7?
I also suggest we close this issue and open ones for different versions of Slack. Then the discussion would be more clear.

@YingzhouLi it is working for me. FYI I'm not the owner of this repo (so I can't close an issue or merge PR). If there are specific questions related to my fork, all are welcomed to leave issues there!

@thisiscam Thanks. Your forked master branch works on my Ubuntu 20.04 with Slack 4.7.0. The code works for Windows as well. I have slightly modified the path search part for Windows in my fork. The readme is also updated slightly. If you prefer, I do a pull request back into your repo.

@thisiscam Thanks. Your forked master branch works on my Ubuntu 20.04 with Slack 4.7.0. The code works for Windows as well. I have slightly modified the path search part for Windows in my fork. The readme is also updated slightly. If you prefer, I do a pull request back into your repo.

This code is working for me as well, I have Windows and Slack 4.7.0. The search path for app.asar is implemented correctly. The only thing missing is having a version of this code not in Python, for those people that don't have Python installed.

Thank you very much!

@YingzhouLi I tried your fork on Windows 10, with Slack 4.8 and it worked. You might want to make the instructions more clear that you want to say "yes" to the most recent slack installation, because if you say "yes" to the oldest, it never prompts you for the newest. It turned out I had folders for both slack 4.7 and 4.8, and couldn't figure out why it wasn't working until I studied your script.

@YingzhouLi If you can submit a PR to my repo, I will merge in your changes. Thanks!

@Dr-Irv Thank you for the suggestion. I have revised the interface to select among multiple versions of Slack. (It seems that new Slack installation will also remove old versions from Windows.)
@thisiscam I have submitted a pull request to your repo.

Is there any version that works on Mac with Slack 4.8.0 ??

@Yuren-Zhong Try this fork https://github.com/YingzhouLi/math-with-slack . It worked for my colleague who has slack 4.8 on Mac

Is there any version that works on Mac with Slack 4.8.0 ??

https://github.com/thisiscam/math-with-slack works for me on Mac with Slack 4.8.0