Beispiel #1
0
        public void WebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            //throw new NotImplementedException();
            mshtml.HTMLDocument           doc  = webBrowser.Document as mshtml.HTMLDocument;
            mshtml.IHTMLElementCollection coll = (mshtml.IHTMLElementCollection)(doc.getElementsByTagName("button"));
            mshtml.IHTMLElement           coll_id_start_explorer = (mshtml.IHTMLElement)(doc.getElementById("id_start_explorer"));
            mshtml.IHTMLElement           coll_id_start_dialog   = (mshtml.IHTMLElement)(doc.getElementById("id_start_dialog"));

            // https://codevomit.wordpress.com/2015/06/15/wpf-webbrowser-control-part-2/

            /*
             * foreach (mshtml.IHTMLElement obj in coll)
             * {
             *  HTMLButtonElementEvents_Event htmlButtonEvent = obj as HTMLButtonElementEvents_Event;
             *  htmlButtonEvent.onclick += clickElementHandler;
             * }
             * //*/

            if (coll_id_start_dialog != null)
            {
                HTMLButtonElementEvents_Event htmlButtonEvent = coll_id_start_dialog as HTMLButtonElementEvents_Event;
                htmlButtonEvent.onclick += start_dialog;
            }
            if (coll_id_start_explorer != null)
            {
                HTMLButtonElementEvents_Event htmlButtonEvent = coll_id_start_explorer as HTMLButtonElementEvents_Event;
                htmlButtonEvent.onclick += start_explorer;
            }
        }
Beispiel #2
0
        public static String Search(string name)
        {
            buffer1 = new mshtml.HTMLDocument();
            buffer2 = (mshtml.IHTMLDocument2)buffer1;
            Console.WriteLine("Downloading search page for: {0}", name);
            string Data = Storage.wc.DownloadString($"https://vidstreaming.io/search.html?keyword={name}");

            buffer2.write(Data); // Write all the data to buffer1 so that we can enumerate it.
            mshtml.IHTMLElementCollection collection;
            Console.WriteLine("Searching for video-block");
            collection = buffer1.getElementsByTagName("li"); //Get all collections with the <li> tag.
            foreach (mshtml.IHTMLElement obj in collection)
            {
                if (obj.className == "video-block " || obj.className == "video-block click-hover") //if the element has a classname of "video-block " then we are dealing with a show.
                {
                    Console.WriteLine("Found video-block!");
                    node = obj; // set node to object.
                    break;      // escape the foreach loop.
                }
            }
            Expressions.vidStreamRegex = new Regex(Expressions.searchVideoRegex); // Don't say anything about parsing html with REGEX. This is a better than importing another library for this case.
            if (node == null)
            {
                return("E");
            }
            Match m = Expressions.vidStreamRegex.Match(node.innerHTML);

            return(m.Groups.Count >= 1 ? "https://vidstreaming.io" + m.Groups[1].Value : "E");
        }
