SteamTransaction2TSV miyaoka forked:0favorite:1lines:91license : MIT License modified : 2010-01-07 07:55:22 share Tweet 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="transactionRowPrice">/gi, "" ).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]); } ); } } } Code Fullscreen Preview Fullscreen nki2 replace System.setClipboard escape String TextFieldType.INPUT type String.fromCharCode join height multiline text width trace addChild length Array Sprite int