Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            InitizationScriptContent();
            DC_File.SetDisharmonyWord();
            CWebBrowserResult.ShowLog(txtLog, "Init DisharmonyWord Done!");

            DC_File.nConfigActionFlag = API.GetCommentAction();
            CWebBrowserResult.ShowLog(txtLog, "CommentAction=" + DC_File.nConfigActionFlag.ToString("X"));

            webBrowser1.ScriptErrorsSuppressed = true;
            HarmoniouWeibo();
        }
Esempio n. 2
0
        public async Task CheckHarmoniousWord(WebBrowser WebBrowser_, string strLink, Action <string> fnShowPtr)
        {
            Action <string> ShowLogPtr = (x) =>
            {
                if ((DC_File.nConfigActionFlag & (int)em_Comment_Action.em_Comment_Action_Show) != 0)
                {
                    fnShowPtr(x);
                }
            };

            bool bExistUnHarmoniousWord = false;

            while (!bExistUnHarmoniousWord)
            {
                ShowLogPtr("Loading Page:" + strLink);
                await Load(WebBrowser_, strLink);

                AddJsContent(WebBrowser_, DC_File.strRoolupScriptContent);

                ShowLogPtr("Rolling down to Bottom");
                await RollupToButtom(WebBrowser_, 5);

                // click more comment document.getElementsByClassName("WB_cardmore S_txt1 S_line1 clearfix")[0].click()
                while (ExistMoreCommentLink_NewPage(WebBrowser_))
                {
                    ShowLogPtr("Show More Comment!");
                    ClickMoreCommentLink_NewPage(WebBrowser_);

                    ShowLogPtr("Rolling down to Bottom");
                    await RollupToButtom(WebBrowser_, 2);
                }

                bExistUnHarmoniousWord = true;
                var Vec = getElementsByClassName(WebBrowser_, "div", "WB_text");
                for (int i = 0; i < Vec.Count; i++)
                {
                    string strText       = Vec[i].InnerText;
                    int    nContentIndex = strText.IndexOf(":");
                    if (nContentIndex == -1)
                    {
                        continue;
                    }

                    strText = strText.Substring(nContentIndex + 1);
                    string strResult = DC_File.VecDisharmonyWord.Find((x) => { return(strText.IndexOf(x) != -1); });
                    if (strResult == string.Empty || strResult == null)
                    {
                        continue;
                    }

                    string strWord = new WbAccount()
                    {
                        strName = Vec[i].InnerText.Substring(0, nContentIndex), strComment = strText
                    }.GetText();
                    ShowLogPtr("Exist Bad Word:" + strWord);
                    if ((DC_File.nConfigActionFlag & (int)em_Comment_Action.em_Comment_Action_Confirm) != 0 && MessageBox.Show("Exist UnHarmoniousWord:" + strWord, "Warning", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        continue;
                    }

                    // delete comment
                    if ((DC_File.nConfigActionFlag & (int)em_Comment_Action.em_Comment_Action_Fuck) == 0)
                    {
                        continue;
                    }

                    // document.getElementsByClassName("hover")[i].children[0].children[0].click()
                    ShowLogPtr("Ready Remove Bad Word:" + strWord);
                    if (!await ClickDeleteCommentByIndex(WebBrowser_, i))
                    {
                        break;
                    }
                    // confirm delete
                    ShowLogPtr("Confirm Remove Bad Word:" + strWord);
                    if (!await ConfirmDeleteComment(WebBrowser_))
                    {
                        break;
                    }

                    // contiune loop!
                    bExistUnHarmoniousWord = false;

                    // record comment
                    if ((DC_File.nConfigActionFlag & (int)em_Comment_Action.em_Comment_Action_Save) != 0)
                    {
                        ShowLogPtr("Save Record!");
                        DC_File.AddDisharmonyRecord(strWord);
                    }

                    Vec = getElementsByClassName(WebBrowser_, "div", "WB_text");
                    i   = -1;
                }
            }
        }