Skip to content

Instantly share code, notes, and snippets.

@asvdvl
Last active October 26, 2023 00:03
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 asvdvl/1f0b1156160cffa97b333ce789825b79 to your computer and use it in GitHub Desktop.
Save asvdvl/1f0b1156160cffa97b333ce789825b79 to your computer and use it in GitHub Desktop.
Discord: removing idiotic parameters from a link
#!/bin/bash
#FIRST, this script is only for Linux, download, run something like this: `./dsLinkCorrector.sh`, required clipnotify(https://github.com/cdown/clipnotify)
#How it works: when copying (primary/clipboard), it corrects the link and places it in the primary buffer (pasting on the mouse wheel or ctrl+v)
#what is he doing:
##checks that this is really a cdn discord link
##removes everything after the `?` sign (cdn parameters)
##changes media.discordapp.net to cdn.discordapp.com and removes sizing overrides
cdnCheck="https\S+(cdn|media)\.discord"
while clipnotify; do
content=$(xclip -o)
if [[ $content =~ $cdnCheck ]]; then
content=$(echo "$content" | sed 's/\?.*//gm')
content=$(echo "$content" | sed 's/media\.discordapp\.net/cdn\.discordapp\.com/gm')
echo "$content" | xclip
##uncomment next line for able to use ctrl+v for paste links,
##However, it does cause a problem if you need to copy an image or other object and the clipboard already has a discord cdn link, object will just be rewritten by the link.
#echo "$content" | xclip -selection clipboard
echo "$content"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment