3

In Slack setting there is status looks like

John Doe is typing ...

I found in the preferences a way to hide it with:

Additional options

☑️ Display information about who is currently typing a message

But my question is, does this also stop my client from sending the "is typing" notification?

If not, is there a way to stop client from sending the "is typing" info?

1 Answer 1

3

does this also stop my client from sending the "is typing" notification?

It does not.


Chromium

If you're on a Chromium browser (or a browser that can install Chrome extensions), you can install the Slack Hide Typing browser extension.

I've reviewed the code and tested it as of 25 April 2023, and at the time it was safe to install and worked as intended.

Firefox

Unfortunately, I don't think this is possible in Firefox unless the Content-Security-Policy (CSP) feature is disabled, which would lead to security implications.

Due to a bug still present in Firefox 112, the main way to block the relevant transmission is to open developer tools, navigate to the Console tab, and paste the script at the bottom of this answer. This would have to be done every time you reload the page. Extensions, userscripts, and bookmarklets should be able to bypass the CSP as well, but currently don't, which makes it unviable. [reference]

Outdated

You can achieve this by injecting custom JavaScript into the page by either:

  • Defining a userscript using a browser extension like Violentmonkey.
  • Defining a custom Insert Scripts rule using a browser extension like Requestly.
  • Pasting it into the developer tools Console, however, this will stop working on reload.

Since Slack uses a WebSocket to communicate, we can hijack the WebSocket#send function and replace it with our own. Then we can check the arguments being passed in first, and drop it if it matches our requirements. In this case, we want to drop outgoing transmissions if the type is equal to user_typing, which is what indicates that you were typing to Slack's servers.

// Site-specific configuration.

/** 
 * Key/value pairs for filtering outgoing transmissions. If any match, the
 * outgoing transmission is dropped.
 * 
 * In each nested array, index 0 represents the property key, and index 1
 * represents the value it must equal to be considered a match.
 * 
 * @type {string[][]}
 */
const FILTER_CONDITIONS = [
  ["type", "user_typing"]
];

// Generic script for blocking outgoing WebSocket messages.

/**
 * The original {@link WebSocket#send} implementation.
 * 
 * @type {function}
 */
const SEND = window.WebSocket.prototype.send;

/**
 * Wrapper around the built-in {@link WebSocket#send} function, but filtering
 * events against {@link FILTER_CONDITIONS}.
 * 
 * @param {string | ArrayBufferLike | Blob | ArrayBufferView} data
 */
function preprocessedSend(data) {
  if (typeof data !== 'string') {
    console.log('Received non-string data, forwarding without check.');
    return SEND.apply(this, [data]);
  }

  try {
    const parsed = JSON.parse(data);

    for (const pair of FILTER_CONDITIONS) {
      if (parsed[pair[0]] === pair[1]) {
        return;
      }
    }

    return SEND.apply(this, [data]);
  } catch (err) {
    if (err instanceof SyntaxError) {
      console.log('Received non-JSON data, forwarding without check.');
      return SEND.apply(this, [data]);
    }

    throw err;
  }
}

window.WebSocket.prototype.send = preprocessedSend;

Based on Slack Hide Typing, an open-source Chrome extension.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.