Beispiel #3
0
        //해당 ID와 PW로 로그인하기
        public void loginMethod()
        {
            dataGridView1.ClearSelection();

            dataGridView1.Rows[nextRowIndex].Selected = true;

            string id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
            string pw = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();

            inputId(id);
            inputPassword(pw);

            mshtml.HTMLDocument dd = ie.Document;
            var divs = dd.getElementsByTagName("div");

            foreach (IHTMLElement div in divs)
            {
                string divInnterHtml = div.innerText;
                if (divInnterHtml != null && divInnterHtml.Equals("로그인"))
                {
                    Console.WriteLine("로그인 버튼 클릭");
                    div.click();

                    Thread.Sleep(5000);

                    mshtml.HTMLDocument dda = ie.Document;

                    var alertP = dda.getElementById("slfErrorAlert");

                    if (alertP == null)
                    {
                        //로그인 성공

                        FileStream fileStream = new FileStream(filePath, FileMode.Append, FileAccess.Write);

                        string       strData      = id + " " + pw;
                        StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.UTF8);
                        streamWriter.WriteLine(strData);
                        streamWriter.Close();

                        fileStream.Close();
                        return;
                    }
                    //else
                    //{
                    //    FileStream fileStream = new FileStream(filePath, FileMode.Append, FileAccess.Write);

                    //    string strData = id + " " + pw;
                    //    StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.UTF8);
                    //    streamWriter.WriteLine(strData);
                    //    streamWriter.Close();

                    //    fileStream.Close();
                    //    //로그인 실패
                    //    return;

                    //}
                }
            }
        }
        /// <summary>
        /// 挑入网页加载完毕监听
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Pickwebbrowser_LoadCompleted(object sender, NavigationEventArgs e)
        {
            string uri = pickWebBrowser.Source.ToString();

            if (pickurl.IndexOf(uri) > -1)
            {
                //页面加载完毕执行挑入
                IHTMLDocument2      pickdoc = (IHTMLDocument2)pickWebBrowser.Document;
                IHTMLWindow2        pickwin = (IHTMLWindow2)pickdoc.parentWindow;
                mshtml.HTMLDocument htmlDoc = pickWebBrowser.Document as mshtml.HTMLDocument;
                var head   = htmlDoc.getElementsByTagName("head").Cast <HTMLHeadElement>().First();
                var script = (IHTMLScriptElement)htmlDoc.createElement("script");
                script.src = "https://demo.22com.cn/crm/json2.js";
                head.appendChild((IHTMLDOMNode)script);
                InjectJs inject = new InjectJs(this.pickWebBrowser);
                Thread   thr    = new Thread(() =>
                {
                    //这里还可以处理些比较耗时的事情。
                    Thread.Sleep(1000);//延时10秒
                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        pickwin.execScript(inject.getOverridePickInJs(), "javascript");
                        pickwin.execScript("_shy_.alert_close();", "javascript");//关闭弹窗JS
                        pickwin.execScript("selectOpp.getWidget('').select(0,true);", "javascript");
                        pickwin.execScript("overrDoPick()", "javascript");
                    }));
                });
                thr.Start();
            }
        }
Beispiel #5
0
        public static String extractDownloadUri(string episodeUri)
        {
            Console.WriteLine("Extracting Download URL for {0}", episodeUri);
            WebClient wc   = new WebClient();
            string    Data = wc.DownloadString(episodeUri);

            buffer3 = new mshtml.HTMLDocument();
            wc.Dispose();
            buffer3.designMode = "off";
            buffer4            = (mshtml.IHTMLDocument2)buffer3;
            buffer4.write(Data); // beware the hang.
            Expressions.vidStreamRegex = new Regex(Expressions.videoIDRegex);
            IHTMLElementCollection col = buffer3.getElementsByTagName("IFRAME");
            Match  match;
            string id = null;

            foreach (IHTMLElement elem in col)
            {
                match = Expressions.vidStreamRegex.Match(elem.getAttribute("src"));
                if (match.Success)
                {
                    id = match.Groups[0].Value;
                    break;
                }
                else
                {
                    return(null);
                }
            }
            col = null;
            buffer3.clear();
            buffer4.clear();

            Task <String> response = Storage.client.GetStringAsync($"https://vidstreaming.io/ajax.php?id={id}");

            Expressions.vidStreamRegex = new Regex(Expressions.downloadLinkRegex);
            match = Expressions.vidStreamRegex.Match(response.Result);
            if (match.Success)
            {
                string ursTruly = match.Groups[0].Value.Replace("\\", string.Empty);
                int    ids      = Extensions.indexOfEquals(ursTruly) + 1;
                if (ursTruly.Contains("goto.php"))
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ursTruly);
                    request.AutomaticDecompression = DecompressionMethods.GZip;
                    WebResponse res = request.GetResponse();
                    string      s   = res.ResponseUri.ToString();
                    return(s);
                }
                else
                {
                    return(ursTruly);
                }
            }
            return(null);
        }
Beispiel #6
0
        public void InjectJSScript(mshtml.HTMLDocument doc, IHTMLScriptElement JavaSCript)
        {
            IHTMLElementCollection nodes = doc.getElementsByTagName("head");

            foreach (IHTMLElement elem in nodes)
            {
                var head = (HTMLHeadElement)elem;
                head.appendChild((IHTMLDOMNode)JavaSCript);
            }
        }
Beispiel #7
0
        private void Stop_Play_Click(object sender, RoutedEventArgs e)
        {
            playOn = !playOn;
            if (playOn)
            {
                Stop_Play.Content = FindResource("Play");
            }
            else
            {
                Stop_Play.Content = FindResource("Stop");
            }

            SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
            IntPtr handle = GetForegroundWindow();

            foreach (SHDocVw.WebBrowser IE in shellWindows)
            {
                if (IE.HWND.Equals(handle.ToInt32()))
                {
                    doc = IE.Document as mshtml.HTMLDocument;
                }
            }
            if (doc != null)
            {
                mshtml.IHTMLElementCollection elemColl = null;
                elemColl = doc.getElementsByTagName("button") as mshtml.IHTMLElementCollection;

                foreach (mshtml.IHTMLElement elem in elemColl)
                {
                    if (elem.getAttribute("class") != null)
                    {
                        if (elem.className == "ytp-play-button ytp-button")
                        {
                            elem.click();
                            break;
                        }
                    }
                }
            }
        }
