Advertisement
Guest User

proxy2ch helper v2 (HTA)

a guest
Mar 29th, 2015
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 7.33 KB | None | 0 0
  1. <HTML XMLNS:HTA><HEAD><TITLE>proxy2ch helper</TITLE>
  2. <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>
  3. <SCRIPT type=text/javascript>
  4. var SWbemLocator = new ActiveXObject("WbemScripting.SWbemLocator");
  5. (function () {
  6.     var wbemImpersonationLevelImpersonate = 3;
  7.     SWbemLocator.security_.impersonationLevel = wbemImpersonationLevelImpersonate;
  8. })();
  9. var SWbemServices = SWbemLocator.connectServer(".", "root/cimv2");
  10. var $ = document.getElementById;
  11. function start() {
  12.     stop();
  13.     var commandLine = [ $("executablePath").value ];
  14.     if ($("port").value) {
  15.         commandLine.push("-p");
  16.         commandLine.push($("port").value);
  17.     }
  18.     if ($("timeout").value) {
  19.         commandLine.push("-t");
  20.         commandLine.push($("timeout").value);
  21.     }
  22.     if ($("agent").value) {
  23.         commandLine.push("-a");
  24.         commandLine.push($("agent").value);
  25.     }
  26.     if ($("global").checked) { commandLine.push("-g") }
  27.     if ($("proxyServer").value && $("proxyPort").value) {
  28.         commandLine.push("--proxy");
  29.         commandLine.push($("proxyServer").value + ":" + $("proxyPort").value);
  30.     }
  31.     if ($("appKey").value && $("hmacKey").value) {
  32.         commandLine.push("--api");
  33.         commandLine.push($("appKey").value + ":" + $("hmacKey").value);
  34.     }
  35.     if ($("apiAuthUa").value) {
  36.         commandLine.push("--api-auth-ua");
  37.         commandLine.push($("apiAuthUa").value);
  38.     }
  39.     if ($("apiDatUa").value) {
  40.         commandLine.push("--api-dat-ua");
  41.         commandLine.push($("apiDatUa").value);
  42.     }
  43.     if ($("apiAuthXua").value) {
  44.         commandLine.push("--api-auth-xua");
  45.         commandLine.push($("apiAuthXua").value);
  46.     }
  47.     if ($("apiDatXua").value) {
  48.         commandLine.push("--api-dat-xua");
  49.         commandLine.push($("apiDatXua").value);
  50.     }
  51.     if ($("chunked").checked) { commandLine.push("--chunked") }
  52.     if ($("verbose").checked) { commandLine.push("--verbose") }
  53.     for (var i = 0, l = commandLine.length; i < l; i++) {
  54.         if (/[\s"]/.test(commandLine[i])) { commandLine[i] = '"' + commandLine[i].replace(/"/g, '\\"') + '"' }
  55.     }
  56.     var startup = SWbemServices.get("Win32_ProcessStartup").spawnInstance_();
  57.     var SW_HIDE = 0;
  58.     var SW_SHOWMINNOACTIVE = 7;
  59.     if ($("hide").checked) { startup.showWindow = SW_HIDE }
  60.     if ($("showminnoactive").checked) { startup.showWindow = SW_SHOWMINNOACTIVE }
  61.     var Win32_Process = SWbemServices.get("Win32_Process");
  62.     var method = Win32_Process.methods_("create");
  63.     var inParameters = method.inParameters.spawnInstance_();
  64.     inParameters.commandLine = commandLine.join(" ");
  65.     inParameters.currentDirectory = /^file:\/\/(.+\\)/i.exec(document.URL)[1];
  66.     inParameters.processStartupInformation = startup;
  67.     var outParameters = Win32_Process.execMethod_(method.name, inParameters);
  68.     switch (outParameters.returnValue) {
  69.         case 0: // 正常終了
  70.             $("processId").value = outParameters.processId;
  71.             if ($("autoClose").checked) { window.close() }
  72.             break;
  73.         case 2:
  74.             alert("アクセスが拒否されました。");
  75.             break;
  76.         case 3:
  77.             alert("権限がありません。");
  78.             break;
  79.         case 9:
  80.             alert("ファイルが見つかりません。");
  81.             break;
  82.         case 21:
  83.             alert("パラメーターが不正です。");
  84.             break;
  85.         case 8:
  86.         default:
  87.             alert("エラーが発生しました。");
  88.     }
  89. }
  90. function stop() {
  91.     var process = getProcess();
  92.     if (process) { process.terminate() }
  93.     $("processId").value = "";
  94. }
  95. function save() {
  96.     var stream = new ActiveXObject("ADODB\x2eStream"); // アンチウィルス対策で "." を "\x2e"
  97.     stream.open();
  98.     stream.charset = document.charset;
  99.     for (var c = document.firstChild; c; c = c.nextSibling) { stream.writeText(c.outerHTML) }
  100.     stream.flush();
  101.     var adSaveCreateOverWrite = 2;
  102.     stream.saveToFile(/^file:\/\/(.+)/i.exec(document.URL)[1], adSaveCreateOverWrite);
  103.     stream.close();
  104. }
  105. function getProcess() {
  106.     if ($("processId").value) {
  107.         var query = "SELECT * FROM Win32_Process WHERE Name = 'proxy2ch.exe' AND ProcessId = " + $("processId").value;
  108.         var wbemFlagForwardOnly = 32;
  109.         var wbemFlagReturnImmediately = 16;
  110.         var flags = wbemFlagForwardOnly | wbemFlagReturnImmediately;
  111.         var enumerator = new Enumerator(SWbemServices.execQuery(query, null, flags));
  112.         if (!enumerator.atEnd()) { return enumerator.item() }
  113.     }
  114.     return null;
  115. }
  116. window.onload = function () {
  117.     if (!$("executablePath").value) {
  118.         $("executablePath").value = /^file:\/\/(.+\\)/i.exec(document.URL)[1] + "proxy2ch.exe";
  119.         $("executablePath").defaultValue = $("executablePath").value;
  120.     }
  121.     if (!getProcess()) {
  122.         $("processId").value = "";
  123.         if ($("autoStart").checked) { start() }
  124.     }
  125. }
  126. window.onunload = function () {
  127.     save();
  128.     SWbemServices = null;
  129.     SWbemLocator = null;
  130.     CollectGarbage();
  131. }
  132. </SCRIPT>
  133. </HEAD>
  134. <BODY bgColor=threedface>
  135. <FORM action=javascript:void(start())>
  136. <FIELDSET title="-p <port>"><LEGEND><LABEL for=port>ポート番号</LABEL></LEGEND><INPUT id=port> (デフォルト: 9080)</FIELDSET>
  137. <FIELDSET title="-t <timeout>"><LEGEND><LABEL for=timeout>タイムアウト秒数</LABEL></LEGEND><INPUT id=timeout> (デフォルト: 30)</FIELDSET>
  138. <FIELDSET title="-a <user-agent>"><LEGEND><LABEL for=agent>User-Agent</LABEL></LEGEND><INPUT id=agent size=100></FIELDSET>
  139. <FIELDSET title=-g><LEGEND><LABEL for=global>この PC 以外からも接続可</LABEL></LEGEND><INPUT id=global type=checkbox></FIELDSET>
  140. <FIELDSET title="--proxy <server:port>"><LEGEND><LABEL for=proxyServer>プロキシー経由 (サーバー : ポート番号)</LABEL></LEGEND><INPUT id=proxyServer size=50> : <INPUT id=proxyPort></FIELDSET>
  141. <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>
  142. <FIELDSET title="--api-auth-ua <user-agent>"><LEGEND><LABEL for=apiAuthUa>API 認証時の User-Agent</LABEL></LEGEND><INPUT id=apiAuthUa size=100></FIELDSET>
  143. <FIELDSET title="--api-dat-ua <user-agent>"><LEGEND><LABEL for=apiDatUa>API で DAT 取得時の User-Agent</LABEL></LEGEND><INPUT id=apiDatUa size=100></FIELDSET>
  144. <FIELDSET title="--api-auth-xua <X-2ch-UA>"><LEGEND><LABEL for=apiAuthXua>API 認証時の X-2ch-UA</LABEL></LEGEND><INPUT id=apiAuthXua size=100></FIELDSET>
  145. <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>
  146. <FIELDSET title=--chunked><LEGEND><LABEL for=chunked>Transfer-Encoding: chunked を維持</LABEL></LEGEND><INPUT id=chunked type=checkbox></FIELDSET>
  147. <FIELDSET title=--verbose><LEGEND><LABEL for=verbose>詳細ログ</LABEL></LEGEND><INPUT id=verbose type=checkbox></FIELDSET>
  148. <P><LABEL for=executablePath>proxy2ch.exe のフルパス:</LABEL><BR><INPUT id=executablePath size=100><INPUT id=processId type=hidden></P>
  149. <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>
  150. <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>
  151. <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