Properly encode greasemonkey-script URI's paths.

This ensures URIs containing reserved characters for URI components
(like "#") are handled correctly. Previously, any modification to
such an URI's hash would lead to mis-parsing of the resource name.

One example where we don't fully control the URI's hash are favicons,
which have their icon size appended to the hash.

Fixes #1955.