SteamTransaction2TSV
Convert Steam account transactions data
into Tab-Separated-Values Format.
スチームアカウントの購買ログがExcelとかで
扱いにくすぎるのでタブ区切り形式に変換するよ
/**
* Copyright miyaoka ( http://wonderfl.net/user/miyaoka )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sKt4
*/
package
{
import flash.display.Sprite;
import com.bit101.components.PushButton;
import com.bit101.components.Label;
import flash.events.FocusEvent;
import flash.events.MouseEvent;
import flash.system.System;
import flash.text.TextField;
import flash.text.TextFieldType;
/**
* Convert Steam account transactions data
* into Tab-Separated-Values Format.
*
* スチームアカウントの購買ログがExcelとかで
* 扱いにくすぎるのでタブ区切り形式に変換するよ
*/
[SWF(width="465", height="465", backgroundColor= 0xffffff, frameRate="60")]
public class SteamTransaction2TSV
extends Sprite
{
private static const SEARCH_URL_BASE:String = "http://store.steampowered.com/search/?term=";
public function SteamTransaction2TSV()
{
new Label(this, 20, 20, "1. Open your Steam account page. (https://store.steampowered.com/account/)\n2. Copy the source text and paste it to 'Source' textarea.\n3. Push 'Convert' button.");
var tfSrc:TextField = new TextField();
var tfTra:TextField = new TextField();
var tfLic:TextField = new TextField();
var tfs:Array = [tfSrc, tfTra, tfLic];
var lbls:Array = ["Source", "Transactions", "Licenses"];
for (var i:int = 0; i < tfs.length; i++ )
{
new Label(this, 20 + i*140, 100, lbls[i]);
var tf:TextField = tfs[i];
tf.x = 20 + i * 140;
tf.y = 120;
tf.width = 120;
tf.height = 160;
tf.border = true;
tf.type = TextFieldType.INPUT;
tf.multiline = true;
addChild(tf);
}
new PushButton(this, 20, 300, "Convert", function ():void
{
var text:String = num2char(tfSrc.text);
tfTra.text = "Recent Steam Store Transactions\n" + transactions(text)
tfLic.text = "Licenses and subscriptions\n" + licenses(text);
});
new PushButton(this, 160, 300, "Copy to clipboard", function ():void
{
System.setClipboard(tfTra.text);
});
new PushButton(this, 300, 300, "Copy to clipboard", function ():void
{
System.setClipboard(tfLic.text);
});
}
private function transactions(text:String):String
{
return text
.replace(/.*Recent Steam Store Transactions(.*?)<!-- End Center Column -->.*/si, "$1"
).replace(/^\s+|\s+$/mg, ""
).replace(/[\n\r\t]/g, ""
).replace(/<div class="transactionRow [^>]*?>/gi, "\n"
).replace(/<div class="transactionRowDate">/gi, ""
).replace(/<div class="transactionRowPrice">/gi, "\t"
).replace(/<div class="transactionRowEvent">|<div class="transactionRowItems">/gi, "\t"
).replace(/<span class="itemSubtext">([^>]*?)<\/span><\/div>(.*)/gi, "\t$2\t$1"
).replace(/<[^>]*?>| /gi, ""
);
}
private function licenses(text:String):String
{
return text
.replace(/.*Licenses and subscriptions(.*?)Recent Steam Store Transactions.*/si, "$1"
).replace(/^\s+|\s+$/mg, ""
).replace(/[\n\r\t]/g, ""
).replace(/<div class="licenseRow [^>]*?>/gi, "\n"
).replace(/<div class="licenseRowRight">(.*?)<\/div>(.*?)<\/div>/gi, function():String
{
var title:String = arguments[2].replace(/<[^>]*?>/gi, "");
trace(title);
return [arguments[1], title, '=HYPERLINK("' + SEARCH_URL_BASE + escape(title) + '","[LINK]")'].join("\t");
}
).replace(/<[^>]*?>| /gi, ""
);
}
private function num2char(text:String):String
{
return text
.replace(/&#(\d+?);/g, function ():String
{
return String.fromCharCode(arguments[1]);
}
);
}
}
}