' ,'
' ].join(""); function IE() { this.existsIE = false; var ie = WScript.CreateObject("InternetExplorer.Application","Event_IE_"); var doc,msg1; ie.Width =800; ie.Height =600; ie.AddressBar = false; ie.MenuBar = false; ie.ToolBar = false; ie.Resizable = true; ie.Visible = false; ie.Navigate2("about:blank", 2); while(ie.Busy || ie.readyState != 4) WScript.Sleep(100); doc=ie.Document; doc.write(HTML_CONTENTS); ie.Visible = true; msg1 = doc.getElementById('msg1'); this.existsIE = true; this.out = function(s) { msg1.innerHTML += s.replace(/&/g,"&"); } this.quit = function() { ie.Quit(); while(ie.Busy) WScript.Sleep(50); this.existsIE=false; } this.getElement = function(s) { return doc.getElementById(s); } this.evt = doc.parentWindow.evt; this.getEvent = function() { try{ return (this.evt.length) ? this.evt.shift() : null; }catch(e){}; return null; } this.setElementByIdDisabled = function(s,t) { this.getElement(s).disabled = t; } }; function Event_IE_OnQuit() { ie.existsIE = false; event_IE_Quit = true; ie=null;} function isExistsIE() { return ie ? ie.existsIE : false; } function waitEvent(t) { var rc = 0, ev, n; if(!isExistsIE) return -1; for( ;t>=0 && !rc; t-=100) { try{ ev=ie.getEvent(); if(ev) { n=(ev.match(/(\d+)$/)||[])[1]; switch(ev.replace(/\d+$/,"")) { case "btn": Wrap.invokeEditor(n); break; default: break; } } } catch(e) { rc = -1; } if(t>0) WScript.Sleep(100); } return 0; } function invokeEditor(n) { var parms,fname="ImageViewURLReplace.dat"; n = button.pos[n] + ""; parms = TEXT_EDITOR_PARMS.replace(/\$F/g, JANE_PATH+fname).replace(/\$N/g, n); sha.ShellExecute(replaceEnv(TEXT_EDITOR), parms); } 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; } //----------------------------------------------------------------- var button = new function() { this.n = 0; this.pos = []; } var err = new function ERR() { this.isError = false; this.out = function(s) { this.isError=true; s="ERROR : "+s; outln(s); throw new Error(s); } this.popup = function(s) { this.isError=true; s="ERROR : "+s; shell.Popup(s); throw new Error(s); } } var ini = new function ImageViewIni() { var ini = ""; var re = "^\\[$1\\]\\r\\n(?:.*\\r\\n)*?(?:$2=(.*)|\\[.*\\])\\r\\n"; var search = function(f,s,p) { return f.match(new RegExp(expand(s,p),"im"))||[]; } var expand = function(s,p) { return s.replace(/\$(\d)/g, function(m, n) { return (""+p[n]).replace(/\./g,"\\."); }); } try { ini = loadTextFile("ImageView.ini"); } catch(e) {} this.UseViewCache = search(ini, re, [,"Cache","UseViewCache"])[1]; if(this.UseViewCache=="1") this.VwCacheDir = search(ini, re, [,"Cache","CachePath"])[1] || "VwCache"; this.FileSizeMaximum = search(ini, re, [,"HTTP","FileSizeMaximum"])[1]; this.TimeOut = search(ini, re, [,"HTTP","TimeOut"])[1]; this.ConnectTimeout = search(ini, re, [,"HTTP","ConnectTimeout"])[1]; try { ini = loadTextFile(JANE2CH_INI); } catch(e) {} this.Exclude1FromNGProcessing = search(ini, re, [,"VIEW","Exclude1FromNGProcessing"])[1]; ini = null; } var ImageViewURLReplaceDat = new function(){ var i; this.list = ""; this.safety_line_pos = Infinity; try { this.list = loadTextFile("ImageViewURLReplace.dat"); } catch(e) {} this.list = this.list.replace(/\r/g,"").split("\n"); this.list.splice(this.list.length-1,1); for(i=0;i"); r = -1; for(i=0;i=0) break; } return (ret>=0) ? own.NGs[n][i][6] : -1; } function makeNGExList() { var i,j,r,s="",ngex,NGEx=[],REs={}; for(i in new NGExClass()) { REs[i] = new RegExp('^'+i+'="?(.*?)"?$'); } try{ s=loadTextFile("NGEx.txt"); } catch(e){} s = s.split(/\r?\n/); for(i=0;i/,"") .replace(/^((?!<)\S)/,"$1") .replace(/^(.+?\t.*?\t.*?\t)<>/,"$1<0>") .replace(/^(.+?\t.*?\t.*?\t)((?!<[012345]>)\S)/,"$1<0>$2"); list[i]=list[i].split("\t"); } } s="";for(i=0;i(.*)$/); try { switch(r[1]) { case "0": if((url+"\n"+title).indexOf(r[2])<0) continue; break; case "1": if((url+"\n"+title).indexOf(r[2])>=0) continue; break; case "2": if(url!=r[2] && title!=r[2]) continue; break; case "3": if(url==r[2] || title==r[2]) continue; break; case "4": if(!Wrap.test(url,r[2],"i")&&!Wrap.test(title,r[2],"i")) continue; break; case "5": if(Wrap.test(url,r[2],"i")||Wrap.test(title,r[2],"i")) continue; break; } } catch(e) { continue; } } r = list[i][0].match(/^<(ex2|ex|rx2|rx)>(.+)$/i); try { switch((r||[])[1]) { case "ex" : s=Wrap.replace(s,escapeMetaChar(r[2]),"ig",list[i][1]); break; case "ex2" : s=Wrap.replace(s,escapeMetaChar(r[2]),"g",list[i][1]); break; case "rx" : s=Wrap.replace(s,r[2],"ig",list[i][1]); break; case "rx2" : s=Wrap.replace(s,r[2],"g",list[i][1]); break; } } catch(e){} } return s; }; }; function Cookie() { this.key; this.data; this.domain; this.path; this.secure; this.lifetime; this.inHtml; } Cookie.prototype.set = function(key, data, domain, path, secure, lifetime, inHtml) { this.key = key; this.data = data; this.domain = domain; this.path = path; this.secure = secure; this.lifetime = lifetime; this.inHtml = inHtml; } var cookies = []; var Cookies = (function() { var words = [ "(path)=", "(domain)=", "(secure)", "(httponly)", "(max-age)=", "(expires)=" , "(version)=", "(comment)=", "(.+)=", "(.)" ]; return { parse : function(s,inHtml,url) { var key=[], data=[], path="", domain="", secure=false, lifetime, httponly=false; var i,re,r,sArray,chunk; var r = this.parseURL(url); domain = r[0]; path = r[1]; sArray = s.replace(/^Set-Cookie: *(.*)\s*$/i,"$1").replace(/^=lifetime) this.del(cookie); else if(USING_CURL||inHtml) this.put(cookie); //ヘッダの場合auto-cookie handlingで処理されるのでスキップ } } , put : function(cookie) { var r = this.search(cookie); if(r>=0) cookies[i] = cookie; else cookies.push(cookie); } , del : function(cookie) { var r = this.search(cookie); if(r>=0) {cookies.splice(r,1);} } , search : function(cookie) { var i,r=-1; for(i=0; i0) ? r.splice(i-1,2) : r.splice(i,1); } } path = "/"+r.join("/"); return [domain, path]; } , setHttpHeaders : function(HeaderList, url) { var r, domain, path; r = this.parseURL(url); domain = r[0]; path = r[1]; for(var i=0; i=cookies[i].lifetime) cookies.splice(i,1); } for(var i=0; i=0) { if("Cookie" in HeaderList) HeaderList["Cookie"] += "; "+cookies[i].key+"="+cookies[i].data; else HeaderList["Cookie"] = cookies[i].key+"="+cookies[i].data; } } } , getAll : function() { var i,j,r=[],s; for (i=0;i ImageViewURLReplaceDat.safety_line_pos) { rc[1]=rc[1].replace(/^http:/,"https:"); if(rc[3]) rc[3]=rc[3].replace(/^http:/,"https:"); if(detail & 0x08) outln2("*** 最終防衛ラインによる置換をhttpsに戻しました"); } url_access = rc[1]; url_new = rc[2]; url_referer = rc[3]; if(detail & 0x08) outln2(MSG_SEARCH_IMAGE_DAT2); if(detail & 0x01) { outln("Org URL: "+url); outln("New URL: "+url_new); outln("Access : "+url_access); } else { trace("Org URL: "+url, 2); trace("New URL: "+url_new, 2); trace("Access : "+url_access, 2); } vwCacheDir = ini.VwCacheDir.replace(/[^\\\/]$/,"$&\\"); hash = encode(md5(string2bytes(url_new))); vchFile = hash.substr(0,22) + ".vch"; if(url_referer) HTTP_HEADERS2.Referer = url_referer; Cookies.setHttpHeaders(HTTP_HEADERS2, url_access); if(args.outimg) { if(fso.FileExists(vwCacheDir+vchFile)) Wrap.putImgFile(vwCacheDir+vchFile, null); else Wrap.putImgFile(null, url_access); } else if(args.deleteVch) { Wrap.deleteVchFile(vwCacheDir, vchFile); } else { Wrap.putVchFile(url_new, url_access, vwCacheDir, vchFile, isErr, detail); } } function putVchFile(url_new, url_access, vwCacheDir, vchFile, isErr, detail) { var img, Vch, n; if(detail & 0x02) outln("【ファイル名】"+vchFile,"strong","2"); else trace("【ファイル名】"+vchFile, 2); isErr = Wrap.dispOldVchFile(vwCacheDir, vchFile, isErr, detail); if(isErr) return; try { img=Wrap.readHTTP(url_access); } catch(e) { img=e.message; try{err.out("http: "+e.message);}catch(e){} } outln2(""); if(event_IE_Quit) return; Vch = new VCH(); img = Wrap.setVch(img, url_new, Vch, detail); n = ("0000000"+Vch.getAll().length.toString(16)).slice(-8); vchFile = path(vwCacheDir+vchFile); try { saveBinaryFile(vchFile, hex2bytes(hexReverseByteOrder(n))); saveTextFile(vchFile, Vch.getAll(), "", true); if(img!=null) saveBinaryFile(vchFile, img, true); } catch(e) { try{ fso.DeleteFile(vchFile); } catch(e2) {} try{ err.out("save: "+e.message); } catch(e) {if(!ie) throw new Error(e.message); } return; } Vch = null; } function putImgFile(vchfile, url_access) { var s, img, n, fname, fext="", fsize, top2, hash, f; if(vchfile) { n = chkOldVchExists(vchfile); if(n) { try{ img = loadBinaryFile(vchfile, fsize-4-n, 4+n); } catch(e){ outln("Skip: ファイル読込みエラー"+e.message,"Strong","3"); return; } } else { outln("Skip: vchファイルにimgデータ無し","strong","3"); return; } } else { try { img=Wrap.readHTTP(url_access); } catch(e) { try{err.out("http: "+e.message);}catch(e){return;} } if(event_IE_Quit) return; img = img[0]; } switch( b2h(img,0,2) ) { case "FFD8" : fext = ".jpg"; break; case "8950" : fext = ".png"; break; case "4749" : fext = ".gif"; break; case "424D" : fext = ".bmp"; break; default : fext = ".dat"; } //if(args.imgonly && fext==".dat") {outln("Skip: imgではありません","strong","3"); return;} hash = encode(md5(img)); if(f=ImageHashFile.search(hash)) {outln("Skip: 同hash値のファイル("+f+")があります","strong","3");} else if (SearchNGFile(hash)) {outln("Skip: NGFiles.txtで検閲されました","strong","3");} else { fname=Wrap.newfile(args.outimg, vchfile, url_access, fext); try{ saveBinaryFile(args.outimg+fname,img); outln(fname,"strong","3"); } catch(e){ outln(fname+" --- 失敗"+e.message,"strong","3"); } ImageHashFile.append(hash,fname); } return; } function deleteVchFile(vwCacheDir, vchFile) { if(fso.FileExists(vwCacheDir+vchFile)) { try{ fso.DeleteFile(vwCacheDir+vchFile); outln(vchFile+" --- 削除","strong","3"); } catch(e) { outln(vchFile+" --- 削除できません","strong","3"); } } else { outln2("既存ファイルなし"); } return; } function getVchInfo(f) { var s="", n, m; n = bytes2hex(loadBinaryFile(f, 4)); m = parseInt(hexReverseByteOrder(n),16); if(!isNaN(m)) s = loadTextFile(f, m, 4); return s; } function VCH() { var data = []; this.putItem = function(s,d) { if(d) data.push(s+"="+d); } this.getAll = function() { var r=data.join("\r\n"); return r ? r+"\r\n" : ""; } } function hexReverseByteOrder(s) { var i,ss=""; for(i=0; i/, isNGAddrs : /^.*?<>(.*?)<>/ , isNGID : /^.*?<>.*?<>(.*?)<>/, isNGWords : /^.*?<>.*?<>.*?<>(.+?)<>/ , isNGBE : /^.*?<>.*?<>.*? BE:(\d+).*?<>/ }; if(args.res) { try { urls = loadTextFile(args.res[0]) } catch(e) { throw new Error("datファイルが読み込めません: "+e.message); } // datにtitleが埋め込まれてない場合もある title = (urls.match(/^.*?<>.*?<>.*?<>.*?<>(.*)\r?$/m)||[])[1]; offset=0; urls = urls.split(/\r?\n/); if(args.res[1]) { offset = args.res[1]-1; ln = 0; delNo = offset; if(args.res[2]) { delNo += args.res[2]; ln = urls.length-delNo; } if(ln>0) urls.splice(delNo, ln); if(args.res[1]>1) urls.splice(0,args.res[1]-1); } if(!NO_ABONE) abone = new Abone(args.res[0].replace(/\.dat$/,".abn")); for(i=0;i=0) { if(r<4) urls[i] = ""; break; } } if(r<0) { //NGxxにマッチしなかった場合のみNGExを判定する r = abone.isNGEx(urls[i], args.link, title); if(r>=0 && r<4) urls[i] = ""; } } replaceStrTxt = new ReplaceStrTxt(); if(urls[i]) { //ReplaceStr.Txtによるテキスト変換 urls[i] = urls[i].replace(/^.*?<>.*?<>.*?<>(.*?)<>.*$/,"$1"); if(urls[i]) urls[i] = replaceStrTxt.execute(urls[i],args.link,title); } } urls = urls.join("\n").replace(/&/g,"&"); abone = replaceStrTxt = null; } else { urls = args.range; } urls = urls.replace(/h?(ttps?:\/\/)/g,"h$1"); var re = (args.httpsonly) ? /https:\/\/[-.a-zA-Z0-9]+(?::\d+)?\/[-_.!~*'a-zA-Z0-9;/?:@&=+$,%#\[\]]+/g : /https?:\/\/[-.a-zA-Z0-9]+(?::\d+)?\/[-_.!~*'a-zA-Z0-9;/?:@&=+$,%#\[\]]+/g; return urls.match(re); } function main() { var i, url; if(!args.abn) NO_ABONE = true; trace = args0.Exists("log") ? new Trace(args0.Item("log")) : function(){}; if(args0.Exists("i")) { if(CSCRIPT) Wrap.out2 = _out2_console; else ie = new IE(); } if (USING_CURL) { CURL_PATH = replaceEnv(CURL_PATH).replace(/[^\\\/]$/,"$&\\"); if(!fso.FileExists(CURL_PATH+CURL_EXE)) err.popup("File Not Found - "+CURL_PATH+CURL_EXE); cURL = new CURL(); Wrap.readHTTP = cURL.readHTTP; } if(USING_GZIP||USING_7Z) { if(!USING_GZIP) { GZIP_EXE = GZIP_EXE_7Z; GZIP_ARGS = GZIP_ARGS_7Z; } GZIP_PATH = replaceEnv(GZIP_PATH).replace(/[^\\\/]$/,"$&\\"); if(!fso.FileExists(GZIP_PATH+GZIP_EXE)) err.popup("File Not Found - "+GZIP_PATH+GZIP_EXE); } Wrap.initialize(); trace("--- start ---",1);trace("",1); if(args.outimg) { path(args.outimg); ImageHashFile = new imageHashFile(args.outimg); } if(args.rebuild) { ImageHashFile.rebuild(); } else { if(ini.UseViewCache=="1") { if(!args.range && !args.res) { Wrap.genVwCache(args.url, 0x3f); } else { url = Wrap.makeURLs(); if(url) { for(i=0; i