Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HTML XMLNS:HTA><HEAD><TITLE>proxy2ch helper</TITLE>
- <META content="text/html; charset=UTF-8" http-equiv=Content-Type><HTA:APPLICATION applicationName="proxy2ch helper" innerBorder="no" navigable="yes" selection="no" version="2"></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() {
- 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") }
- 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_SHOWMINNOACTIVE = 7;
- if ($("hide").checked) { startup.showWindow = SW_HIDE }
- 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").value = outParameters.processId;
- 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").value = "";
- }
- 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;
- 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;
- }
- window.onload = function () {
- if (!$("executablePath").value) {
- $("executablePath").value = /^file:\/\/(.+\\)/i.exec(document.URL)[1] + "proxy2ch.exe";
- $("executablePath").defaultValue = $("executablePath").value;
- }
- if (!getProcess()) {
- $("processId").value = "";
- if ($("autoStart").checked) { start() }
- }
- }
- window.onunload = function () {
- save();
- SWbemServices = null;
- SWbemLocator = null;
- CollectGarbage();
- }
- </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></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 id=processId type=hidden></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=showminnoactive CHECKED 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()) type=button value=停止> <INPUT type=reset value=変更を破棄></P></FORM></BODY></HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement