Skip to content

Instantly share code, notes, and snippets.

@iskigow
Last active April 23, 2024 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iskigow/305e4fd14b718a8e233da612f35c1c12 to your computer and use it in GitHub Desktop.
Save iskigow/305e4fd14b718a8e233da612f35c1c12 to your computer and use it in GitHub Desktop.
Script to correct the expected behavior of browsing Slack history using the mouse back and forward buttons.
#!/bin/bash
:<<'END-INFO'
hackMouseBrowsingSlackHistory.sh - Script to correct the expected behavior of browsing Slack
history using the mouse back and forward buttons.
Autor: R. Catto <rcatto@iskigow.com>
--------------------------------------------------------------------------------------------------
This script is base answer on reddit thread (https://www.reddit.com/r/Slack/comments/qfodd7/comment/k4937gj/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button)
Exemplos:
$ hackMouseBrowsingSlackHistory.sh
$ hackMouseBrowsingSlackHistory.sh /custom/location/lib/slack/resources/app.asar
--------------------------------------------------------------------------------------------------
Changelog:
v1.0 2023-11-29, R. Catto:
- initial version, just create as answer suggestion;
v1.1 2023-11-29, R. Catto:
- permit informe a custom location and make a bkp file with date time info
(app.asar.20231129141751432.hackbkp);
v1.2 2023-11-29, R. Catto:
- test if the file has the pattern before the backup and replace;
v1.3 2023-11-29, R. Catto:
- Allow exec the script via curl and fix logic version
v1.4 2024-04-16, R. Catto:
- Fix regex replace;
v1.5 2024-04-16, R. Catto:
- Fix space replace, because without slack won't open;
License [ (CC) by ]
END-INFO
APP_ASAR_LOCATION="/usr/lib/slack/resources/app.asar"
SEARCH_PATTERN='case"browser-backward":f0(-1,g.webContents);break;case"browser-forward":f0(1,g.webContents);break'
REPLACE_PATTERN='case"browser-backward":f0( 0,g.webContents);break;case"browser-forward":f0(0,g.webContents);break'
SED_PATTERN="s/${SEARCH_PATTERN}/${REPLACE_PATTERN}/"
CUSTOM_APP_ASAR_LOCATION=$1
Version () {
echo
echo "$(basename "$0")"
[ -f "$0" ] && grep -E 'v[0-9]+[.][0-9]+' "$0" | tail -1 | cut -d ',' -f 1 | tr -d \# || {
curl -sSL https://gist.githubusercontent.com/iskigow/305e4fd14b718a8e233da612f35c1c12/raw/hackMouseBrowsingSlackHistory.sh | grep -E 'v[0-9]+[.][0-9]+' | tail -1 | cut -d ',' -f 1 | tr -d \#
}
echo
}
HowTo() {
echo
echo "Usage:"
echo " $(basename "$0") [custom Slack app.asar location] # hack Slack elsewhere installation location"
echo " $(basename "$0") -v, --version # show the script version"
echo " $(basename "$0") -h, --help # show this help"
echo
}
# Do I have to show help or version?
case "$1" in
-h | --help ) HowTo ; exit 0 ;;
-v | --version) Version ; exit 0 ;;
esac
[ -z "${CUSTOM_APP_ASAR_LOCATION}" ] || {
echo "Using informed Slack app.asar location..."
APP_ASAR_LOCATION="${CUSTOM_APP_ASAR_LOCATION}"
}
[ -f "${APP_ASAR_LOCATION}" ] || {
echo "The Slack app.asar file is located elsewhere..."
echo "The expected location is: [ ${APP_ASAR_LOCATION} ]"
HowTo
exit 1
}
if grep "${SEARCH_PATTERN}" ${APP_ASAR_LOCATION} > /dev/null 2>&1; then
echo "Sudo is needed..."
echo
echo "Hacking the behavior of browsing Slack history for mouse navigation..."
BACKUP_SUFFIX="$(date +%Y%m%d%H%M%S%N | cut -c 1-17).hackbkp"
echo "Backing up as [${APP_ASAR_LOCATION}.${BACKUP_SUFFIX} ] and changing app.asar file: [ ${APP_ASAR_LOCATION} ]..."
sudo sed -i.${BACKUP_SUFFIX} "${SED_PATTERN}" ${APP_ASAR_LOCATION}
echo "Reopen Slack please..."
else
echo "It was not possible to make the hack, as the file has already been changed or is not in the expected pattern."
fi
echo
@iskigow
Copy link
Author

iskigow commented Nov 29, 2023

running from web:

$ curl -sSL https://gist.githubusercontent.com/iskigow/305e4fd14b718a8e233da612f35c1c12/raw/hackMouseBrowsingSlackHistory.sh | bash -s --

Help:

$ curl -sSL https://gist.githubusercontent.com/iskigow/305e4fd14b718a8e233da612f35c1c12/raw/hackMouseBrowsingSlackHistory.sh | bash -s -- --help

Version:

$ curl -sSL https://gist.githubusercontent.com/iskigow/305e4fd14b718a8e233da612f35c1c12/raw/hackMouseBrowsingSlackHistory.sh | bash -s -- --version

Custom app.asar location:

$ curl -sSL https://gist.githubusercontent.com/iskigow/305e4fd14b718a8e233da612f35c1c12/raw/hackMouseBrowsingSlackHistory.sh | bash -s -- /custom/location/lib/slack/resources/app.asar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment