Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HTML XMLNS:HTA><HEAD><TITLE>proxy2ch helper - 初期化</TITLE>
- <META id=utf8n content="text/html; charset=UTF-8" http-equiv=Content-Type><HTA:APPLICATION applicationName="proxy2ch helper" innerBorder="no" navigable="yes" selection="no" singleInstance="yes" version="6"></HTA:APPLICATION>
- <SCRIPT type=text/javascript>
- var SWbemLocator = new ActiveXObject("WbemScripting.SWbemLocator");
- (function () {
- var wbemImpersonationLevelImpersonate = 3;
- SWbemLocator.security_.impersonationLevel = wbemImpersonationLevelImpersonate;
- })();
- var SWbemServices = SWbemLocator.connectServer(".", "root/cimv2");
- var $ = document.getElementById;
- function start() {
- if (!/\\proxy2ch\.exe$/i.test($("executablePath").value)) {
- alert("proxy2ch.exe の場所 (フルパス) を指定してください。");
- selectExecutablePath();
- }
- if (!/\\proxy2ch\.exe$/i.test($("executablePath").value)) { return }
- stop();
- var commandLine = [ $("executablePath").value ];
- if ($("port").value) {
- commandLine.push("-p");
- commandLine.push($("port").value);
- }
- if ($("timeout").value) {
- commandLine.push("-t");
- commandLine.push($("timeout").value);
- }
- if ($("agent").value) {
- commandLine.push("-a");
- commandLine.push($("agent").value);
- }
- if ($("global").checked) { commandLine.push("-g") }
- if ($("proxyServer").value && $("proxyPort").value) {
- commandLine.push("--proxy");
- commandLine.push($("proxyServer").value + ":" + $("proxyPort").value);
- }
- if ($("appKey").value && $("hmacKey").value) {
- commandLine.push("--api");
- commandLine.push($("appKey").value + ":" + $("hmacKey").value);
- }
- if ($("apiAuthUa").value) {
- commandLine.push("--api-auth-ua");
- commandLine.push($("apiAuthUa").value);
- }
- if ($("apiDatUa").value) {
- commandLine.push("--api-dat-ua");
- commandLine.push($("apiDatUa").value);
- }
- if ($("apiAuthXua").value) {
- commandLine.push("--api-auth-xua");
- commandLine.push($("apiAuthXua").value);
- }
- if ($("apiDatXua").value) {
- commandLine.push("--api-dat-xua");
- commandLine.push($("apiDatXua").value);
- }
- if ($("chunked").checked) { commandLine.push("--chunked") }
- if ($("verbose").checked) { commandLine.push("--verbose") }
- if (/\.(?:log|txt)$/i.test($("logRedirect").value)) {
- commandLine = ["cmd.exe", "/C", "@"].concat(commandLine); // "@" は cmd.exe のお節介対策
- if ($("logOverWrite").checked) { commandLine.push("1>") }
- if ($("logAppend").checked) { commandLine.push("1>>") }
- commandLine.push($("logRedirect").value);
- commandLine.push("2>&1");
- }
- for (var i = 0, l = commandLine.length; i < l; i++) {
- if (/[\s"]/.test(commandLine[i])) { commandLine[i] = '"' + commandLine[i].replace(/"/g, '\\"') + '"' }
- }
- var startup = SWbemServices.get("Win32_ProcessStartup").spawnInstance_();
- var SW_HIDE = 0;
- var SW_NORMAL = 1;
- var SW_SHOWMINNOACTIVE = 7;
- if ($("hide").checked) { startup.showWindow = SW_HIDE }
- if ($("normal").checked) { startup.showWindow = SW_NORMAL }
- if ($("showminnoactive").checked) { startup.showWindow = SW_SHOWMINNOACTIVE }
- var Win32_Process = SWbemServices.get("Win32_Process");
- var method = Win32_Process.methods_("create");
- var inParameters = method.inParameters.spawnInstance_();
- inParameters.commandLine = commandLine.join(" ");
- inParameters.currentDirectory = /^file:\/\/(.+\\)/i.exec(document.URL)[1];
- inParameters.processStartupInformation = startup;
- var outParameters = Win32_Process.execMethod_(method.name, inParameters);
- switch (outParameters.returnValue) {
- case 0: // 正常終了
- $("processId").defaultValue = $("processId").value = outParameters.processId;
- $("stopButton").disabled = false;
- document.title = "proxy2ch helper - " + inParameters.commandLine;
- if ($("autoClose").checked) { window.close() }
- break;
- case 2:
- alert("アクセスが拒否されました。");
- break;
- case 3:
- alert("権限がありません。");
- break;
- case 9:
- alert("ファイルが見つかりません。");
- break;
- case 21:
- alert("パラメーターが不正です。");
- break;
- case 8:
- default:
- alert("エラーが発生しました。");
- }
- }
- function stop() {
- var process = getProcess();
- if (process) { process.terminate() }
- $("processId").defaultValue = $("processId").value = "";
- $("stopButton").disabled = true;
- document.title = "proxy2ch helper - 停止中";
- }
- function save() {
- var stream = new ActiveXObject("ADODB\x2eStream"); // アンチウィルス対策で "." を "\x2e"
- stream.open();
- stream.charset = document.charset;
- for (var c = document.firstChild; c; c = c.nextSibling) { stream.writeText(c.outerHTML) }
- stream.flush();
- var adSaveCreateOverWrite = 2;
- stream.saveToFile(/^file:\/\/(.+)/i.exec(document.URL)[1], adSaveCreateOverWrite);
- stream.close();
- }
- function getProcess() {
- if ($("processId").value) {
- var query = "SELECT * FROM Win32_Process WHERE Name = 'proxy2ch.exe' AND ( ProcessId = " + $("processId").value + " OR ParentProcessId = " + $("processId").value + " )";
- var wbemFlagForwardOnly = 32;
- var wbemFlagReturnImmediately = 16;
- var flags = wbemFlagForwardOnly | wbemFlagReturnImmediately;
- var enumerator = new Enumerator(SWbemServices.execQuery(query, null, flags));
- if (!enumerator.atEnd()) { return enumerator.item() }
- }
- return null;
- }
- function getUserAgent() {
- var ie = new ActiveXObject("InternetExplorer.Application");
- ie.navigate("about:blank");
- var identifier = setInterval(function() {
- if (!ie.busy) {
- clearInterval(identifier);
- var userAgent = ie.document.parentWindow.navigator.userAgent;
- ie.quit();
- ie = null;
- CollectGarbage();
- /* navigator.userAgent は冗長なので削る */
- var match = /(.+?\()(.+)(\).*)/.exec(userAgent);
- if (match) {
- var tokens = match[2].split(/; /g);
- for (var i = 0; i < tokens.length; i++) {
- if (!/^(?:compatible$|MSIE |Windows |W(?:in|OW)64|Trident\/|Touch$|rv:)/.test(tokens[i])) { delete tokens[i] }
- }
- userAgent = match[1] + tokens.join("; ").replace(/(?:; ){2,}/g, "; ") + match[3];
- }
- $("agent").value = userAgent;
- }
- },
- 100);
- }
- function selectExecutablePath() {
- var defaultValue = $("executablePath").defaultValue;
- var value = $("executablePath").value;
- $("executablePathDialog").outerHTML = $("executablePathDialog").outerHTML.replace(/type=button/, "type=hidden");
- $("executablePath").outerHTML = $("executablePath").outerHTML.replace(/INPUT/, "INPUT type=file");
- $("executablePath").click();
- $("executablePath").outerHTML = $("executablePath").outerHTML.replace(/ type=file/, "");
- $("executablePathDialog").outerHTML = $("executablePathDialog").outerHTML.replace(/type=hidden/, "type=button");
- $("executablePath").defaultValue = defaultValue;
- if (!$("executablePath").value) { $("executablePath").value = value }
- }
- function selectLogRedirect() {
- alert("ログ ファイルを選択する前に、対象ファイルを作成してください。存在しないファイル名を指定するとエラーになります。\n既存ファイルを選択する場合は、改変されても問題ないファイルであることを確認してください。");
- var defaultValue = $("logRedirect").defaultValue;
- var value = $("logRedirect").value;
- $("logRedirectDialog").outerHTML = $("logRedirectDialog").outerHTML.replace(/type=button/, "type=hidden");
- $("logRedirect").outerHTML = $("logRedirect").outerHTML.replace(/INPUT/, "INPUT type=file");
- $("logRedirect").click();
- $("logRedirect").outerHTML = $("logRedirect").outerHTML.replace(/ type=file/, "");
- $("logRedirectDialog").outerHTML = $("logRedirectDialog").outerHTML.replace(/type=hidden/, "type=button");
- $("logRedirect").defaultValue = defaultValue;
- if (!$("logRedirect").value) { $("logRedirect").value = value }
- }
- window.onload = function () {
- if (getProcess()) { return }
- $("processId").defaultValue = $("processId").value = "";
- $("stopButton").disabled = true;
- document.title = "proxy2ch helper - 停止中";
- if ($("autoStart").checked) { start() }
- }
- window.onunload = function () {
- SWbemServices = null;
- SWbemLocator = null;
- CollectGarbage();
- save();
- }
- </SCRIPT>
- <SCRIPT id=runOnce type=text/javascript>
- alert("起動時に「発行元を確認できませんでした。このソフトウェアを実行しますか?」という警告がでる場合は、「このファイル開く前に常に警告する(W)」のチェックをはずして実行してみてください。");
- $("utf8n").outerHTML = "";
- $("runOnce").outerHTML = "";
- </SCRIPT>
- </HEAD>
- <BODY bgColor=threedface>
- <FORM action=javascript:void(start())>
- <FIELDSET title="-p <port>"><LEGEND><LABEL for=port>ポート番号</LABEL></LEGEND><INPUT id=port> (デフォルト: 9080)</FIELDSET>
- <FIELDSET title="-t <timeout>"><LEGEND><LABEL for=timeout>タイムアウト秒数</LABEL></LEGEND><INPUT id=timeout> (デフォルト: 30)</FIELDSET>
- <FIELDSET title="-a <user-agent>"><LEGEND><LABEL for=agent>User-Agent</LABEL></LEGEND><INPUT id=agent size=100><INPUT onclick=javascript:void(getUserAgent()) type=button value=MSIE></FIELDSET>
- <FIELDSET title=-g><LEGEND><LABEL for=global>この PC 以外からも接続可</LABEL></LEGEND><INPUT id=global type=checkbox></FIELDSET>
- <FIELDSET title="--proxy <server:port>"><LEGEND><LABEL for=proxyServer>プロキシー経由 (サーバー : ポート番号)</LABEL></LEGEND><INPUT id=proxyServer size=50> : <INPUT id=proxyPort></FIELDSET>
- <FIELDSET title="--api <AppKey:HmacKey>"><LEGEND><LABEL for=appKey>API キー (AppKey : HmacKey)</LABEL></LEGEND><INPUT id=appKey size=50> : <INPUT id=hmacKey size=50></FIELDSET>
- <FIELDSET title="--api-auth-ua <user-agent>"><LEGEND><LABEL for=apiAuthUa>API 認証時の User-Agent</LABEL></LEGEND><INPUT id=apiAuthUa size=100></FIELDSET>
- <FIELDSET title="--api-dat-ua <user-agent>"><LEGEND><LABEL for=apiDatUa>API で DAT 取得時の User-Agent</LABEL></LEGEND><INPUT id=apiDatUa size=100></FIELDSET>
- <FIELDSET title="--api-auth-xua <X-2ch-UA>"><LEGEND><LABEL for=apiAuthXua>API 認証時の X-2ch-UA</LABEL></LEGEND><INPUT id=apiAuthXua size=100></FIELDSET>
- <FIELDSET title="--api-dat-xua <X-2ch-UA>"><LEGEND><LABEL for=apiDatXua>API で DAT 取得時の X-2ch-UA</LABEL></LEGEND><INPUT id=apiDatXua size=100></FIELDSET>
- <FIELDSET title=--chunked><LEGEND><LABEL for=chunked>Transfer-Encoding: chunked 維持</LABEL></LEGEND><INPUT id=chunked type=checkbox></FIELDSET>
- <FIELDSET title=--verbose><LEGEND><LABEL for=verbose>詳細ログ表示</LABEL></LEGEND><INPUT id=verbose type=checkbox></FIELDSET>
- <P><LABEL for=executablePath>proxy2ch.exe の場所 (フルパス)</LABEL>:<BR><INPUT id=executablePath size=100><INPUT onclick=javascript:void(selectExecutablePath()) id=executablePathDialog type=button value=" 参照... "><INPUT id=processId type=hidden></P>
- <P><LABEL for=logRedirect>ログ表示をリダイレクトしてファイルに保存 (フルパス)</LABEL>:<BR><INPUT id=logRedirect size=100><INPUT onclick=javascript:void(selectLogRedirect()) id=logRedirectDialog type=button value=" 参照... "><INPUT id=logOverWrite CHECKED type=radio name=redirectType><LABEL for=logOverWrite>上書き</LABEL><INPUT id=logAppend type=radio name=redirectType><LABEL for=logAppend>追記</LABEL><BR> <SMALL>※ 安全のため、<STRONG>".log" と ".txt" 以外の拡張子がついたファイルを指定しても無効</STRONG>になります。</SMALL></P>
- <P><INPUT id=autoStart type=checkbox><LABEL for=autoStart>helper を開いた時に proxy2ch が停止中なら自動的に開始</LABEL><BR><INPUT id=autoClose type=checkbox><LABEL for=autoClose>proxy2ch を開始したら自動的に helper を閉じる</LABEL></P>
- <P><INPUT id=normal CHECKED type=radio name=showWindow><LABEL for=normal>通常表示で実行</LABEL> <INPUT id=showminnoactive type=radio name=showWindow><LABEL for=showminnoactive>最小化で実行</LABEL> <INPUT id=hide type=radio name=showWindow><LABEL for=hide>非表示で実行</LABEL></P>
- <P><INPUT type=submit value=開始> <INPUT onclick=javascript:void(stop()) disabled id=stopButton type=button value=停止> <INPUT type=reset value=変更を破棄></P></FORM></BODY></HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement