Created
February 21, 2011 10:17
-
-
Save tmyt/836895 to your computer and use it in GitHub Desktop.
Azurea ColorLabel Preview support script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Azurea 1.3.2.ColorLabelPreviewを利用してカラーラベルを利用するためのサポートスクリプト | |
ColorLabelPreviewとセットで使用してください。 | |
http://refy.net/temp/Azurea.1.3.2.ColorLabelPreview.1.i386.exe | |
http://refy.net/temp/Azurea.1.3.2.ColorLabelPreview.1.ARMv5T.exe | |
使用方法 | |
Scripts\以下に任意のファイル名で保存 | |
テキストエリアからsetcolor(screen_name,colorcode)とPostする | |
screen_nameはカラーラベルを設定したいユーザのスクリーンネーム、 | |
colorcodeは16進数でBBGGRR形式で指定してください。 | |
colorcodeに-1を指定すると設定をクリアできます。 | |
*/ | |
var colors = new Array(); | |
// String prototype replaceAll extension from http://www.syboos.jp/webjs/doc/string-replace-and-replaceall.html | |
String.prototype.replaceAll = function (org, dest){ | |
return this.split(org).join(dest); | |
} | |
// makeJSON from http://q.hatena.ne.jp/1166750204 | |
function makeJSON(hash){ | |
var init = true; | |
var str = '{'; | |
for(var i in hash){ | |
if(!init) str += ','; | |
str += '"' + i.replaceAll('"', '\\"') + '":"'; | |
str += ("" + hash[i]).replaceAll('"', '\\"') + '"'; | |
init = false; | |
} | |
str += '}'; | |
return str; | |
} | |
function PreSendUpdateStatus(status) | |
{ | |
if(status.text.match('setcolor\\([ ]*(.+?)[ ]*,[ ]*(.+?)[ ]*\\)')){ | |
var name = RegExp.$1; | |
var color = RegExp.$2; | |
if(color.charAt(0) == '-'){ | |
delete colors[name]; | |
}else{ | |
var n = parseInt(color, 16); | |
System.setColorLabel(name, n); | |
colors[name] = n; | |
} | |
System.settings.setValue('user.colorLabel', 'colorLabels', makeJSON(colors)); | |
System.settings.reconfigure(); | |
return true; | |
} | |
} | |
var settingJson = System.settings.getValue('user.colorLabel', 'colorLabels'); | |
if(settingJson != ''){ | |
colors = eval('(' + settingJson + ')'); | |
} | |
for(var i in colors){ | |
System.setColorLabel(i, colors[i] + 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment