I defined the version of my user script in the meta block, like this:
// ==UserScript==
// @name Script Name
// @description Something about what this script does
// @include http://www.example.com/
// @version 5.3.0
// @run-at document-end
// ==/UserScript==
Is there a way to get the version number that I defined? I want to be able to do something like alert("This is version " + SCRIPT_VERSION + ".");
.
If you upgrade to Greasemonkey 0.9.16 (just released), you can use the brand new GM_info
object.
You can add this to your script example, above:
var myVersion = GM_info.script.version;
console.log ('Version: ', myVersion, myVersion === "5.3.0");
Which would output this to the console:
Version: 5.3.0 true
For GM versions prior to 0.9.16, you'd have to either read your own script in as a @resource
or use encapsulation techniques as shown in "Knowing Your Own Metadata".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With