Beispiel #8
0
        private IEnumerable <string> ParseProxies(mshtml.HTMLDocument document)
        {
            foreach (var column in document.getElementsByTagName("td").OfType <IHTMLElement>())
            {
            }

            /*foreach (IHTMLElement element in document.body.children)
             * {
             *  if (element.tagName == "table")
             *  {
             *
             *  }
             * }*/
            return(null);
        }
Beispiel #9
0
        void findByKeyword(string keyword)
        {
            mshtml.HTMLDocument dd = ie.Document;
            var buttons            = dd.getElementsByTagName("button");

            foreach (IHTMLElement button in buttons)
            {
                string buttonInnerHtml = button.innerText;
                if (buttonInnerHtml != null && buttonInnerHtml.Equals(keyword))
                {
                    button.click();
                    return;
                }
            }
        }
        /// <summary>
        /// 页面加载完成
        /// 注入js
        /// </summary>
        private void replaceJs()
        {
            mshtml.HTMLDocument htmlDoc = webBrower.Document as mshtml.HTMLDocument;
            var head   = htmlDoc.getElementsByTagName("head").Cast <HTMLHeadElement>().First();
            var script = (IHTMLScriptElement)htmlDoc.createElement("script");

            script.src = "https://demo.22com.cn/crm/json2.js";
            head.appendChild((IHTMLDOMNode)script);
            getWinScript();
            if (inject == null)
            {
                inject = new InjectJs(this.webBrower);
            }
            win.execScript(inject.getOverrideJs(), "javascript");//替换JS
        }
Beispiel #11
0
        //로그인 버튼 클릭
        public void loginButtonClick()
        {
            mshtml.HTMLDocument dd = ie.Document;
            var buttons            = dd.getElementsByTagName("button");

            foreach (IHTMLElement button in buttons)
            {
                string buttonInnerHtml = button.innerText;

                if (buttonInnerHtml != null && buttonInnerHtml.Equals("로그인"))
                {
                    button.click();
                    return;
                }
            }
        }
Beispiel #12
0
        private void InjectDisableScript()
        {
            mshtml.HTMLDocument doc2 = (HTMLDocument)ViewWebBrowser.Document;
            IHTMLScriptElement  scriptErrorSuppressed = (IHTMLScriptElement)doc2.createElement("SCRIPT");

            scriptErrorSuppressed.type = "text/javascript";
            scriptErrorSuppressed.text = DisableScriptError;

            IHTMLElementCollection nodes = mDocument.getElementsByTagName("head");

            foreach (IHTMLElement elem in nodes)
            {
                HTMLHeadElement head = (HTMLHeadElement)elem;
                head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
            }
        }
Beispiel #13
0
        //첫번째 _8-yf5가 좋아요, 두번째가 댓글달기.

        //좋아요 버튼 클릭
        private void likeButton()
        {
            log.Debug("likeButton method start");
            mshtml.HTMLDocument document = ie.Document;
            var svgs = document.getElementsByTagName("svg");

            foreach (IHTMLElement svg in svgs)
            {
                string svgClassName = svg.className.Trim();

                if (svgClassName != null && svgClassName.Equals("_8-yf5"))
                {
                    svg.click();
                    log.Debug("likeButton method end");
                    return;
                }
            }
        }
Beispiel #14
0
        private void inputPassword(string pwString)
        {
            mshtml.HTMLDocument dd = ie.Document;
            var inputs             = dd.getElementsByTagName("input");

            foreach (IHTMLElement input in inputs)
            {
                string inputName = input.getAttribute("name");
                if (!string.IsNullOrEmpty(inputName) && inputName.Equals("password"))
                {
                    ((IHTMLElement2)input).focus();
                    Thread.Sleep(1000);
                    //  ((IHTMLElement2)input).focus();
                    break;
                }
            }
            inputString(pwString);
            Thread.Sleep(1000);
        }
