mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-12-14 04:12:28 +00:00
2011-06-19
This commit is contained in:
parent
6afa4e6b6d
commit
a4e7d1675d
1 changed files with 5 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
|
|
||||||
// @name Import Discogs releases to MusicBrainz
|
// @name Import Discogs releases to MusicBrainz
|
||||||
// @version 2011-05-26_01
|
// @version 2011-06-19_01
|
||||||
// @namespace http://userscripts.org/users/22504
|
// @namespace http://userscripts.org/users/22504
|
||||||
// @include http://*musicbrainz.org/release/add
|
// @include http://*musicbrainz.org/release/add
|
||||||
// @include http://*musicbrainz.org/release/*/add
|
// @include http://*musicbrainz.org/release/*/add
|
||||||
|
@ -14,9 +14,6 @@
|
||||||
|
|
||||||
// Script Update Checker
|
// Script Update Checker
|
||||||
// -- http://userscripts.org/scripts/show/20145
|
// -- http://userscripts.org/scripts/show/20145
|
||||||
var version_scriptNum = 36376; // Change this to the number given to the script by userscripts.org (check the address bar)
|
|
||||||
var version_timestamp = 1306451747561; // Used to differentiate one version of the script from an older one. Use the (new Date()).getTime() function to get a value for this.
|
|
||||||
|
|
||||||
var SUC_script_num = 36376;
|
var SUC_script_num = 36376;
|
||||||
try{function updateCheck(forced){if ((forced) || (parseInt(GM_getValue('SUC_last_update', '0')) + 86400000 <= (new Date().getTime()))){try{GM_xmlhttpRequest({method: 'GET',url: 'http://userscripts.org/scripts/source/'+SUC_script_num+'.meta.js?'+new Date().getTime(),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=parseInt(/@uso:version\s*(.*?)\s*$/m.exec(rt)[1]);local_version=parseInt(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 > local_version){if(confirm('There is an update available for the Greasemonkey script "'+script_name+'."\nWould you like to go to the install page now?')){GM_openInTab('http://userscripts.org/scripts/show/'+SUC_script_num);GM_setValue('SUC_current_version', remote_version);}}else if (forced)alert('No update is available for "'+script_name+'."');}else GM_setValue('SUC_current_version', remote_version+'');}});}catch (err){if (forced)alert('An error occurred while checking for updates:\n'+err);}}}GM_registerMenuCommand(GM_getValue('SUC_target_script_name', '???') + ' - Manual Update Check', function(){updateCheck(true);});updateCheck(false);}catch(err){}
|
try{function updateCheck(forced){if ((forced) || (parseInt(GM_getValue('SUC_last_update', '0')) + 86400000 <= (new Date().getTime()))){try{GM_xmlhttpRequest({method: 'GET',url: 'http://userscripts.org/scripts/source/'+SUC_script_num+'.meta.js?'+new Date().getTime(),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=parseInt(/@uso:version\s*(.*?)\s*$/m.exec(rt)[1]);local_version=parseInt(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 > local_version){if(confirm('There is an update available for the Greasemonkey script "'+script_name+'."\nWould you like to go to the install page now?')){GM_openInTab('http://userscripts.org/scripts/show/'+SUC_script_num);GM_setValue('SUC_current_version', remote_version);}}else if (forced)alert('No update is available for "'+script_name+'."');}else GM_setValue('SUC_current_version', remote_version+'');}});}catch (err){if (forced)alert('An error occurred while checking for updates:\n'+err);}}}GM_registerMenuCommand(GM_getValue('SUC_target_script_name', '???') + ' - Manual Update Check', function(){updateCheck(true);});updateCheck(false);}catch(err){}
|
||||||
|
|
||||||
|
@ -198,7 +195,7 @@ function insertLink(release) {
|
||||||
var innerHTML = '<form action="http://musicbrainz.org/release/add" method="post" target="_blank">';
|
var innerHTML = '<form action="http://musicbrainz.org/release/add" method="post" target="_blank">';
|
||||||
parameters.forEach(function(parameter) {
|
parameters.forEach(function(parameter) {
|
||||||
var value = parameter.value + "";
|
var value = parameter.value + "";
|
||||||
innerHTML += "<input type='hidden' value='" + value.replace("'","'") + "' name='" + parameter.name + "'/>";
|
innerHTML += "<input type='hidden' value='" + value.replace(/'/g,"'") + "' name='" + parameter.name + "'/>";
|
||||||
});
|
});
|
||||||
|
|
||||||
innerHTML += '<input type="submit" value="Import into MB">';
|
innerHTML += '<input type="submit" value="Import into MB">';
|
||||||
|
@ -233,8 +230,9 @@ function appendParameter(parameters, paramName, paramValue) {
|
||||||
parameters.push( { name: paramName, value: paramValue } );
|
parameters.push( { name: paramName, value: paramValue } );
|
||||||
}
|
}
|
||||||
|
|
||||||
function luceneEscape(string) {
|
function luceneEscape(text) {
|
||||||
return encodeURIComponent(string.replace(/\-|\/|\(\)/, ""));
|
var newtext = text.replace(/[-[\]{}()*+?~:\\^!"]/g, "\\$&");
|
||||||
|
return newtext.replace("&&", "\&&").replace("||", "\||");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function: compute url for a release object
|
// Helper function: compute url for a release object
|
||||||
|
|
Loading…
Reference in a new issue