How to get the @version ?
![]() ![]() |
Is there anyway to make var for @version from local and remote ? So you can see the "real" version number instead av the version number that its getting now. Thanks for the code btw ! |
![]() ![]() |
I don't know of a way to get any meta-data for the local copy of the script; however, Greasemonkey probably has a way to do it by now. |
![]() ![]() |
the local version can you just add a variable manually. dont you know about getting the remote "real" version number ? |
![]() ![]() |
I'm not sure what you're asking. |
![]() ![]() |
hm, how to creating a var from the version on the site. for example if you take my script http://userscripts.org/scripts/show/56716, in the code i got the meta-data "@version". var localver = "1.2.4.1.1"; //this value can I change manually every time I update the script
so i can get this to work I can just be using a message when a new version is out, like;
My english is not the best, hope you get what I meant. |
![]() ![]() |
You'd have to parse it out of the meta.js file for that script. Probably something like this (I haven't tested this, so there might be some syntax errors):
var script_number=56716;
try
{
GM_xmlhttpRequest(
{
method: 'GET',
url: 'http://userscripts.org/scripts/source/'+ script_number +'.meta.js?'+new Date().getTime(),
headers: {'Cache-Control': 'no-cache'},
onload: function(resp)
{
var remote_version;
remote_version=parseInt(/@version\s*(.*?)\s*$/m.exec(resp.responseText)[1]);
alert('Remote version is: '+ remote_version);
}
});
}
catch (err)
{
alert('An error occurred while checking the version:\n'+ err);
}
|
![]() ![]() |
yes, that was something i was looking for.
|
![]() ![]() |
No problem. |
![]() ![]() |
also check out the metadata block info on http://wiki.greasespot.net/Metadata_block. This has a very good example on parsing metadata for local and remote scripts! :)
for each (line in lines) {
to
var i=0;
for each (line in lines) {
if (++i > lines.length) break; // to control error in looping from remote responses
because the loop was continuing even after reaching the last element... don't know why. |
![]() ![]() |
Ah, thanks. I figured there was a way to get the local metadata; I just didn't know what it was. |

