Minimal Chrome extension (8ko) that output the content of clipboard to a new tab

pack 1000B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash -e
  2. #
  3. # Purpose: Pack a Chromium extension directory into crx format
  4. if test $# -ne 2; then
  5. echo "Usage: crxmake.sh <extension dir> <pem path>"
  6. exit 1
  7. fi
  8. dir=$1
  9. key=$2
  10. name="PasteTab"
  11. crx="$name.crx"
  12. pub="$name.pub"
  13. sig="$name.sig"
  14. zip="$name.zip"
  15. trap 'rm -f "$pub" "$sig" "$zip"' EXIT
  16. # zip up the crx dir
  17. cwd=$(pwd -P)
  18. (cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)
  19. # signature
  20. openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig"
  21. # public key
  22. openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null
  23. byte_swap () {
  24. # Take "abcdefgh" and return it as "ghefcdab"
  25. echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}"
  26. }
  27. crmagic_hex="4372 3234" # Cr24
  28. version_hex="0200 0000" # 2
  29. pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}')))
  30. sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}')))
  31. (
  32. echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p
  33. cat "$pub" "$sig" "$zip"
  34. ) > "$crx"
  35. echo "Wrote $crx"