Hello guys,
I wrote a script including an auto update function which looks like
that (a small truncated version):
GM_registerMenuCommand("Update: SkriptABC'", function ()
{ updateCheck(true); });
function updateCheck(forced) {
if (forced || parseInt(eval(GM_getValue('lastUpdateCheck', '0'))) +
3600000 <= (new Date().getTime())) {
GM_xmlhttpRequest({
method: "HEAD",
headers: {'Cache-Control': 'no-cache'},
url: scriptUrl,
onload: function(r) {
GM_xmlhttpRequest({
method: "GET",
url: some-newUrl,
headers: { 'Cache-Control': 'no-cache' },
onload: function(r) {
var changelog = r.responseText;
if (changelog) {
window.location = "
http://some-url.com/xx/
scriptABC.user.js";
//
}
}
});
}
});
}
updateCheck(false); //will executed all the time the scripts get
loaded.
the problem is following. When the update check is executed by
updateCheck(false); and parseInt(eval(GM_getValue('lastUpdateCheck',
'0'))) + 3600000 <= (new Date().getTime()) is true and a chancelog
could be found window.location just loads the script and shows the
source code. It won't open the GM installing code screen.
When I'm using the registerMenuCommand by clicking on the monkey and
selecting the "Update: SkriptABC" menu item the window.location
command shows me the GM installing code screen.
I am using window.location because I don't want to open a new tab by
GM_openInTab and show the url to that userscript.
So is there any workaround? Looks like window.location won't trigger
the installing screen all the time.