static void Main(string[] args) { if (args.Count() < 1) { echo(MESSAGE); exit(); } if (my.is_string_like(args[0], "https://") || my.is_string_like(args[0], "http://")) { URL = args[0]; } if (!my.is_string_like(URL, "https://") && !my.is_string_like(URL, "http://")) { echo(MESSAGE); exit(); } string data = my.b2s(my.file_get_contents(URL)); //echo(data); List <string> preScripts = new List <string>(); //preScripts.Add("$=function(){};"); preScripts.Add("var adsbygoogle=null;"); //preScripts.Add("var window=null;"); preScripts.Add("var localStorage={'getItem':function(){return '';}, 'setItem':function(a,b){} };"); preScripts.Add("var y='46';"); preScripts.Add("function spp(){};"); preScripts.Add("var WWWWWTTTTTFFFFF='';"); preScripts.Add("var document='';"); //preScripts.Add("function $(p){};"); preScripts.Add("function loadingpage(p){};"); preScripts.Add("function initcomment(p){};"); preScripts.Add("function mm(p){return (parseInt((p-1)/10)%10)+(((p-1)%10)*3)};"); preScripts.Add("function nn(n){return n<10?'00'+n:n<100?'0'+n:n;};"); preScripts.Add("function su(a,b,c){var e=(a+'').substring(b,b+c);return (e);};"); preScripts.Add("function lc(l){ if (l.length != 2) return l; var az = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"; var a = l.substring(0,1); var b = l.substring(1, 2); if (a == \"Z\") return 8000 + az.indexOf(b); else return az.indexOf(a) * 52 + az.indexOf(b); };"); preScripts.Add("function request(queryStringName){var returnValue=\"\";var URLString=new String(document.location);var serachLocation=-1;var queryStringLength=queryStringName.length;do{serachLocation=URLString.indexOf(queryStringName+\"\\= \");if (serachLocation!=-1){if ((URLString.charAt(serachLocation-1)=='?') || (URLString.charAt(serachLocation-1)=='&')){URLString=URLString.substr(serachLocation);break;}URLString=URLString.substr(serachLocation+queryStringLength+1);}}while (serachLocation!=-1)if (serachLocation!=-1){var seperatorLocation=URLString.indexOf(\" & \");if (seperatorLocation==-1){returnValue=URLString.substr(queryStringLength+1);}else{returnValue=URLString.substring(queryStringLength+1,seperatorLocation);} }return returnValue;}"); string ch = ""; if (!my.is_string_like(URL, "ch=")) { ch = "1"; } else { ch = my.explode("-", my.explode("ch=", URL)[1])[0];//第幾回 } //preScripts.Add("ch=" +ch); //merge all scripts List <string> AllJS = new List <string>(); var mjs = my.explode("<script>", data); for (int i = 6; i < mjs.Count(); i++) { var _m = my.explode("</script>", mjs[i]); AllJS.Add(_m[0]); } //var mScripts = my.explode("<script>", data)[7]; //string scripts = my.explode("</script>", mScripts)[0].Trim(); string scripts = my.implode("\n\n ", AllJS); scripts = scripts.Replace("var pi=ch", "ch=" + ch + ";var pi=ch"); //scripts = scripts.Replace("\n", " ").Replace("\r", " "); //echo("\nCounts:" + my.explode("<script>", data).Count().ToString() + "\n"); //echo(scripts); //exit(); scripts = scripts.Replace("document.getElementById(e)", "e"); scripts = scripts.Replace("}var", "};var"); //scripts = scripts.Replace("ge('TheImg').src=", "WWWWWTTTTTFFFFF="); scripts = scripts.Replace(").src=", ");WWWWWTTTTTFFFFF="); //scripts = scripts.Replace(";", ";\n"); //scripts = scripts.Replace(";", ";\n"); //scripts = scripts.Replace("adsbygoogle", "//adsbygoogle"); preScripts.Add(scripts); preScripts.Add("ps+\"___\"+\"https:\"+WWWWWTTTTTFFFFF;"); //preScripts.Add("swtvv;"); string sc = my.implode("\n", preScripts); sc = sc.Replace("; ", "; \n"); sc = sc.Replace("(adsbygoogl", "//(adsbygoogl"); //echo(sc); //exit(); sc = sc.Replace("if (localStorage.getItem(\"imgmode\")" + my.get_between(sc, "if (localStorage.getItem(\"imgmode\")", "document.getElementById(\"barcodeimg\");"), ""); sc = sc.Replace("document.writeln(\"<scr" + my.get_between(sc, "document.writeln(\"<scr", "ipt>\");") + "ipt>\");", ""); sc = sc.Replace("document.writeln(\"<scr" + my.get_between(sc, "document.writeln(\"<scr", "ipt>\");") + "ipt>\");", ""); sc = sc.Replace("document.getElementById(\"barcodeimg\");", ""); sc = sc.Replace("(function() {" + my.get_between(sc, "(function() {", "})();") + "})();", ""); //my.file_put_contents("sc.txt", sc); string finalData = EvalJScript(sc).ToString().Trim(); //echo(sc); //echo(finalData); //exit(); var m = my.explode("___", finalData); int pages = Convert.ToInt32(m[0]); string output = "Totals:" + pages.ToString() + "\n"; string t = m[1].Replace("/001_", "/{PAGE}_"); //echo(t); //exit(); for (int i = 1; i <= pages; i++) { //取得 WWWWWTTTTTFFFFF=...... 至 '.jpg'; //WWWWWTTTTTFFFFF='//img'+su(yvdnl, 0, 1)+'.8comic.com/'+su(yvdnl,1,1)+'/'+ti+'/'+iyjco+'/'+ nn(p)+'_'+su(qvjme,mm(p),3)+'.jpg'; //string d = t.Replace("{PAGE}", i.ToString().PadLeft(3, '0')); //output += d + "\n"; var imgPath = "\"https:\"+" + my.get_between(sc, ";WWWWWTTTTTFFFFF=", ";"); //echo(imgPath); //exit(); var _sc = sc + "\n" + imgPath.Replace("(p)", "(" + i + ")") + ";"; output += EvalJScript(_sc).ToString() + "\n"; } echo(output); }
private void button1_Click(object sender, EventArgs e) { button1.Enabled = false; button1.Text = "載入中..."; string URL = downloadURL.Text; if (!Regex.IsMatch(URL, @"^https://www.comico.com.tw/\d*/")) { MessageBox.Show("網址不對..."); button1.Enabled = true; button1.Text = "載入"; return; } string orin_URL = URL; //從已知的 tabs 找 tooltips,如果一樣,就跳過,直接跳到那頁 for (int i = 0, max_i = tabControl1.TabPages.Count; i < max_i; i++) { string tipname = tabControl1.TabPages[i].ToolTipText; if (tipname == orin_URL) { tabControl1.SelectedIndex = i; button1.Enabled = true; button1.Text = "載入"; return; } } string orin_data = my.b2s(my.file_get_contents(orin_URL)); //my.file_put_contents(PWD + "\\log.txt", orin_data); string orin_NAME = my.get_between(orin_data, "<meta property=\"og:title\" content=\"", "|"); orin_NAME = orin_NAME.Replace("。", ""); URL = URL.Replace("https://", ""); var m = my.explode("/", URL); string id = m[1]; string jsonURL = "https://www.comico.com.tw/api/getArticleList.nhn"; string data = my.b2s(my.file_get_contents_post(jsonURL, "titleNo=" + id)); //my.file_put_contents(PWD + "\\log.txt", data); var jd = my.json_decode(data); List <ConcurrentDictionary <string, string> > ldt = new List <ConcurrentDictionary <string, string> >(); for (int i = 0; i < jd[0]["result"]["list"].Count(); i++) { var d = new ConcurrentDictionary <string, string>(); d["URL"] = jd[0]["result"]["list"][i]["articleDetailUrl"].ToString(); d["NAME"] = jd[0]["result"]["list"][i]["subtitle"].ToString(); d["URL_IMG"] = jd[0]["result"]["list"][i]["imgUrl"].ToString(); ldt.Add(d); } Console.WriteLine(my.json_encode(ldt)); // Gets the controls collection for tabControl1. // Adds the tabPage1 to this collection. var tab = new TabPage("item_" + orin_NAME); tab.ToolTipText = orin_URL; DataGridView dgv = new DataGridView(); //dgv.AutoGenerateColumns = false; //這啥 dgv.AllowUserToAddRows = false; //不能允許使用者自行調整 dgv.RowHeadersVisible = false; //左邊空欄移除 dgv.Dock = DockStyle.None; //自動展開到最大 dgv.AllowDrop = false; dgv.ReadOnly = true; dgv.Name = "PAGE_" + tabControl1.TabPages.Count.ToString(); SOURCES[dgv.Name] = new ConcurrentDictionary <string, object>(); SOURCES[dgv.Name]["NAME"] = orin_NAME; SOURCES[dgv.Name]["URL"] = orin_URL; dgv.Width = 650; dgv.Height = 500; //dgv.Columns.Add("ID", "序號"); //dgv.Columns.Add("NAME", "話"); //dgv.Columns.Add("URL", "URL"); dgv.Location = new Point(0, 50); DataTable dtt = new DataTable(); dtt.Columns.Add("ID"); dtt.Columns.Add("NAME"); dtt.Columns.Add("URL"); dtt.Columns.Add("STATUS"); for (int i = 0, max_i = ldt.Count; i < max_i; i++) { dtt.Rows.Add(); int LAST_ID = dtt.Rows.Count - 1; dtt.Rows[LAST_ID]["ID"] = (i + 1).ToString(); dtt.Rows[LAST_ID]["NAME"] = ldt[i]["NAME"]; dtt.Rows[LAST_ID]["URL"] = ldt[i]["URL"]; dtt.Rows[LAST_ID]["STATUS"] = "待命"; } dgv.DataSource = dtt; SOURCES[dgv.Name]["回"] = dtt; //加一個標題 var labelTitle = new System.Windows.Forms.Label(); labelTitle.Text = orin_NAME + " (共 " + ldt.Count.ToString() + " 回)"; labelTitle.Width = 650; labelTitle.Font = new Font("微軟正黑體", 16); labelTitle.Location = new Point(0, 0); //加一個下載的鈕 var btnRun = new System.Windows.Forms.Button(); btnRun.Name = "goBtn - " + dgv.Name; btnRun.Text = "開始下載"; btnRun.Location = new Point(this.Width - btnRun.Width - 50, 0); btnRun.Click += (object s, EventArgs ee) => { //按鈕的程式 //MessageBox.Show(dgv.Name); Button btn = s as Button; string key = my.explode(" - ", btn.Name)[1]; switch (btn.Text) { case "開始下載": { btn.Text = "下載中...(點了取消)"; SOURCES[key]["RUN_THREAD"] = new Thread(() => run(key, btn)); ((Thread)SOURCES[key]["RUN_THREAD"]).Start(); } break; default: { btn.Text = "開始下載"; if (SOURCES[key].Keys.Contains("RUN_THREAD") && SOURCES[key]["RUN_THREAD"] != null) { ((Thread)(SOURCES[key]["RUN_THREAD"])).Abort(); } } break; } }; tab.Controls.Add(labelTitle); tab.Controls.Add(btnRun); tab.Controls.Add(dgv); tab.Text = dgv.Name; tabControl1.TabPages.Add(tab); for (int i = 0; i < dgv.Columns.Count - 1; i++) { dgv.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } dgv.Columns[dgv.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; for (int i = 0; i < dgv.Columns.Count; i++) { int colw = dgv.Columns[i].Width; dgv.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.None; dgv.Columns[i].Width = colw; } button1.Enabled = true; button1.Text = "載入"; tabControl1.SelectedIndex = tabControl1.TabPages.Count - 1; }