namespacesmetadatagreasemonkeyuserscripts

What is the Greasemonkey namespace needed for?


I'm learning how to use Greasemonkey, and was wondering what the @namespace metadata id is for.

Does it have to be a web address? Or can it be a folder/directory on my computer?

Does it even need to be filled in?


Solution

  • A namespace is used to avoid naming collisions. If you called your script foobar and someone else did as well, then central repositories would have a hard time telling them apart.

    Therefore you should provide some URL that you control (i.e. you own it or can administrate it) that basically means "everything with that URL is by me". Now those central repositories can distinguish between foobar from http://somesite.com/ and foobar from http://anothersite.com.

    It's not necessary for basic operation, but strongly suggested if you want to share your scripts.

    Keep in mind that mailto:someone@example.com is also a valid URL and might be a possible option when you don't own or control a domain of your own.