Beispiel #15
0
        //댓글 버튼 클릭
        private void replyButton()
        {
            mshtml.HTMLDocument document = ie.Document;
            var svgs  = document.getElementsByTagName("svg");
            int count = 0;

            foreach (IHTMLElement svg in svgs)
            {
                string svgClassName = svg.className.Trim();

                if (svgClassName != null && svgClassName.Equals("_8-yf5"))
                {
                    if (count == 1)
                    {
                        svg.click();
                        return;
                    }
                }
                count++;
            }
        }
Beispiel #16
0
        private void inputId(string idString)
        {
            mshtml.HTMLDocument dd = ie.Document;
            var inputs             = dd.getElementsByTagName("input");

            foreach (IHTMLElement input in inputs)
            {
                string inputName = input.getAttribute("name");

                //  if (inputName != null) Console.WriteLine("1" + inputName);
                if (!string.IsNullOrEmpty(inputName) && inputName.Equals("username"))
                {
                    ((IHTMLElement2)input).focus();

                    Thread.Sleep(1000);
                    break;
                }
            }

            inputString(idString);
            Thread.Sleep(1000);
            Console.WriteLine("inputID complete");
        }
        private void Webbrowser_LoadCompleted(object sender, NavigationEventArgs e)
        {
            try
            {
                if (!_isRun)
                {
                    // Get the website document first
                    mshtml.HTMLDocument document = (mshtml.HTMLDocument)Webbrowser.Document;

                    // Set the username
                    var username = document.getElementById("ap_email");
                    if (username != null)
                    {
                        username.innerText = "*****@*****.**";
                    }
                    // Now for amazon we need to click first
                    var theElementCollection = document.getElementsByTagName("input");
                    if (theElementCollection != null)
                    {
                        foreach (var el in theElementCollection)
                        {
                            if (((HTMLDTElement)el).id == "continue")
                            {
                                ((HTMLDTElement)el).click();
                            }
                        }
                    }

                    // Let the page load
                    System.Threading.Thread.Sleep(2000);

                    // Get the newly loaded document
                    document = (mshtml.HTMLDocument)Webbrowser.Document;

                    // Fill in password
                    var pw = document.getElementById("ap_password");
                    if (pw != null)
                    {
                        pw.innerText = "xd";
                    }

                    theElementCollection = document.getElementsByTagName("input");
                    if (theElementCollection != null)
                    {
                        // Click login button
                        foreach (var el in theElementCollection)
                        {
                            if (((HTMLDTElement)el).id == "signInSubmit")
                            {
                                ((HTMLDTElement)el).click();
                            }
                        }
                    }
                    _isRun = true;
                }
            }
            catch (Exception ex)
            {
                Communication.InformUser("Page couldn't be loaded.");
            }
        }
Beispiel #18
0
        // search input complete
        void Keyboard_Closed(object sender, EventArgs e)
        {
            SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
            IntPtr handle = GetForegroundWindow();

            foreach (SHDocVw.WebBrowser IE in shellWindows)
            {
                if (IE.HWND.Equals(handle.ToInt32()))
                {
                    doc = IE.Document as mshtml.HTMLDocument;
                }
            }
            if (doc != null)
            {
                // Document 속성 읽기
                Uri    uri  = new Uri(doc.url);
                String host = uri.Host;

                if (host.Contains(naver))
                {
                    //검색어 셋팅
                    IHTMLElement query = doc.getElementsByName("query").item("query", 0);
                    query.setAttribute("value", System.Windows.Clipboard.GetText());

                    //네이버검색버튼 : search_btn
                    doc.getElementById("search_btn").click();
                }
                else if (host.Contains(search_naver))
                {
                    mshtml.IHTMLElementCollection elemColl = null;
                    elemColl = doc.getElementsByTagName("button") as mshtml.IHTMLElementCollection;

                    foreach (mshtml.IHTMLElement elem in elemColl)
                    {
                        if (elem.getAttribute("class") != null)
                        {
                            if (elem.className == "bt_search spim")
                            {
                                IHTMLElement query = doc.getElementsByName("query").item("query", 0);
                                //검색어 셋팅
                                query.setAttribute("value", System.Windows.Clipboard.GetText());
                                elem.click();
                                break;
                            }
                        }
                    }
                }
                else if (host.Contains(daum) || host.Contains(google))
                {
                    IHTMLElement q = doc.getElementsByName("q").item("q", 0);
                    q.setAttribute("value", System.Windows.Clipboard.GetText());

                    IHTMLFormElement form_google = doc.forms.item(Type.Missing, 0);
                    form_google.submit();
                }

                else
                {
                    System.Windows.MessageBox.Show("naver google daum 쓰세요");
                }
            }
        }
