Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to update user script in greasemonkey
    primarykey
    data
    text
    <p>I have an issue with Greasemonkey, it doesn't update my script automatically (probably because we don't want to add it to its UserScripts root, and it seems in this case it doesn't update it)... </p> <p>anyway, I was adding a piece of code (main idea from <a href="http://userscripts.org/scripts/show/20145" rel="nofollow">here</a>) to my script to check the script version inside the script and let user know if there is a new version available, and as if user wants to update it, if so it should open a new window/tab for script url (that it should trigger Greasemonkey to install it)... this is my senario, and it works perfect up to the point that it should open a new window/tab...</p> <p>here you can see the function I'm using:</p> <pre><code>function checkForUpdate(in_vid){ var plugin_url = 'https://MyWebSiteURL/MonaTest.user.js?'+new Date().getTime(); if ((parseInt(GM_getValue('SUC_last_update', '0')) + 86400000 &lt;= (new Date().getTime()))){ try { GM_xmlhttpRequest( { method: 'GET', url: plugin_url, headers: {'Cache-Control': 'no-cache'}, onload: function(resp){ var local_version, remote_version, rt, script_name; rt=resp.responseText; GM_setValue('SUC_last_update', new Date().getTime()+''); remote_version = parseFloat(/@version\s*(.*?)\s*$/m.exec(rt)[1]); local_version = parseFloat(GM_getValue('SUC_current_version', '-1')); if(local_version!=-1){ script_name = (/@name\s*(.*?)\s*$/m.exec(rt))[1]; GM_setValue('SUC_target_script_name', script_name); if (remote_version &gt; local_version){ if(confirm('There is an update available for the Greasemonkey script "'+script_name+'."\nWould you like to install it now?')){ -------&gt; GM_openInTab(plugin_url); //window.open(plugin_url,'_blank') //location.assign(plugin_url); GM_setValue('SUC_current_version', remote_version); } } else{ GM_log('No update is available for "'+script_name+'"'); } } else{ GM_setValue('SUC_current_version', remote_version+''); } } }); } catch (err){ GM_log('An error occurred while checking for updates:\n'+err); } } } </code></pre> <p>I tried to use GM_openInTab, but it returns this error in the console:</p> <pre><code>Timestamp: 9/27/12 9:55:33 AM Error: ReferenceError: GM_openInTab is not defined Source File: file:///Users/Mona/Library/Application%20Support/Firefox/Profiles/tonwb5lg.default/gm_scripts/MonaTest/MonaTest.user.js Line: 97 </code></pre> <p>I couldn't find any reference to indicate that GM_openInTab doesn't support anymore!</p> <p>I tried other solutions, using window.open and location.assign... both of them doesn't work because they shows the script source codes without triggering Greasemonkey to install it... </p> <p>I don't know if there is a way to update script using this method... I would appreciate if you share your knowledge and help me with my problem.</p> <p>Thanks for your time!</p> <p>P.S. My firefox version is 15.0.1, Greasemonkey version is 1.1 </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload