Closed Spenhouet closed 6 years ago
Are you talking about the Slack App that you get from Windows Store? Because the 64-bit installer from slack website works just fine for me with the following index.js
file: (Slack version (2.9.0))
//do not migrate preload script into TypeScript
require('../stat-cache');
const profiler = require('../utils/profiler');
if (profiler.shouldProfile()) profiler.startProfiling();
var startup = function() {
var url = require('url');
// Skip "?loadSettings=".
var fileUri = url.parse(window.location.href);
var queryParts = fileUri.query.split('&');
var loadSettingsStr = null;
for (var j=0; j < queryParts.length; j++) {
if (queryParts[j].match(/loadSettings/)) {
loadSettingsStr = queryParts[j].replace("loadSettings=", "");
break;
}
}
var loadSettings = JSON.parse(decodeURIComponent(loadSettingsStr));
// Require before the module cache in dev mode
window.loadSettings = loadSettings;
var noCommitVersion = loadSettings.version.split('-')[0];
var shouldSuppressErrors = loadSettings.devMode;
if (!loadSettings.isSpec) {
require('../renderer/bugsnag-setup').setupBugsnag(shouldSuppressErrors, noCommitVersion);
}
if (loadSettings.bootstrapScript) {
require(loadSettings.bootstrapScript);
}
};
document.addEventListener("DOMContentLoaded", function() { // eslint-disable-line
try {
startup();
// *** Code injected for MathJax support
// See: https://github.com/fsavje/math-with-slack
var mathjax_inject_script = `
var mathjax_config = document.createElement("script");
mathjax_config.type = "text/x-mathjax-config";
mathjax_config.text = \`
MathJax.Hub.Config({
messageStyle: "none",
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
skipTags: ["script","noscript","style","textarea","pre","code"],
inlineMath: [ ['\$','\$'] ],
displayMath: [ ['\$\$','\$\$'] ],
processEscapes: true
},
TeX: {
extensions: ["noErrors.js", "noUndefined.js"]
}
});
\`;
var mathjax_script = document.createElement("script");
mathjax_script.type = "text/javascript";
mathjax_script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js";
document.getElementsByTagName("head")[0].appendChild(mathjax_config);
document.getElementsByTagName("head")[0].appendChild(mathjax_script);
var render = function (records, observer) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
};
var target = document.querySelector('#msgs_div');
var observer = new MutationObserver(render);
var config = { attributes: false, childList: true, characterData: true, subtree: true };
observer.observe(target, config);
`;
window.webviews = document.querySelectorAll(".TeamView webview");
setTimeout(function() {
for(var i = 0; i < webviews.length; i++) {
webviews[i].executeJavaScript(mathjax_inject_script);
}
}, 10000);
// *** End injected MathJax
} catch (e) {
console.log(e.stack);
if (window.Bugsnag) {
window.Bugsnag.notifyException(e, "Renderer crash");
}
throw e;
}
});
@crstnbr Yes, I'm talking about the Windows Store App.
Can you locate an index.js
somewhere?
@crstnbr I found the index.js
in a sub folder: \app\resources\app.asar.unpacked\src\static\index.js
Do I only need to modify this file? I'm not sure if modifying this file works or would take effect.
It looks like the folder structure is changed for the Windows 10 app.
@Spenhouet Could you please try to run the following and report if it works:
math_with_slack.bat %UserProfile%\AppData\Local\slack\app\resources\app.asar.unpacked\src\static
@fsavje The \app
folder is located in another directory (see command bellow). The slack main folder contains multiple long character strings that look like IDs (therefore I removed them -> marked with <removed>
).
The script found the index.js and said it was installed successfully but actually can't get write access and therefore doesn't install anything (the script was started with admin rights).
math_with_slack.bat "C:\Program Files\WindowsApps\<removed>.Slack_2.9.0.0_x64__<removed>\app\resources\app.asar.unpacked\src\static"
Using Slack installation at: C:\Program Files\WindowsApps\<removed>.Slack_2.9.0.0_x64__<removed>\app\resources\app.asar.unpacked\src\static
Zugriff verweigert
Zugriff verweigert
Zugriff verweigert
Zugriff verweigert
Zugriff verweigert
math-with-slack has been installed. Please restart the Slack client.
Drücken Sie eine beliebige Taste . . .
@fsavje Why was this closed?
@Spenhouet Sorry, I forgot to push the changes. They'll be online in a few minute.
The issue here is that Windows Store installs the app in a weird location. To minimize the risk for errors, I decided not to write up a script that searches the hard drive for possible Slack installations. Instead, users who have installed the Windows Store version will thus have to specify Slack's location themselves.
@fsavje Oh I see. Thank you 👍 Did you test it with the Windows Store App? If no, I could test it when the changes are up.
@Spenhouet That would have been great. The new version is live. Let me know how it goes.
It doesn't work for me.
What I did:
math-with-slack.bat "C:\Program Files\WindowsApps\91750D7E.Slack_3.0.5.0_x64__8she8kybcnzg4\app\resources\app.asar.unpacked\src\static"
Output:
Using Slack installation at: C:\Program Files\WindowsApps\91750D7E.Slack_3.0.5.0_x64__8she8kybcnzg4\app\resources\app.asar.unpacked\src\static
Zugriff verweigert
Zugriff verweigert
Zugriff verweigert
math-with-slack has been installed. Please restart the Slack client.
Drücken Sie eine beliebige Taste . . .
It seems the script doesn't get full access right even with the console started with admin access.
I'm not sure but I think the WindowApp Folder / environment is very restricted. I'm not sure it will allow changes at all, see:
@Spenhouet Hmm, I see. I think you're right, the WindowApp folder is not editable by the user even with admin access. I don't want to hack this too much as it could be flagged as malicious code. Unfortunately, this means that the Windows Store app won't be supported. The app downloaded directly from Slack should, however, still work. If you decide to try that out, please let me know if it works.
@fsavje I guess the original slack app works as it did before. This issue was only meant for the Windows Store App.
Sad to hear that there seems to be no other way then to stop the support for the Windows Store App Slack version. Thanks for pointing this out in the math-with-slack README. 👍
Yeah, unfortunately there is no (easy) way to solve this it seems. I'm very grateful for your help! I hope it's OK that I add you as a contributor.
Sure 👍
I'm using the Windows 10 Slack App. It seems I can't install this math-with-slack.
The Slack App installation dir looks very different:
app dir: