layerUnlock();
listFigNumber();
alert("finished.");

function layerUnlock(l){
lay = app.activeDocument.layers;
for (i=0; i<lay.length; i++){
lay[i].locked = false;
}
}

function listFigNumber()
{
var ls = []
doc = app.activeDocument.pages;
for (j = 0; j < doc.length; j++){
pg = doc[j]
for (i = 0; i < pg.allGraphics.length; i++){
graphic = pg.allGraphics[i]
graphic.transparencySettings.blendingSettings.opacity = 40;
ls[i] ="null"
try{
ls[i] = graphic.itemLink.name
}catch(e){}
tf = pg.textFrames.add();
tf.move("to",[0, 0]);
tf.contents = "(" + cntNonZeroStart(i) + ")";
tf.geometricBounds = graphic.geometricBounds;
tf.textFramePreferences.verticalJustification = VerticalJustification.centerAlign;
para = tf.paragraphs[0]
para.strokeColor = "スウォッチのカラー名(文字縁色)";
para.fillColor = "スウォッチのカラー名(文字色)";
para.pointSize = "12Q";
para.justification = Justification.centerAlign;
count++;
}
for(i=0; i < ls.length; i++){
textWriter(saveFilePath(), graphicInfo(ls, i, j));
}
}
}

function textWriter(filepath, str){
var fileObj = new File(filepath);
fileObj.open("a");
fileObj.encoding = "UTF-8";
fileObj.lineFeed = "Unix";
fileObj.writeln(str);
fileObj.close();
fileObj = null;
}

function saveFilePath(){
sep = "/"
saveDir = Folder.desktop.fullName + sep;
return saveFilePath = saveDir + app.activeDocument.name + ".txt";
}

function graphicInfo(ls, i, j){
return cntNonZeroStart(j) + "\t" + cntNonZeroStart(i) + "\t" + ls[i]
}

function cntNonZeroStart(i){
return i+1
}