Pastebin PRO Accounts CHRISTMAS SPECIAL! For a limited time only. Get 40% discount on a LIFETIME PRO account!
- /********************************************************************/
- /* gethtmldat.js : ver.0.45 2015/12/11 */
- /********************************************************************/
- //
- // Jane2ch.exeでhtmlから過去ログを取得しdat形式に変換してLogsフォルダに格納する
- // htmltodat-convert2.wsf+htmltodat.exeと同じような機能を果たす
- // htmltodat-convert2.wsfとGetLog.wsfからコードを盗用してます(許して)
- //
- //==============================================================
- // ※ 重要 ※
- // なお、このスクリプトはpastbinのサイトから DOWNLOAD するのではなく、RAW( http://pastebin.com/raw.php?i=3EZzrsxY )
- // で表示したものか 又は 下の方にある RAW Paste Data から、コピー&ペースト(CTRL+A,CTRL+C 及び CTRL+V)で、
- // テキストエディタに貼り付け、gethtmldat.js という名前でShift-JISコード(メモ帳ではANSI)で保存し、
- // Jane2ch.exe のあるフォルダに格納してください
- // ※注意※ DOWNLOADすると、文字コードがUTF-8となり実行できません
- // また、行番号付きでコピー&ペーストしても実行できません
- //==============================================================
- //
- // Jane Styleでのコマンド登録方法は、メニュー - ツール - 設定 - 機能 - コマンド で
- // コマンド名 - 過去ログ取得(gethtmldat) ※ここには任意の名称をつけられます
- // コマンド内容 - wscript "$BASEPATHgethtmldat.js" $LINK$URL
- // を入力して、追加、OKします
- // ※ なお、Jane直下フォルダでは無い場合はパスをフルパスで指定してください
- // jane styleの下のscriptフォルダに入れた場合は、wscript "$BASEPATHscript\gethtmldat.js" $LINK$URL
- //
- // コマンド登録時のパラメタに /w 又は /w:999(待ち時間) を追加するとキー送信(CTL+W)により、スレを閉じて再度開く動作をします
- // wscript "$BASEPATHgethtmldat.js" $LINK$URL /w
- // ※注意※ 当該スレが開く前にキー送信がなされると現在開いている別スレが閉じてしまいます
- //
- // 起動オプション: 順不同
- // [+]http://~ url指定 (先頭に+を付けるとdatにURL末尾の指定範囲のレス部分だけ上書きする /aは無効となる)
- // [/n:]999 レス番指定(そのレス番に飛ぶ)
- // /f urlを強制的に問い合わせる
- // /w[:999] スレを指定時間待って閉じ、開き直す(数値省略時 1200ms)
- // /a[ppend] 差分のみ取得(管理人削除などで既存のログとサーバー上のデータに違いがあっても関知しない)
- // /b[ak][1] バックアップを取る(Logs\bak\の下に既存のdatファイルをコピーする) /b1 は1回限りで上書きしない
- // /redraw[:999] 再描画 スレを開いた後、指定時間待ってからキーコード('ALT','T','G','0')を送る (数値省略時 1200ms)
- // /z Jane2ch.exeを終了し、情報(db,idx)設定後、再起動する(この場合 /w は不要)
- // ※ 高速Merge有効時には、SQLite3 ODBC Driver 又は sqlite3.exe のどちらかが必要
- // SQLite3 ODBC Driver : http://www.ch-werner.de/sqliteodbc/sqliteodbc.exe をインストール
- // (インストールは上記exeを実行し、Next,I Agree,Next,Install,Finishボタンで進める)
- // sqlite3.exe : http://www.sqlite.org/download.html から、sqlite-shell-win32-x86-3080900.zip
- // をダウンロード・解凍し、本スクリプトと同じフォルダに格納する
- // "/log[:file]" トレースログを指定のファイルに追加書き込みします(ファイルパス名省略時は %temp%\gethtmldat.log)
- // /keep_kako 渡された過去ログURLをそのまま処理する(したらば、next2ch、machi以外で有効)
- //
- // 使い方:
- // 以下のa)~c)のいずれかで右クリックして上記登録したコマンドを選択する
- // a) Jane Styleで、過去ログを開いたレス表示欄
- // b) 別スレに書かれているリンク
- // c) 書き込みウィンドウ、メモ欄にURLを書き込みプレビューで現れるリンク
- //
- // TIPS :
- // ●★「過去ログ」と表示されている場合は、メニュー(スレッド)から「強制過去ログ化」のチェックを外すか
- // 又は、一旦ログを削除後にリンクから再取得してください
- // ●レスが表示されない場合は、スレッドツールバーの「表示レス数/スレの再描画」アイコンを右クリックしてください
- // ●未読状態が既読状態にならない場合やレス番リンクのポップアップが表示されなかったりID抽出回数が0回になる場合は
- // 1)ステータスが過去ログ以外の時、所属する板を開いてスレ一覧更新をして、スレを閉じ、
- // リンク(又はスレ一覧から)クリックで開き直し、最新レス末尾までスクロールする
- // 2)過去ログの場合、上記「強制過去ログ化」のチェックを外した後、>>999 などの未読状態のレスを指すリンクをクリックする
- // 又は、名前欄1001をクリックする、又はアドレスバーに「スレURL/999」のようなレス番付きで入力する
- // ●2ch.netでftp://問題により520エラー又はデータが途切れてしまう場合の部分的な救済方法
- // webブラウザで問題となるレス番をtrial and errorで目星をつけて、それを避けるように範囲指定してデータを取得する
- // 例えば、レス番50が引っ掛かっている場合は、-49 と 51- の2回に分けて取得する
- // コマンド登録時には、+$LINK$URLとし、URL末尾に範囲指定付きのリンクから使うか
- // /f も追加して、実行時にURL末尾にレス番範囲を追加で入力する
- //
- // 修正履歴:
- // http://pastebin.com/my14uCkr を参照
- //==============================================================
- /*@cc_on
- @set @DEBUG = false;
- @set @EnabledTest2chJSON = false; // =true で2chで最初にJSONでの取得を試みる(お遊び機能:仕様等一切不明、過去ログは無理)
- //漢字コード変換にbasp21.dllを試みる http://www.hi-ho.ne.jp/babaq/basp21.htmlのBASP21-2003-0211.exeのインストールが必要
- @set @EnabledBASP21 = true;
- @*/
- var HTTP_HEADERS = {
- // "If-Modified-Since" : "Thu, 01 Jun 1970 00:00:00 GMT"
- // ,"Content-Type" : "application/x-www-form-urlencoded"
- // ,"User-Agent" : "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;)"
- };
- var HTTP_TIMEOUT = 30 * 1000;
- var IDX_STATE = { "2ch":3 , "jbbs":3 }; //=0:現役 =3:dat落ち =10:過去ログ
- var ABN_MSG = "あぼーん<>あぼーん<>あぼーん<>あぼーん<>";
- var NOT_GET_MSG = "未取得<>未取得<>未取得<>未取得<>";
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var shell = new ActiveXObject("WScript.Shell");
- var sha = new ActiveXObject("Shell.Application");
- var strm = new ActiveXObject("ADODB.Stream");
- var http; try { http = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0"); } catch(e){}
- if (!http) try { http = new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch(e){}
- if (!http) { http = new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
- var basp; /*@if (@EnabledBASP21) try { basp = new ActiveXObject("basp21"); } catch(e){} @end @*/
- var JANE_PATH = shell.CurrentDirectory.replace(/[^\\]$/,"$&\\");
- var SCRIPT_PATH = fso.GetParentFolderName( WScript.ScriptFullName ).replace(/[^\\]$/,"$&\\");
- shell.CurrentDirectory = JANE_PATH;
- var JANE_EXE = "Jane2ch.exe";
- var JANE_INI = "Jane2ch.ini";
- var JANE_BRD = "Jane2ch.brd";
- var JANE_LOGS = "Logs\\2ch\\";
- var JANE_BAK = "Logs\\bak\\";
- var JANE_BRDCUSTOMIZE_INI = "brdcustomize.ini";
- var MY_NAME = WScript.ScriptName.split(/\.(?=[^.]+$)/)[0];
- var TRACE_LOG = replaceEnv("%temp%\\"+MY_NAME+".log").replace(/\\\\/g,"\\");
- //==============================================================
- function o(s) { /*@if (@DEBUG) WScript.Echo(s); @end @*/ }
- function q() {WScript.Quit();}
- String.prototype.expand = function(v) { return this.replace(/\$(\d)/g, function(m, n) { return v[n]; }); }
- String.prototype.convDontUseStr = function() {
- var tbl0 = { "CON":"$CON", "AUX":"$AUX", "NUL":"$NUL" /*, "PRN":"$PRN", "COM([0-2])":"$COM$1", "LPT([0-2])":"$LPT$1" */ }
- var tbl1 = { "\\":"$Backslash", "/":"$Slash", ":":"$Colon", "*":"$Asterisk", "?":"$Question" }
- var s = this;
- for(var i in tbl0) { s=s.replace( new RegExp("^"+i+"$","i") , tbl0[i]); }
- return s.replace(/[\\/:*?]/g, function (w){return tbl1[w];});
- }
- var trace = function(){};
- function Err(s,t) { s=ErrMsg(s,t); trace("---- "+s+" ----",2); throw new Error(s); }
- function ErrMsg(s,t) { return (ERROR_MSG[s]?ERROR_MSG[s]:"Unknown error") + (t?t:"");}
- var ERROR_MSG = {
- "E_already_there" : "このスレは既に取得しています"
- ,"E_illegal_url" : "このURLでは処理できません"
- ,"E_remained_garbage" : "レスデータのみの抽出に失敗しました"
- ,"E_block_not_found" : "htmlからスレブロックが見つかりません"
- ,"E_title_not_found" : "スレタイトルが見つかりません"
- ,"E_require_sqlite" : "sqlite3.exe 又は SQLite3 ODBC Driver が必要です"
- ,"E_require_sqlODBC" : "SQLite3 ODBC Driver が必要です"
- ,"E_stop" : "処理を中止しました"
- ,"E_no_data" : "取得データはありません"
- ,"E_http_timeout" : "受信タイムアウト"
- ,"E_http_recieve" : "http受信エラー"
- ,"E_bbs_not_found" : "掲示板番号が不正です"
- ,"E_key_not_found" :"スレッド番号が不正です"
- ,"E_thread_not_found" : "スレッドがありません"
- ,"E_brditem_not_found" : "dat格納場所が見つかりません"
- ,"E_loadfile" : "ファイル読み込みエラー"
- ,"E_savefile" : "ファイル書き込みエラー"
- }
- function object(o) {
- var f = object.f, i, len, n, prop;
- f.prototype = o;
- n = new f;
- for (i=1, len=arguments.length; i<len; ++i) for (prop in arguments[i]) n[prop] = arguments[i][prop];
- return n;
- }
- object.f = function(){};
- //--- http://with-love-from-siberia.blogspot.jp/2009/12/msgbox-inputbox-in-jscript.html -----------
- var vb = {};
- vb.Function = function(func) { return function() { return vb.Function.eval.call(this, func, arguments); }; };
- vb.Function.eval = function(func) {
- var args = Array.prototype.slice.call(arguments[1]);
- for (var i = 0; i < args.length; i++) {
- if ( typeof args[i] != 'string' ) { continue; }
- args[i] = '"' + args[i].replace(/"/g, '" + Chr(34) + "') + '"';
- }
- var vbe;
- vbe = new ActiveXObject('ScriptControl');
- vbe.Language = 'VBScript';
- return vbe.eval(func + '(' + args.join(', ') + ')');
- };
- var InputBox = vb.Function('InputBox');
- var MsgBox = vb.Function('MsgBox');
- //==============================================================
- var args = parmParse(WScript.Arguments);
- var URL_2ch = {
- RE_HOST : new RegExp("^http://\\w+\\.(?:2ch\\.net|bbspink\\.com)/") //この定義はdat取得できないサイトの判別に使う
- ,RE_URL : new RegExp("^http://((\\w+(?=\\.\\w+\\.))?(\\.?(\\w+).+?))/(?:(?:test|bbs)/.+?/)?(\\w+)/(?:kako/.+?/)?(((\\d+)\\d)\\d{5})(/|\\.html|\\.dat(?:\\.gz)?)?")
- ,range : ""
- ,set_prm : function(url) { this._set_prm(url, 1, null, 5, 6); this.kako = /\/kako\//.test(url) && delete args.append; }
- ,_set_prm: function(url,p1,p2,p3,p4) {
- this.prm = url.match(this.RE_URL) || Err("E_illegal_url");
- if(/\d$/.test(this.prm[0])) this.prm[0] += "/";
- this.url = this.prm[0];
- this.url2 = this.prm[0];
- if (this.prm[0].slice(-1)=="/") {
- var range = url.match(/\/n?((\d*)n?(-?)[^\/]*)$/)||[];
- this.url2 += (args.opt_n || range[2] ||"");
- if(range[3]) this.range = (range[1]||"").replace(/n/ig,"");
- else if(range[2]) this.range = range[2] + "-" + range[2];
- }
- this.site = this.prm[p1];
- this.category = (p2) ? this.prm[p2] : "";
- this.brdID = this.prm[p3];
- this.thrID = this.prm[p4];
- }
- ,appendRange : function(top) {
- if (args.overwrite) this.url += this.range;
- else this.url += ((args.append && top) ? top+"-n" : "");
- }
- ,getUrl2 : function() { return this.url2; }
- }
- var URL_jbbs = object(URL_2ch,{
- RE_HOST : new RegExp("^http://jbbs\\.(?:shitaraba|livedoor)\\.(?:net|jp|com)/")
- ,RE_URL : new RegExp("^http://(jbbs\\.shitaraba\\.net)/bbs/\\w+\\.cgi/(\\w+)/(\\d+)/(\\d+)/?")
- ,set_prm : function(url) { this._set_prm(url,1,2,3,4); }
- });
- var URL_machi = object(URL_2ch,{
- RE_HOST : new RegExp("^http://(?:\\w+\\.)?machi\\.to/")
- ,RE_URL : new RegExp("^http://((?:\\w+\\.)?machi\\.to)/bbs/\\w+\\.cgi/2/(\\w+)/(\\d+)/?")
- ,set_prm : function(url) { this._set_prm(url,1,null,2,3); }
- ,getUrl2 : function() { return this.url2.replace(/\/offlaw\.cgi\/2\//,"/read.cgi/"); }
- });
- var URL = URL_2ch;
- var Jane_2ch = {
- ini : loadFile2(JANE_INI)
- ,brd : ""
- ,LogBasePath : ""
- ,init : function() { this._setLogBasePath(); this._loadBRD(); }
- ,getINI : function(p) { var m=this._search(this.ini, this._re_ini, p); return m && RegExp.$1 || p[3]; }
- ,getBRD : function(p) {
- var m = this._search(this.brd, this._re_brd, p);
- return (m) ? RegExp.$1.convDontUseStr()+"\\"+RegExp.$2.convDontUseStr()+"\\" : null;
- }
- ,_re_ini : "^\\[$1\\]\\r\\n(?:.*\\r\\n)*?(?:$2=(.*)|\\[.*\\])\\r\\n"
- ,_re_brd : "^([ \\S]+).*\\r\\n(?:\\t.*\\r\\n)*\\t\\w*$3\\t$5\\t([^\\t\\r\\n]+)\\r\\n"
- ,_search : function(f,s,p) { return f.match(new RegExp(this._expand(s,p),"img")); }
- ,_expand : function(s,p) { return s.replace(/\$(\d)/g, function(m, n) { return (""+p[n]).replace(/\./g,"\\."); }); }
- ,_setLogBasePath : function() { this.LogBasePath = this.getINI([,"PATH","LogBasePath",""]).replace(/[^\\]$/,"$&\\");}
- ,_loadBRD : function() { this.brd = loadFile2(this.LogBasePath + JANE_BRD); }
- }
- var Jane_jbbs = object(Jane_2ch,{
- _re_brd : "^([ \\S]+).*\\r\\n(?:\\t.*\\r\\n)*?\\t$1/$2\\t$3\\t([^\\t\\r\\n]+)\\r\\n"
- });
- var Jane_machi = object(Jane_2ch,{
- _re_brd : "^([ \\S]+).*\\r\\n(?:\\t.*\\r\\n)*?\\t$1\\t$2\\t([^\\t\\r\\n]+)\\r\\n"
- });
- var Jane = Jane_2ch;
- Jane.init();
- if (args.trace !== void 0) { trace = new Trace(); }
- trace("--- start --- "+args.url,1);trace("",1)
- //----------------------
- var DatInfo = {
- cnt : 0
- ,title : ""
- ,msg : ""
- ,setInfo : function(dat,bak,brd) {
- this.dat = dat;
- this.bak = bak;
- this.brd = brd;
- if (fso.FileExists(dat)) {
- var msg = loadFile2(dat);
- this.cnt = msg.replace(/^.*$/mg,"").length;
- this.title = (msg.match(/<>((?:(?!<>).)*)$/m)||[])[1];
- if (args.overwrite) { this.msg = msg.slice(0,-1).split("\n"); }
- }
- }
- ,copyDat : function() {
- if (fso.FileExists(this.dat)) {
- path(this.bak);
- if (args.bak<0 || !fso.FileExists(this.bak) )
- try{ trace(); fso.CopyFile(this.dat, this.bak, true); trace("copy file:"+this.bak);} catch(e) {}
- }
- }
- ,setNewDatInfo : function(title, lines) {
- this.title = title;
- this.lines = parseInt(lines,10);
- }
- }
- //================================================================================
- var Thread = {
- re_sel : 0
- ,REG_PATTERN : [ {} ]
- ,msg : ""
- ,resNo : []
- ,requireFillAbn : false
- ,prepare : function() {}
- ,urlReplace : function(u) { return u; }
- ,preReplace : function() {}
- ,mainReplace : function() { this.msg = this.msg.replace(this.REG_PATTERN[this.re_sel].msg, this.REG_PATTERN[this.re_sel].rep); }
- ,postReplace : function() {}
- ,createBrdFolder : function() { return null;}
- ,matchTBlock :
- function(s) {
- var i,ss;
- for(i=0; i<this.REG_PATTERN.length; i++) {
- this.re_sel =i;
- if(ss=s.match(this.REG_PATTERN[i].thr)) break;
- }
- return ss;
- }
- ,getTBlock : function() { this.msg = (this.matchTBlock(this.msg)||[])[1]||""; }
- ,getTitle : function(s) { this.title = (s.match(/<title>(.*?)\n*<\/title>/i)||[])[1]; }
- ,readHTTP : function(url) {
- trace("try URL="+url,9);
- this.msg = readHTTP(url);
- this.preReplace();
- this.getTitle(this.msg);
- this.getTBlock();
- return true;
- }
- ,getFirst : function() { return (args.overwrite) ? parseInt(URL.range,10) : (args.append) ? DatInfo.cnt + 1 : 1; }
- ,getLast : function() { return parseInt((this.msg.match(/(\d+).*\n$/i)||[])[1],10); }
- ,delContents : function(s) { return s.replace(/^(?:(?:(?!<>).)*<>){4}.*$/mg, ""); }
- ,checkData : function(s) {
- var ln = this.checkData0(s);
- if(args.overwrite) return;
- if (this.last-this.first+1 != ln.length)
- if (MsgBox("抽出したレス数が合いませんが続行しますか?(先頭="+this.first
- +" 末尾="+this.last+" レス数="+ln.length+")",4+48,MY_NAME)!=6)
- Err("E_stop");
- }
- ,checkData0 : function(s) {
- var ln = this.delContents(s);
- if (ln.replace(/\n/g,"").length > 0) Err("E_remained_garbage");
- return ln;
- }
- ,addTitle : function() { this.msg = this.msg.replace(/^.*?$/m, "$&"+this.title); }
- ,delDupData : function() { //わざと重複して要求した先頭レス番データ削除
- if ((this.msg.match(/^(\d+)/i)||[])[1] == DatInfo.cnt) { this.msg = this.msg.replace(/^.*\n/m, ""); }
- }
- ,fillAbn : function() {
- // 透明あぼーんレスを挿入する
- var d = [], n = this.first;
- var s = this.msg.split("\n");
- for (var i=0; i<s.length; i++) {
- for (var j=n; j<parseInt(s[i].replace(/^(\d+).+$/, "$1"),10); j++) { d.push(j+"<>"+ABN_MSG); n++; }
- d.push(s[i]); n++;
- }
- this.msg = d.join("\n");
- }
- ,delResNo : function() { this.msg = this.msg.replace(/^\d+<>/mg, ""); }
- ,overwriteMsg : function() {
- var data = this.msg.split("\n");
- var msg = DatInfo.msg;
- var i;
- for (i=0; i<data.length; i++) msg[parseInt(data[i],10)-1] = data[i].replace(/^\d+<>/,"");
- for (i=0; i<msg.length; i++) if(!msg[i]) msg[i] = NOT_GET_MSG;
- this.msg = msg.join("\n");
- if(this.msg.slice(-1)!="\n") this.msg += "\n";
- }
- ,proc : function() {
- this.prepare();
- URL.set_prm(this.urlReplace(args.url));
- var brd = Jane.getBRD(URL.prm);
- if (!brd) brd = this.createBrdFolder();
- if (!brd) Err("E_brditem_not_found");
- var dat = Jane.LogBasePath + JANE_LOGS + brd + URL.thrID + ".dat";
- var bak = Jane.LogBasePath + JANE_BAK + brd + URL.thrID + ".dat";
- DatInfo.setInfo(dat, bak, brd);
- URL.appendRange(DatInfo.cnt);
- if (trace()|this.readHTTP(URL.url)|trace("HTTP total read time")) {
- if (!this.msg) Err("E_block_not_found");
- if (!this.noChkTitle && !this.title) Err("E_title_not_found");
- trace(); this.mainReplace(); trace("html->dat main replace");
- if (args.append) {
- trace(); this.delDupData(); trace("del dupdata time");
- if(this.msg=="") Err("E_already_there");
- }
- this.first = this.getFirst();
- this.last = this.getLast();
- this.checkData(this.msg);
- if (this.first==1) { this.addTitle(); }
- if(this.requireFillAbn) { trace(); this.fillAbn(); trace("透明abnレス挿入"); }
- this.postReplace();
- if(args.overwrite) this.overwriteMsg();
- else this.delResNo();
- }
- trace("スレタイトル:"+this.title+"\tレス数:"+this.last,9);
- saveDat(dat, this.msg);
- DatInfo.setNewDatInfo(this.title, this.last);
- saveIdx("http://"+URL.site+((URL.category)?"/"+URL.category:"")+"/"+URL.brdID);
- invokeJaneStyle(URL.getUrl2());
- trace("---- end ----",1);
- }
- }
- var Thread_2ch = object(Thread,{
- read_cgi_ver : ""
- ,REG_PATTERN : [
- { "thr" : /^[\s\S]*?<dl[^>]*>\s*(?:<font[^>]*>.*<\/font>.*\s*)?((?:\s*<dt[^>]*>.+?<dd>.+\r?\n?)+)(\s*<\/dl>)?/i
- ,"msg" : /[ \t]*<dt.*?>([0-9]+).+?(?:"mailto:(.+?)">)?<b[^>]*>(.*?)<\/b>(?:<\/font>|<\/a>)?(?: ?投稿日)? ?:(.*?)<dd>(.*?)(?:<br>)*(?=<dt.*?>|$)/img
- ,"rep" : "$1<>$3<>$2<>$4<>$5<>"
- }
- ,{ "thr" : /^[\s\S]*?<div class="thread"[^>]*>((?:<div class="post"[^>]*>(?:<div[^>]*>.*?<\/div>)+<\/div>)*)(<\/div>)/i
- ,"msg" : /.*?<div class="number">(\d+).+?<\/div><div class="name"><b>(?:<a href="mailto:(.+?)">)?(.*?)(?:<\/a>)?<\/b><\/div><div class="date">(.*?)<\/div><div class="message">(.*?)<\/div><\/div>(?=<div class="post"|$)/img
- ,"rep" : "$1<>$3<>$2<>$4<>$5<>\n"
- }
- ]
- ,urlReplace :
- function(url) {
- url = url.replace(/^(http:\/\/next2ch\.net\/)(\w+\/)(?:kako\/\d{3,4}\/(?:\d{5}\/)?)?(\d+)(?:\/|\.html)?$/,"$1test/read.cgi/$2$3/");
- if(!args.keep_kako)
- url=url.replace(/^(.*?\/)(\w+\/)kako\/\d{3,4}\/(?:\d{5}\/)?(\d+)\.html$/,"$1test/read.cgi/$2$3/");
- return url;
- }
- ,preReplace : function() {
- this.msg = this.msg
- .replace(/<div (?:class|id)="banner"[^>]*>[\s\S]*?(?=<dt|<div class="post"|<\/div><div class="cLength"|<\/dl>)/ig,"")
- .replace(/(<a href=)"\/cdn-cgi\/l\/(email-protection\#.*?">)/ig,'$1"mailto:$2');
- }
- ,postReplace : function() {
- this.msg = this.msg
- .replace(/<\/div><div class="be[^>]*><a href="[^"]+\/(\d+)"[^>]*>\?(.*?)<\/a>/ig," BE:$1-$2")
- .replace(/<a href="http.*?>(.*?)<\/a>/ig, "$1")
- .replace(/<a href="javascript:be\(([^\)]+?)\)[^>]*>\?(.*?)<\/a>/ig, "BE:$1-$2")
- .replace(/<img src="http:\/\/(img\.2ch\.net\/.+?)">/ig, "sssp://$1")
- .replace(/<img src="(.*?)">/ig, "$1");
- }
- ,_getKakoUrl :
- function() {
- var p = URL.prm;
- if(URL.thrID<1000000000)
- { url="http://$1/$2/kako/$3/$4.dat.gz".expand([,p[1],p[5],p[6].substr(0,3),p[6]]);}
- else
- {url="http://$1/$2/kako/$3/$4/$5.dat.gz".expand([,p[1],p[5],p[6].substr(0,4),p[6].substr(0,5),p[6]]);}
- return url;
- }
- ,readHTTP :
- function(url) {
- var s,ss,u,msgLength;
- if(!URL.kako && !URL.RE_HOST.test(url)) { if(!this.readHTTP0(url)) return false; } //dat取得
- /*@if (@EnabledTest2chJSON)
- o("1st try json");
- this.msg = get2chJSON();
- if(this.msg=="") Err("E_already_there");
- if(this.msg) return false;
- o("2nd try html");
- @end @*/
- this.kakoUrl = this._getKakoUrl();
- if(URL.kako) if(!this.readHTTP2(this.kakoUrl)) return false;
- trace("try URL="+url,9);
- this.msg = readHTTP(url);
- this.read_cgi_ver = (this.msg.match(/>read\.cgi ver ([\d.]+)/)||[])[1];
- this.preReplace();
- this.getTitle(this.msg);
- msgLength = this.msg.length;
- ss = this.matchTBlock(this.msg);
- if (!ss) {
- u = this.kakoUrl.replace(/\.dat\.gz$/,".html");
- if (u!=url) {
- switch(this.readHTTP3(u)) {
- case 0: return false;
- case 1: url=u; ss=this._matchTBlock(this.msg); break;
- default: break // case -1
- }
- }
- }
- if(!ss) {
- ss = "<URL>="+url+"\n<TITLE>="+this.title+"\n<メッセージ長>="+msgLength+"\n\n";
- ss += ((this.msg.match(/^((?=.*LoadAverage|人大杉).*$)/im)||[])[1])
- || ((this.msg.match(/<h1[^>]*>([\s\S]*?)<\/h1>/m)||[])[1])
- || ((this.msg.match(/<p[^>]*>\n*(.*\s+.*\s*)$/m)||[])[1])
- || "不明";
- Err("E_block_not_found", "\nもしかしたら以下のはメッセージかも\n\n"+ss+"\n");
- }
- if (!ss[2]) {
- if (MsgBox("途中でデータが途切れているようですが続行しますか?",4+48,MY_NAME)!=6) Err("E_stop");
- }
- s = ss[1] || "";
- if(this.re_sel==0 && s && s.slice(-1)!='\n') s += '\n';
- this.msg = s;
- return true;
- }
- ,readHTTP2 :
- function(url) {
- var re = /^(?:(?!<>).)*<>(?:(?!<>).)*<>(?:(?!<>).)*<>(?:(?!<>).)*<>((?:(?!<>).)*).*\s*$/m;
- trace("try URL="+url,9);
- var s="";
- try {s = readHTTP(url);}catch(e){} //9999999999.dat.gz
- var r = s.match(re);
- if(!r) {url=url.replace(/\.gz$/,""); trace("try URL="+url,9); try{s=readHTTP(url); r=s.match(re);}catch(e){} }
- if(r) {
- this.msg = s;
- this.last = this.checkData0(s).replace(/^.*$/m,"").length;
- this.title = r[1];
- URL.kako = true;
- delete args.append;
- return false;
- }
- return true;
- }
- ,readHTTP3 :
- function(url) {
- var title=((this.msg.match(/<title>(.*)<\/title>/im)||[])[1]||"");
- trace("HTTP title="+title,9);
- if (/error/i.test(title)) {
- if(!this.readHTTP2(this.kakoUrl)) return 0; //最初に/kako/.../9999999999.dat.gzを試す
- trace("try URL="+url,9);
- var s = readHTTP(url); //9999999999.html
- if(/<dl.*>/.test(s)) { // hit
- this.msg = s;
- this.preReplace();
- URL.kako = true;
- delete args.append;
- return 1;
- }
- trace("HTTP title="+((s.match(/<title>(.*)<\/title>/im)||[])[1]||""),9);
- }
- return -1;
- }
- ,readHTTP0 :
- function(url) {
- var re = /^(?:(?!<>).)*<>(?:(?!<>).)*<>(?:(?!<>).)*<>(?:(?!<>).)*<>((?:(?!<>).)*).*\s*$/m;
- var s;
- url = "http://"+URL.site+"/"+URL.brdID+"/dat/"+URL.thrID+".dat";
- trace("try URL="+url,9);
- try { s=readHTTP(url); } catch(e) {}
- if(s) {
- this.msg = s;
- this.title = (s.match(re)||[])[1];
- this.last = this.checkData0(s).replace(/^.*$/m,"").length;
- delete args.append;
- return false;
- }
- return true;
- }
- });
- var Thread_jbbs = object(Thread,{
- prepare : function() { Jane=Jane_jbbs; URL=URL_jbbs; }
- ,REG_PATTERN : [
- { "thr" : /^[\s\S]*?<dl\s+(?:class|id)="thread[^>]*?>\s*(<dt>(?:(?!<\/dl>)[\s\S])*?\s*)<\/dl>[\s\S]*$/i
- ,"msg" : /<DT><A.*?>([0-9]+).+?(?:<A HREF="mailto:(.+?)">)?<B> ?(?:<font color.*?>)?(.*?)(?:<\/font>)? ?<\/B>(?:<\/A>|<\/FONT>)(?: 投稿日)?: ?(.*?)(?:<BR>)?<DD>(.*) ?<BR><BR>/img
- ,"rep" : "$1<>$3<>$2<>$4<>$5<>"
- }
- ,{ "thr" : /^[\s\S]*?<dl[^>]*?>(?:(?!<dt>)[\s\S])*(<dt>(?:(?!<\/dl>)[\s\S])*)<\/dl>[\s\S]*$/i
- ,"msg" : /<DT><A.*?>([0-9]+).+?(?:<A HREF="mailto:(.+?)">)?<B> ?(?:<font color.*?>)?(.*?)(?:<\/font>)? ?<\/B>(?:<\/A>|<\/FONT>)(?: 投稿日)?: ?(.*?)(?:<BR>)?<DD>(.*) ?<BR><BR>/img
- ,"rep" : "$1<>$3<>$2<>$4<>$5<>"
- }
- ]
- ,urlReplace : function(u) {
- //したらばの事前URL変換:旧site名、/storage/ URLを現在のURLに置換
- return u.replace(URL.RE_HOST,"http://jbbs.shitaraba.net/")
- .replace( /\/\w+\.cgi\//, "/read.cgi/")
- .replace(/^(http:\/\/[^\/]+\/)([^\/]+\/)([^\/]+\/)storage\/(\d+).*$/,"$1bbs/read.cgi/$2$3$4/");
- }
- // ,preReplace : function() {
- // s = s.replace(/^\s*$/mg,"");
- // s = s.replace(/\n\n/g,"\n");
- // s = s.replace(/\s*<div[^>]+>(?:(?!<\/div>)[\s\S])*<\/div>\s*/ig,"\n"); //100レス毎に入る公告を除去
- // }
- ,mainReplace :
- function() {
- this.msg = this.msg.replace(/^(\d+<>.*?<>.*?<>.*?)(<>.*<>)((?:(?!<>).)*)$/mg, function($0,$1,$2,$3) {return ($3)?$1+" ID:"+$3+$2:$0;});
- }
- ,createBrdFolder :
- function() {
- var s = readHTTP( URL.url.replace( /\/\w+\.cgi(\/\w+\/\w+\/).*$/, "/api/setting.cgi$1") );
- var bbs_title = (s.match(/^BBS_TITLE=(.*)$/m)||[])[1];
- var category = (s.match(/^CATEGORY=(.*)$/m)||[])[1];
- bbs_title || category || Err("E_brditem_not_found");
- brd = [ "【したらば】" + category.convDontUseStr() , bbs_title.convDontUseStr() , ""].join("\\");
- path(Jane.LogBasePath + JANE_LOGS + brd + URL.thrID + ".dat");
- return brd;
- }
- ,checkData :
- function(s) {
- if (this.last-this.first+1 != s.replace(/^.*$/mg,"").length) {
- this.requireFillAbn = true;
- }
- // 末尾のIDを削除
- this.msg = s.replace(/^(.*?)<>((?!<>).)*$/mg, "$1");
- }
- ,getTitle : function(s) {
- this.title = (s.match(/<>((?:(?!<>).)*)<>(?:(?!<>).)*$/m)||[])[1];
- if(!this.title) this.title=DatInfo.title;
- }
- ,addTitle : function() {}
- ,readHTTP :
- function(url) {
- //-- 1st try : rawmode read ----
- var raw_url = url.replace(/\/\w+\.cgi\//, "/rawmode.cgi/");
- trace("try URL="+raw_url,9);
- var s = readHTTP( raw_url, true);
- switch( errmsg = (s[1].match(/^ERROR: *(?! )(.*?)$/m)||[])[1]||"" ) {
- case "BBS NOT FOUND": Err("E_bbs_not_found");
- case "KEY NOT FOUND": Err("E_key_not_found");
- case "THREAD NOT FOUND": Err("E_thread_not_found");
- case "STORAGE IN":
- this.getTitle = this.getTitle2;
- this.delDupData = this.delDupData2
- this.checkData = this.checkData2;
- Thread.readHTTP.call(this, URL.prm[0]);
- delete this.mainReplace;
- delete this.addTitle;
- break;
- case "": //正常取得
- s = s[0];
- this.getTitle(s);
- IDX_STATE["jbbs"] = 0;
- this.msg = s;
- break;
- default: Err("E_http_recieve", "(rawmode) : " + errmsg);
- }
- return true;
- }
- ,getTitle2 :
- function(s) { this.title = (s.match(/<h1 class="thread-title">(.*?)<\/h1>/i)||[])[1]
- || (s.match(/<title>(.*?)<\/title>/i)||[])[1] || "";
- }
- ,delDupData2 : //append時、既存のレス数分データを読み飛ばす
- function() { while( (this.msg.match(/^(\d+)/i)||[])[1] < DatInfo.cnt+1)
- { this.msg = this.msg.replace(/^.*\n/m,""); }
- }
- ,checkData2 :
- function(s) { var ln = this.checkData0(s);
- if (this.last-this.first+1 != ln.length) { this.requireFillAbn = true; }
- }
- });
- var Thread_machi = object(Thread,{
- prepare : function() { Jane=Jane_machi; URL=URL_machi; }
- ,noChkTitle : true
- ,REG_PATTERN : [
- { "thr" : /^(?:(?!<>).)*<>(?:(?!<>).)*<>(?:(?!<>).)*<>(?:(?!<>).)*<>(?:(?!<>).)*<>((?:(?!<>).)*)<>((?:(?!<>).)*).*\s*$/m
- ,"msg" : /^((?:(?!<>).)*<>(?:(?!<>).)*<>(?:(?!<>).)*<>(?:(?!<>).)*)(<>(?:(?!<>).)*<>(?:(?!<>).)*)<>((?:(?!<>).)*)(?:<>)?(.*\s*)$/mg
- ,"rep" : "$1 [ $3 ]$2$4"
- }
- ]
- ,urlReplace : function(u) { u=u.replace(/\/test\/(?=read)/,"/bbs/").replace(/\/read\.cgi\//,"/offlaw.cgi/2/"); trace("replace url="+u,9); return u; }
- ,getTitle : function(s) { this.title = (s.match(this.REG_PATTERN[this.re_sel].thr)||[])[1] || DatInfo.title; }
- ,checkData : function(s) {
- if(!/^\d+<>.*?<>.+?<>.*?<>.*$/m.test(s)) Err("E_remained_garbage");
- if (this.last-this.first+1 != s.replace(/^.*$/mg,"").length) { this.requireFillAbn = true; }
- }
- ,delDupData : function() {}
- ,addTitle : function() {}
- ,getTBlock : function() {}
- });
- //==============================================================
- function loadFile(f) {
- var s;
- try {
- strm.Type = 2;
- strm.Charset = 'shift_jis';
- strm.Open();
- strm.loadFromFile(f);
- s = strm.ReadText(-1);
- strm.Close();
- } catch(e) { strm.Close(); Err("E_loadfile", "\n"+e.message+"\ncurrent="+shell.CurrentDirectory+"\nfile="+f); }
- return s;
- }
- function loadFile2(f) {
- var s;
- try {
- var file = fso.OpenTextFile( f, 1, false, 0);
- s = file.ReadAll();
- file.close();
- } catch(e) {
- if(file) file.close();
- s = loadFile(f);
- }
- return s;
- }
- function saveFile(f,s) {
- strm.Type = 2;
- strm.Charset = 'shift_jis';
- strm.Open();
- if (args.append) { try {strm.loadFromFile(f); strm.Position = strm.Size;} catch(e){} }
- strm.WriteText(s);
- try { strm.Savetofile(f, 2); }
- catch(e) { strm.Close(); Err("E_savefile", "\n"+e.message+"\ncurrent="+shell.CurrentDirectory+"\nfile="+f); }
- strm.Close();
- }
- function saveFile2(f,s) {
- try{
- var file = fso.OpenTextFile( f, (args.append)?8:2 , true, 0);
- file.Write(s);
- file.Close();
- } catch(e) {
- if(file) file.Close();
- saveFile(f,s);
- }
- }
- function readHTTP(u, withHeaders) {
- var s="", r="";
- http.open("GET", u, true);
- for(var i in HTTP_HEADERS) { http.setRequestHeader(i, HTTP_HEADERS[i]); }
- http.send();
- for (var t0=new Date(); http.readyState<4; ) {
- if (new Date() - t0 > HTTP_TIMEOUT) { http.abort(); Err("E_http_timeout"); }
- WScript.Sleep(50);
- }
- if (http.status != 200 && !http.status==0) Err("E_http_recieve", " status="+http.status);
- var header = http.getResponseHeader("Content-Type");
- if (withHeaders) r = http.getAllResponseHeaders();
- try {s = http.responseText;} catch(e) {s="";}
- if (!/charset=/i.test(header)) {
- if(http.responseBody !== void 0) {
- if(basp) {
- trace("HTTP文字コード変換開始 using basp21",9);
- s = basp.Kconv(http.responseBody,4);
- } else {
- trace("HTTP文字コード変換開始",9);
- var cs = (s.match(/<meta[^>]*charset=([^>;"'\s]+)/i)||[])[1] || '_autodetect';
- strm.Type = 1;
- strm.Open();
- strm.Write(http.responseBody);
- strm.Position = 0;
- strm.Type = 2;
- strm.Charset = cs;
- s = strm.ReadText(-1);
- strm.Close();
- }
- }
- }
- http.abort();
- if(!s) s="";
- return withHeaders ? [s,r] : s;
- }
- function saveDat(dat,s) {
- if (args.append) {
- if(s=="") Err("E_already_there");
- } else {
- if(s.match(/\n/g)==null) Err("E_no_data");
- if(!args.overwrite && DatInfo.cnt>=s.match(/\n/g).length) {
- if (MsgBox("既存のスレデータの方が同じか又は大きいですが、置換を続行しますか?",4+32+256,MY_NAME) != 6){
- Err("E_stop");
- }
- }
- }
- if(args.bak) DatInfo.copyDat();
- trace(); saveFile2(path(dat), s); trace("save file:"+dat);
- }
- function invokeJaneStyle(url) {
- shell.Exec(JANE_EXE + " " + url);
- if(args.sendkey && args.sendkey > 0) {
- WScript.Sleep(args.sendkey);
- shell.SendKeys('^(w)');
- WScript.Sleep(200);
- shell.Exec(JANE_EXE + " " + url);
- }
- if(args.redraw) {
- WScript.Sleep(args.redraw);
- shell.SendKeys('%');
- WScript.Sleep(20);
- shell.SendKeys('T');
- WScript.Sleep(10);
- shell.SendKeys('G');
- WScript.Sleep(10);
- shell.SendKeys('0');
- }
- }
- function terminateJaneExe() {
- var wmi; try { wmi = new WMI(); } catch(e) { wmi=null; }
- shell.Exec(JANE_EXE);
- WScript.Sleep(200);
- shell.SendKeys("%({F4})");
- if(!wmi) { WScript.Sleep(4000);}
- else {
- do {
- var cnt=40;
- while(cnt && wmi.isAliveProcess(JANE_EXE, JANE_PATH+JANE_EXE)) { WScript.Sleep(100); cnt--;}
- if(!cnt) { WScript.Echo(JANE_EXE+"を終了させてください"); }
- } while(!cnt);
- }
- }
- function saveIdx(boardUrl) {
- var i,s,r;
- var use_db = parseInt(Jane.getINI([,"OPTIONS","QuickMerge",""]),10);
- if(chkJaneProg().indexOf('Xeno')>=0) { use_db = parseInt(Jane.getINI([,"OJVIEW","QuickMerge",""]),10); }
- var basedir = shell.CurrentDirectory;
- var dir = fso.GetParentFolderName(fso.GetFile(DatInfo.dat).Path);
- var datName = DatInfo.dat.replace(/^.*\\([^\\]+)\.dat$/,"$1");
- var maxRes = getBrdCustomizeIni(boardUrl) || 1000;
- var state = (DatInfo.lines>=maxRes) ? 0 : IDX_STATE[ (URL===URL_jbbs) ? "jbbs" : "2ch" ];
- if (URL.kako) state = 10;
- var last_got = Number(new Date(fso.GetFile(DatInfo.dat).DateLastModified)/1000+9*60*60);
- var idx = [ datName,DatInfo.title,'',DatInfo.lines,'0','',boardUrl,state,DatInfo.lines,'','','0',last_got,'0','0' ];
- var idxText = [];
- for(i=0; i<idx.length; i++) { idxText[i] = "'" + idx[i] + "'"; }
- var SQL_CMD_1 = "CREATE TABLE IF NOT EXISTS tableversion (tablename PRIMARY KEY, version);"
- + 'INSERT OR IGNORE INTO "tableversion" VALUES(' + "'board_db','00000001');"
- + 'INSERT OR IGNORE INTO "tableversion" VALUES(' + "'idxlist','00000002');"
- + "CREATE TABLE IF NOT EXISTS idxlist ("
- + "datname TEXT PRIMARY KEY, title TEXT, last_modified TEXT, lines TEXT, view_pos TEXT, idx_mark TEXT,"
- + " uri TEXT, state TEXT,new_lines TEXT, write_name TEXT, write_mail TEXT,"
- + " last_wrote TEXT, last_got TEXT, read_pos TEXT, record_be TEXT,"
- + " etc1 TEXT, etc2 TEXT);";
- var SQL_CMD_2 = 'INSERT OR IGNORE INTO idxlist VALUES(' + idxText.join(",") + ",NULL,NULL);";
- var SQL_CMD_3 = "update idxlist set new_lines=new_lines+$2-lines where datname='$1';".expand([,datName,DatInfo.lines]);
- var SQL_CMD_4 = "update idxlist set lines=" + idxText[3] + ",uri=" + idxText[6] + ",title=" + idxText[1]
- + ",state=" + idxText[7] + ",last_got=" + idxText[12] + " where datname=" + idxText[0] + ";";
- if (use_db && args.restart) {
- var sql = new Sql();
- if(chkJaneProg().substr(0,4)=='Xeno' && !sql.isSqlite_ODBC) Err("E_require_sqlODBC");
- sql.isSqlite_ODBC || sql.isSqlite_exe || Err("E_require_sqlite");
- }
- if(args.restart) terminateJaneExe();
- if (use_db && args.restart) {
- switch(chkJaneProg()) {
- case 'Style' :
- case 'Style?':
- shell.CurrentDirectory = dir;
- r=sql.exec("BoardDB.db",SQL_CMD_1+SQL_CMD_2+SQL_CMD_3+SQL_CMD_4);
- break;
- case 'Xeno':
- case 'Xeno?':
- var qmerge3 = Jane.LogBasePath+JANE_LOGS+"qmerge3.db";
- if(!fso.FileExists(qmerge3)) break;
- idx.splice(14,1,last_got);
- idxText = [];
- for(i=0; i<idx.length; i++) { idxText[i] = "'" + idx[i] + "'"; }
- var brd=DatInfo.brd.slice(0,-1);
- var SQL_CMD_XENO1 = "select board_id,max(board_id) from board where board_name='"+brd+"';";
- var SQL_CMD_XENO2 = 'insert into board VALUES((select max(board_id)+1 from board),'+"'"+brd+"'"+');';
- var SQL_CMD_XENO3 = "select board_id from thread where board_id=$1 and datname='"+datName+"';";
- var SQL_CMD_XENO4 = "insert into thread values($1,"+idxText.join(",")+");";
- var SQL_CMD_XENO5 = "update thread set new_lines=new_lines+$2-lines where datname='$1';".expand([,datName,DatInfo.lines]);
- var SQL_CMD_XENO6 = "update thread set lines=" + idxText[3] + ",uri=" + idxText[6] + ",title=" + idxText[1]
- + ",state=" + idxText[7] + ",last_got=" + idxText[12] + " where datname=" + idxText[0] + ";";
- var board_id = sql.select(qmerge3,SQL_CMD_XENO1);
- board_id = (board_id[0].match(/^(\d+)/)||[])[1];
- if (!board_id) { sql.exec(qmerge3, SQL_CMD_XENO2); board_id=((sql.select(qmerge3,SQL_CMD_XENO1))[0].match(/^(\d+)/)||[])[1]; }
- if(!((sql.select(qmerge3,SQL_CMD_XENO3.expand([,board_id])))[0].match(/^\d+/))) {
- sql.exec(qmerge3, SQL_CMD_XENO4.expand([,board_id]));
- } else {
- sql.exec(qmerge3, SQL_CMD_XENO5);
- sql.exec(qmerge3, SQL_CMD_XENO6);
- }
- default: break;
- }
- sql.finalize();
- }
- // idxファイルの更新
- shell.CurrentDirectory = dir;
- var isExistIdx = false;
- if(fso.FileExists(datName+".idx")) {
- s = loadFile(datName+".idx").replace(/\r/g,"").split("\n");
- if(s.length>=12) {
- isExistIdx = true;
- s[7] = "" + (parseInt(s[7],10) + DatInfo.lines - parseInt(s[2],10));
- s[2] = "" + idx[3];
- s[5] = idx[6];
- s[6] = "" + idx[7];
- s[11] = "" + last_got;
- s[0] = idx[1];
- }
- }
- if(!isExistIdx) {
- s = idx;
- s.splice(0,1);
- s.push("");
- }
- s = s.join("\r\n");
- try { saveFile(datName+".idx", s); } catch(e) {}
- // subject.txtの更新
- if(fso.FileExists("subject.txt")) {
- var re = new RegExp("^"+datName+"\\..*\\((\\d+)\\)(\\s*)$", "m");
- s = loadFile("subject.txt");
- r = s.match(re);
- if(r) {
- s = s.replace(re, r[0].replace(/\((\d+)\)(\s*)$/,"("+DatInfo.lines+")$2"));
- try { saveFile("subject.txt",s); } catch(e) {}
- }
- }
- shell.CurrentDirectory = basedir;
- }
- function Sql(){
- var DRIVER = "DRIVER=SQLite3 ODBC Driver;";
- var db = new ActiveXObject("ADODB.Connection");
- this.isSqlite_exe = fso.FileExists(SCRIPT_PATH + "sqlite3.exe");
- this.isSqlite_ODBC = (function(){var s=true; try {db.Open(DRIVER);db.Close();} catch(e){s=false;}; return s;})();
- this.finalize = function() { db = null; }
- var funcTables = [ "exec", "select" ];
- var types = (this.isSqlite_ODBC) ? "ODBC" : "exe";
- for(var i=0; i<funcTables.length; i++) { eval( "this."+ funcTables[i] + "=" + funcTables[i] + "_" + types + ";"); }
- function exec_ODBC(dbFile,sql) {
- try {
- var s="";
- db.Open(DRIVER+"Database="+dbFile);
- db.Execute(sql);
- } catch(e) { s = e.message; }
- try { db.Close(); } catch(e) { s += " | Connection Close:"+e.message; }
- return [,s];
- }
- function select_ODBC(dbFile,sql) {
- var r="",s="";
- var rs = new ActiveXObject("ADODB.Recordset");
- try {
- db.Open(DRIVER+"Database="+dbFile);
- rs.Open(sql,db);
- while(!rs.Eof) {
- var rr=[];
- for(var i=0; i<rs.Fields.count; i++) { rr.push(rs(i).Value); }
- r += rr.join("|")+"\n";
- rs.MoveNext();
- }
- } catch(e) { s = e.message; }
- try { rs.Close(); } catch(e) { s += " | Recordset Close:"+e.message; }
- try { db.Close(); } catch(e) { s += " | Connection Close:"+e.message; }
- rs = null;
- return [r, s];
- }
- function exec_exe(dbFile,sql) { return select_exe(dbFile, sql); }
- function select_exe(dbFile, sql) {
- var sqlite = shell.Exec(SCRIPT_PATH + "sqlite3.exe");
- sqlite.StdIn.WriteLine(".open '"+ dbFile+ "'");
- sqlite.StdIn.WriteLine(sql);
- sqlite.StdIn.WriteLine(".quit");
- return [ sqlite.StdOut.ReadAll(), sqlite.StdErr.ReadAll() ];
- }
- }
- function getBrdCustomizeIni(brdurl) {
- if(!fso.FileExists(JANE_BRDCUSTOMIZE_INI)) return null;
- var s=loadFile(JANE_BRDCUSTOMIZE_INI),r,u;
- brdurl=brdurl.replace(/^http:\/\//,"").replace(/\./g,"\\.");
- do {
- if (r = s.match(new RegExp("^\\[$1/?\\]\\s+MaxResNum=(\\d+)".expand([,"http://"+brdurl]),"im"))) break;
- u = brdurl.split(/\/(?=[^\/]+$)/);
- brdurl =u[0];
- } while(u[1])
- return r&&r[1];
- }
- function chkJaneProg() {
- var i,n1=0,n2=0, description,productname;
- var folder=sha.Namespace(JANE_PATH);
- var items=folder.Items();
- for(i=0; i<items.Count-1;i++) {
- if(folder.GetDetailsOf(items, i) == '説明') { n1=i; }
- if(folder.GetDetailsOf(items, i) == '製品名') { n2=i; }
- }
- if(n1>0) description = folder.GetDetailsOf(folder.ParseName("Jane2ch.exe"),n1);
- if(n2>0) productname = folder.GetDetailsOf(folder.ParseName("Jane2ch.exe"),n2);
- if (description=="JaneXeno") return "Xeno";
- if (description=="JaneView") return "View";
- if (productname=="Jane Style") return "Style";
- var fileversion = parseFloat(fso.GetFileVersion(JANE_PATH+JANE_EXE));
- if (fileversion>3.0) return "Style?";
- if (fileversion<1.0) return "Xeno?";
- return "Unknown";
- }
- //==============================================================
- function path(p) {
- var d = p.match(/[^\\]+\\/g), e = "";
- for (var i = 0; d[i]; i++) fso.FolderExists(e += d[i]) || fso.CreateFolder(e);
- return p;
- }
- function parmParse(args) {
- var ptn = [ "^(?:/n:)?(\\d+)", "^/f", "^\\+?http://", "^/w:?(-?\\d+)?$", "^/-w", "^/a(?:ppend)?"
- , "^/b(?:ak)?(1)?", "^/z", "^/redraw:?(\\d+)?$", "^/log:?(.*)$", "^/keep_kako$" ];
- var p = {};
- var require_input_url = false;
- for (var i=0; i<args.length; i++) {
- for (var j=0,n=-1; j<ptn.length;j++) {if ((new RegExp(ptn[j],"i")).test(args(i))) { n=j; break;} }
- switch (n) {
- case 0: p["opt_n"] = ((args(i).match(new RegExp(ptn[n],"i"))||[])[1]||"");
- break;
- case 1: require_input_url = true;
- break;
- case 2: p["url"] = args(i);
- break;
- case 3: p["sendkey"] = ((args(i).match(new RegExp(ptn[n],"i"))||[])[1]||1200);
- break;
- case 4: p["sendkey"] = -1;
- break;
- case 5: p["append"] = true;
- break;
- case 6: p["bak"] = -1;
- if ((args(i).match(new RegExp(ptn[n],"i"))||[])[1]) { p["bak"] = 1; }
- break;
- case 7: p["restart"] = true;
- break;
- case 8: p["redraw"] = ((args(i).match(new RegExp(ptn[n],"i"))||[])[1]||1200);
- break;
- case 9: p["trace"] = ((args(i).match(new RegExp(ptn[n],"i"))||[])[1]||"");
- break;
- case 10: p["keep_kako"] = true;
- break;
- default: break;
- }
- }
- p.url = (p.url||"").replace(/^(\+?http:\/\/.*?)http:\/\/.*$/, "$1")
- if (require_input_url || !p.url) p.url = InputBox("URLを指定してください",MY_NAME, p.url) || "";
- if(p.url.charAt(0)=='+') { p.url = p.url.substr(1); p["overwrite"] =true; }
- if(p.overwrite) p.append = false;
- return p;
- }
- //==============================================================
- function WMI() {
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var services = locator.ConnectServer(null, "root\\CIMV2");
- return {
- isAliveProcess :
- function (pName, pPath) {
- var query = "SELECT * FROM Win32_Process WHERE name='"+pName+"'";
- var props = this.wmiProps(query);
- for (var i=0, status=false; i<props.length; i++) { if(props[i].ExecutablePath == pPath) {status = true;} }
- return status;
- }
- ,wmiProps :
- function (query) {
- var result = [];
- try {
- var set = services.ExecQuery(query);
- var e = new Enumerator(set);
- while (!e.atEnd()) { result.push(e.item()); e.moveNext(); }
- } catch (e) { throw e; }
- return result;
- }
- ,getProcessID :
- function (pName, pPath) {
- var query = "SELECT * FROM Win32_Process WHERE name='"+pName+"'";
- do {
- var props = this.wmiProps(query);
- for (var i=0,c=0,pid; i<props.length; i++) {
- if (props[i].ExecutablePath == pPath) { c++; pid=props[i].ProcessID; }
- }
- } while (c>1);
- return pid;
- }
- }
- }
- function Trace() {
- var logfile = TRACE_LOG;
- var flag = true;
- var first = true;
- var t = [];
- if(args.trace) logfile = replaceEnv(args.trace);
- if(!fso.FileExists(logfile)) {
- var env = new ENV();
- try{
- var f = fso.CreateTextFile(logfile);
- f.WriteLine("["+MY_NAME+"]");
- f.WriteLine("Jane Type = "+chkJaneProg()+"\t"+fso.GetFileVersion(JANE_PATH+JANE_EXE));
- f.WriteLine("current path = "+JANE_PATH);
- f.WriteLine("Logs path = "+Jane.LogBasePath+JANE_LOGS);
- f.WriteLine("script path = "+SCRIPT_PATH);
- f.WriteLine("UAC = "+env.UAC);
- f.WriteLine("64bit? = "+env.PROCESSOR_ARCHITECTURE+"\t"+env.PROCESSOR_ARCHITEW6432);
- f.WriteLine("----------------------------------------------------------------------");
- f.Close();
- } catch(e) {flag=false; if(f) f.Close();}
- env = null;
- }
- return function(s,n) {
- if(flag) try{
- if(!n) n=0;
- var f = fso.OpenTextFile(logfile,8,true,0);
- if(first) {first=false; f.WriteLine("");}
- var tt=new Date();
- if(!s) { t[n] = new Date();}
- else { f.WriteLine(formatDate(tt,3)+"\t"+((n in t)?formatNum(tt-t[n],7)+"ms":" ")+"\t"+s); }
- f.Close();
- } catch(e) {if(f) f.Close();}
- }
- }
- function getEnv(s) { var wse = shell.Environment("Process"); return wse(s); }
- function replaceEnv(s) { return s.replace(/\%([^%]+)\%/ig, function(w0,w1) {return getEnv(w1);}); }
- function formatDate(d,n) {
- return [d.getFullYear()
- , "/" , ("0"+(d.getMonth()+1)).slice(-2)
- , "/" , ("0"+d.getDate()).slice(-2)
- , "(" , "日月火水木金土".substr(d.getDay(),1)
- , ") " , ("0"+d.getHours()).slice(-2)
- , ":" , ("0"+d.getMinutes()).slice(-2)
- , ":" , ("0"+d.getSeconds()).slice(-2)
- , "." , ("00"+parseInt(d.getMilliseconds(),10)+" ").slice(-4,n-4)
- ].join("");
- }
- function formatNum(d,n) {
- return (" "+d).slice(-n);
- }
- function ENV() {
- this.UAC = sha.IsRestricted("system", "EnableLUA");
- this.PROCESSOR_ARCHITECTURE = getEnv("PROCESSOR_ARCHITECTURE");
- this.PROCESSOR_ARCHITEW6432 = getEnv("PROCESSOR_ARCHITEW6432")
- return this;
- }
- //==============================================================
- function main() {
- if (URL_jbbs.RE_HOST.test(args.url)) Thread_jbbs.proc();
- else if (URL_machi.RE_HOST.test(args.url)) Thread_machi.proc();
- else Thread_2ch.proc();
- }
- /*@if (@DEBUG)
- main();
- @else @*/
- try {main();} catch (e) {WScript.Echo(e.message);}
- /*@end @*/
- //==============================================================
- /*@if (@EnabledTest2chJSON)
- function get2chJSON() {
- var urlJSON = "http://itest.2ch.net/public/newapi/client.php?subdomain=$2&board=$5&dat=$6".expand(URL.prm);
- trace("try URL=" + urlJSON,9);
- var s = readHTTP(urlJSON);
- if(!s) return null;
- var total_count = (s.match(/"total_count":(\d+)/)||[])[1];
- var thread = s.match(/"thread":\[(\d+),(\d+),("[^"]*"),("[^"]*"),("[^"]*"),("[^"]*")\]/);
- var comments = (s.match(/"comments":\[((?:\[(\d+),("[^"]*"),("[^"]*"),(\d+),("[^"]*"),("[^"]*"),("[^"]*")\],?)+)\]/)||[])[1];
- if (!thread || !comments) return null;
- eval("var title ="+thread[6]+";");
- comments = comments.replace(/(\[(?:\d+),(?:"[^"]*"),(?:"[^"]*"),(?:\d+),(?:"[^"]*"),(?:"[^"]*"),(?:"[^"]*")\]),/g,"$1\n").split("\n");
- Thread_2ch.title = title;
- Thread_2ch.last = comments.length;
- if(args.append && DatInfo.cnt>0) { comments.splice(0,DatInfo.cnt); }
- for(var i=0; i<comments.length; i++) {
- var res,d,id="",be="";
- var res = comments[i].substring(1,comments[i].length-1);
- res = res.match(/^(\d+),("[^"]*"),("[^"]*"),(\d+),("[^"]*"),("[^"]*"),("[^"]*")$/);
- var name = eval(res[2]).replace(/(◆.+)$/,"</b>$1<b>").replace(/(転載ダメ©2ch\.net)/,"<small>$1</small>");
- d = new Date( (res[4]<365*24*60*60*1000) ? res[4]*1000 : res[4] );
- d = formatDate(d,2);
- if (res[5]!='""') id = " ID:" + eval(res[5]);
- if (res[6]!='""') be = " BE:" + eval(res[6]);
- comments[i] = [ name, eval(res[3]), d + id + be, eval(res[7]), ].join("<>");
- }
- s = "";
- if(comments.length>0) {
- if(!args.append || !DatInfo.cnt) { comments[0] += title; }
- s = comments.join("\n") + "\n";
- }
- return s;
- }
- @end @*/
RAW Paste Data