Today I’ll be starting a new series of posts called “Fixing stupid things that should not have been stupid in the first place”, or FSTTSNHBSITFP… Mmmm, just rolls off the tongue.
Anyway.
Logging in to Slack this morning, I noticed an irritating change.
Almost every message was followed by a “Translate” button. What a waste of screen real-estate!
At first, I thought it was another AI crap. It’s been absolutely everywhere lately.
Okay, I so very much want to get rid of this. But how?
If you’re on Firefox (which you should), just add a
uBlock Origin filter for app.slack.com##[class^="translationsBar"]
.
If you’re on Chrome or a derivative, use Firefox.
But I use the desktop app because I have multiple workspaces open…
I know Slack desktop is built with Electron (yuck). Electron is
Chromium (yuck two). It does, however mean that it has full devtools somewhere. Good!
F12
? No. Ctrl + Alt + I
? No. The internet claims Slack has a /slackdevtools
command that should display the
devtools dialog. It doesn’t…
Wait. Doesn’t Chrome have remote a debugging thing? Bingo!
Running slack --remote-debugging-port=9222
got the Slack desktop app running and for a second I saw a log line
scrolling by that mentioned the port. From there on you should go to http://localhost:9222
where you’re presented with
two choices. One for a page
type and another for a service worker. I’m already getting way more excited that I should
be! But clicking on the “Slack” process gives me an error.
Hmm…
Ah, CORS. The root of like most issues on the web.
slack --remote-debugging-port=9222 --remote-allow-origin=http://localhost:9222
.
Much better. First thought is to look for elements with a classname beginning with translationsBar
and simply delete
them from the DOM.
|
|
It works! Hella cool! But
- It’s way too resource intensive
- It’s not that smooth…
What about hiding the elements with CSS?
|
|
Works even better! The buttons are simply gone, and no need to periodically remove them! But it’s still too manual labor-y. Can I script it somehow? Yes!
|
|
I feel like a frickin’ hackerman doing websocket stuff here!
Now I need to figure out how to persist the new element through restarts. And I don’t really like the idea of constantly having remote devtools accessible.
Digging through The Internet I am repeatedly told to look for ssb-interop.js
in the Slack installation directory.
Several Reddit and StackOverflow threads point to this elusive file, claiming to allow preloading code before the
application starts, all without having to script around it using remote devtools.
Weirdly enough, eventually it is ChatGPT that tells me the ssb-interop.js
is deprecated in Slack Desktop client v4,
and seems to now be replaced by preload.bundle.js
. Coolio! That is a file I can see!
Wait, see where? Yea, Electron seems to package most of the application code in app.asar
file. I was able to pacman -Sy asar
the cli, and run asar list /usr/lib/slack/resources/app.asar
to see the contents of the archive.
From there I vibe-coded (yuck) a script to patch the preload bundle to also load some CSS that hides the translation
elements. The script also repacks the app.asar
file and places it in the correct directory.
|
|
Btw, the script has way too many emojis. But I am too lazy to manually remove them, and I’ve already closed the ChatGPT page to have it do this for me. Oh, well.
Running this script errors out the first time. I forgot sudo
because it needs to write to /usr/lib
. Fine.
sudo ./patch.sh
. I am greeted with ✅ Slack patched successfully! Restart Slack to see the changes.
- looking
around in the restarted Slack app, I see no “Translate” buttons! Party!
Now, tonight of today, writing this post I realized the translation buttons were introduced by an app. I don’t know whether it was installed by Slack themselves or an admin, but I’ve gotten rid of the button now.
Am content.