librewolf-xorigin.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. # Automated script to change XOriginPolicy value in LibreWolf for fixing video
  3. # playback issues on certain websites. Note: This is for Appimages only.
  4. # Details: https://freehub.space/item/62631183-9b48-4625-836b-1f383a0eb7bd
  5. #
  6. # Usage:
  7. # 1. Download the latest LibreWolf Appimage from:
  8. # https://gitlab.com/librewolf-community/browser/linux/-/releases
  9. # 2. Run this script with the appimage file as the parameter:
  10. # bash librewolf-xorigin.sh path/to/LibreWolf-*.Appimage
  11. # 3. When it's done and asks to overwrite the original Appimage file, enter y
  12. if [ -f "$1" ]; then
  13. # Prepare variables
  14. tmppath="/tmp/lw-xorigin"
  15. appimage_filepath="$(realpath $1)"
  16. appimage_filename="$(basename $1)"
  17. # Prepare /tmp
  18. mkdir -p "$tmppath"
  19. cp "$appimage_filepath" "$tmppath/$appimage_filename"
  20. cd "$tmppath"
  21. chmod +x "$appimage_filename"
  22. "./$appimage_filename" --appimage-extract
  23. # Change the value in librewolf.cfg
  24. sed -i 's/"network.http.referer.XOriginPolicy", 1/"network.http.referer.XOriginPolicy", 0/' squashfs-root/librewolf.cfg
  25. # Create the Appimage back
  26. if [ -x "$(command -v appimagetool)" ]; then
  27. appimagetool -v squashfs-root
  28. else
  29. curl -LO https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage | wget https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage
  30. chmod +x appimagetool-x86_64.AppImage
  31. ./appimagetool-x86_64.AppImage -v squashfs-root "$appimage_filename"
  32. fi
  33. # Ask to overwrite the original Appimage with the modified one
  34. echo "Modified version of the Appimage has been created. Please enter \"y\" when asked to overwrite to apply the changes to $appimage_filepath."
  35. cp -i "$appimage_filename" "$appimage_filepath"
  36. # We're done, so delete the temporary directory
  37. rm -rf "$tmppath"
  38. else
  39. # The file doesn't exist...
  40. # because there are no file with the input name
  41. if [ -x "$1" ]; then
  42. echo "The file $1 doesn't exist. Please provide a valid appimage file as parameter."
  43. # because there are no filename given
  44. else
  45. echo "No filename given. Please provide the appimage file as parameter."
  46. fi
  47. fi