Beispiel #19
0
        public static String FindAllVideos(string link, Boolean dwnld, [Optional] String fileDestDirectory)
        {
            Console.WriteLine($"Found link: {link}\nDownloading Page...");
            string Data = Storage.wc.DownloadString(link);

            buffer1 = new mshtml.HTMLDocument();
            buffer2 = (mshtml.IHTMLDocument2)buffer1;
            buffer2.write(Data); //(Again) write data to buffer1 so we can enumerate.
            mshtml.IHTMLElementCollection collection;
            Console.WriteLine("Searching for Videos");
            collection = buffer1.getElementsByTagName("li");            // split by the tag <li>
            string mainVidUri = link.Split('/').Last().TrimIntegrals(); // Trim trailing numbers.

            Expressions.vidStreamRegex = new Regex(String.Format("(?<=<A href=\"/videos/{0}).*?(?=\">)", mainVidUri));

            List <String> videoUrls = new List <string>();
            string        val       = null;
            Match         regMax;
            int           id = 0;

            Console.WriteLine(collection.length);
            foreach (mshtml.IHTMLElement obj in collection) // Search for all elements containing "video-block " as a class name and matches them to our trimmed url.
            {
                if (obj.className == "video-block " || obj.className == "video-block click_hover")
                {
                    regMax = Expressions.vidStreamRegex.Match(obj.innerHTML);
                    if (regMax.Success)
                    {
                        val = "https://vidstreaming.io/videos/" + mainVidUri + regMax.Groups[0].Value;
                        Console.WriteLine("Found a video-block! Adding to list, {0} |", val);
                        videoUrls.Add(val);
                        switch (dwnld)
                        {
                        case true:    //case 0:
                        {
                            Download.FileDest = fileDestDirectory + $"\\{id + 1}_{Storage.Aniname}.mp4";
                            if (Program.multTthread)
                            {
                                if (!Download.dwS && Download.downloadLinks.Length >= 1)
                                {
                                    Download.QueueDownload(val);
                                    Download.StartDownload();
                                }
                                else
                                {
                                    Download.QueueDownload(val);
                                }
                            }
                            else
                            {
                                Download.GetM3u8Link(val);
                            }
                            id++;
                            continue;
                            //break;
                        }

                        case false:
                        {
                            System.IO.File.AppendAllText($"{fileDestDirectory}_VDLI_temp.txt", $"\n{val}");
                            continue;
                        }

                        default:
                            continue;
                            //break;
                        }
                    }
                }
            }
            return(dwnld ? null : $"{fileDestDirectory}_VDLI_temp.txt");
        }
        private void Webbrowser_LoadCompleted(object sender, NavigationEventArgs e)
        {
            try
            {
                if (!_isRun && _isLoginAttempt)
                {
                    // Get the website document first
                    mshtml.HTMLDocument document = (mshtml.HTMLDocument)Webbrowser.Document;

                    // Set the username
                    var username = document.getElementById("ap_email");
                    if (username != null)
                    {
                        username.innerText = _username;
                    }
                    // Now for amazon we need to click first
                    var theElementCollection = document.getElementsByTagName("input");
                    if (theElementCollection != null)
                    {
                        foreach (var el in theElementCollection)
                        {
                            if (((HTMLDTElement)el).id == "continue")
                            {
                                ((HTMLDTElement)el).click();
                            }
                        }
                    }

                    // Let the page load
                    System.Threading.Thread.Sleep(2000);

                    // Get the newly loaded document
                    document = (mshtml.HTMLDocument)Webbrowser.Document;

                    // Fill in password
                    var pw = document.getElementById("ap_password");
                    if (pw != null)
                    {
                        pw.innerText = ByteHelper.ByteArrayToString(CryptMemoryProtection.DecryptInMemoryData(_encryptedPassword));
                    }

                    theElementCollection = document.getElementsByTagName("input");
                    if (theElementCollection != null)
                    {
                        // Click login button
                        foreach (var el in theElementCollection)
                        {
                            if (((HTMLDTElement)el).id == "signInSubmit")
                            {
                                ((HTMLDTElement)el).click();
                            }
                        }
                    }

                    Navigation_Textblock.Text = Webbrowser.Source.AbsoluteUri;
                    _isRun = true;
                }
            }
            catch (Exception ex)
            {
                Communication.InformUser("Couldn't log into page.");
                Logger.log.Error($"Couldn't login to page: {ex}");
                Close();
            }
        }