You have JavaScript. You need a bookmarklet. This does that.
Features
- Removes newlines, tabs, optional spaces, and comments
- URL-encodes special ASCII characters: [space], %, ", <, >, #, @, &, ?
- Places code in a wrapper function (if not done already)
- Does not hex-encode non-ASCII characters (you should probably use String.fromCharCode for that)
Use it
License
This is free software. It is released to the public domain without warranty.