Exemplo n.º 1
0
 internal void Class2Form(WebsiteDetail item)
 {
     txtTabTitle.Text           = item.title;
     txtWebsite.Text            = item.url;
     txtCookieJarName.Text      = item.cookiesJar;
     txtNotifKeyword.Text       = item.notificationKeyword;
     chkNotifShowWindow.Checked = item.notificationShowWindow;
     txtNotifIconFilename.Text  = item.notificationIcon;
     chkDontShowStartup.Checked = item.noAtStartup;
 }
Exemplo n.º 2
0
        private void toolStripOpenInGlobal_Click(object sender, EventArgs e)
        {
            WebsiteDetail x = new WebsiteDetail()
            {
                cookiesJar             = "",
                noAtStartup            = false,
                notificationIcon       = "",
                notificationKeyword    = "",
                notificationShowWindow = false,
                title = "child",
                url   = clipboard_url
            };

            add_tab(x);
        }
Exemplo n.º 3
0
        private void toolstripOpenChildTestFingerPrint_Clicked(object sender, EventArgs e)
        {
            WebsiteDetail x = new WebsiteDetail()
            {
                cookiesJar             = "",
                noAtStartup            = false,
                notificationIcon       = "",
                notificationKeyword    = "",
                notificationShowWindow = false,
                title = "test FingerPrint",
                url   = "https://browserleaks.com/canvas"
            };

            add_tab(x);
        }
Exemplo n.º 4
0
        private void toolstripOpenChildTestAgent_Clicked(object sender, EventArgs e)
        {
            WebsiteDetail x = new WebsiteDetail()
            {
                cookiesJar             = "",
                noAtStartup            = false,
                notificationIcon       = "",
                notificationKeyword    = "",
                notificationShowWindow = false,
                title = "test Agent",
                url   = "https://www.whatismybrowser.com/detect/what-is-my-user-agent"
            };

            add_tab(x);
        }
Exemplo n.º 5
0
        private void toolstripOpenChildWebRTC_Clicked(object sender, EventArgs e)
        {
            WebsiteDetail x = new WebsiteDetail()
            {
                cookiesJar             = "",
                noAtStartup            = false,
                notificationIcon       = "",
                notificationKeyword    = "",
                notificationShowWindow = false,
                title = "test WebRTC",
                url   = "https://test.webrtc.org/"
            };

            add_tab(x);
        }
Exemplo n.º 6
0
        private void toolStripOpenInContainer_Click(object sender, EventArgs e)
        {
            CefControl1 user_ctl    = (CefControl1)tabControl1.SelectedTab.Controls[0];
            string      cookies_jar = user_ctl.get_cache_name();

            WebsiteDetail x = new WebsiteDetail()
            {
                cookiesJar             = cookies_jar,
                noAtStartup            = false,
                notificationIcon       = "",
                notificationKeyword    = "",
                notificationShowWindow = false,
                title = "child",
                url   = clipboard_url
            };

            add_tab(x);
        }
Exemplo n.º 7
0
        private void add_tab(WebsiteDetail item)
        {
            TabPage tp = new TabPage(item.title);

            tabControl1.TabPages.Add(tp);

            CefControl1 x = new CefControl1(tabControl1.TabPages.Count - 1, General.cfg.g, item);

            x.StatusChanged += new CefControl1.status_changed(StatusUpdated);
            x.TabText       += new CefControl1.tab_text(TabText);
            x.OpenChild     += new CefControl1.open_child(OpenChildTab);

            x.Dock = DockStyle.Fill;
            tp.Controls.Add(x);

            //CEF start render when is visible
            tabControl1.SelectedIndex = tabControl1.TabPages.Count - 1;
        }
Exemplo n.º 8
0
        private void parse_url_item(WebsiteDetail item, bool add2toolstrip)
        {
            //create instance of CefSharp + add new tab [start]
            if (!item.noAtStartup || !add2toolstrip)
            {
                add_tab(item);
            }
            //create instance of CefSharp + add new tab [end]

            //add to toolstrip open [start]
            if (add2toolstrip)
            {
                ToolStripMenuItem ts = new ToolStripMenuItem();
                ts.Text = item.title;
                toolStripOpen.DropDownItems.Add(ts);
                ts.Click += new System.EventHandler(toolstripOpenChild_Clicked);
            }
            //add to toolstrip open [end]
        }
Exemplo n.º 9
0
        private void OpenChildTab(string url, string cache_dir, bool use_the_same_cookies)
        {
            if (tabControl1.InvokeRequired)
            {
                this.BeginInvoke(new open_child_delegate(OpenChildTab), new object[] { url, cache_dir, use_the_same_cookies });
                return;
            }

            WebsiteDetail x = new WebsiteDetail()
            {
                cookiesJar             = use_the_same_cookies ? cache_dir : "",
                noAtStartup            = false,
                notificationIcon       = "",
                notificationKeyword    = "",
                notificationShowWindow = false,
                title = "child",
                url   = url
            };

            add_tab(x);
        }
Exemplo n.º 10
0
        //public CefControl1(int tabindex, string cache_dir, string url, GeneralSettings gSettings, string notification_keyword, string notification_icon, bool notification_show_window)
        public CefControl1(int tabindex, GeneralSettings gSettings, WebsiteDetail w)
        {
            InitializeComponent();

            this.icon_filepath            = w.notificationIcon;
            this.tabindex                 = tabindex;
            this.cache_dir                = w.cookiesJar;
            this.notification_show_window = w.notificationShowWindow;
            this.externalbrowser          = gSettings.externalbrowser;

            string cache_dir_local = Application.StartupPath + "\\cache\\" + cache_dir;

            this.notification_keyword = w.notificationKeyword.ToLower();

            Directory.CreateDirectory(cache_dir_local);

            if (!Cef.IsInitialized)
            {
                CefSettings settings = new CefSettings();
                settings.UserAgent             = gSettings.agent;
                settings.RootCachePath         = Application.StartupPath + "\\cache\\";
                settings.CachePath             = cache_dir_local;
                settings.PersistSessionCookies = true;

                //fake GPU details - https://stackoverflow.com/questions/55955203/how-to-give-fake-gpu-info-to-site
                //test with https://browserleaks.com/canvas
                if (gSettings.noproxyserver)
                {
                    settings.CefCommandLineArgs.Add("no-proxy-server");
                }

                if (gSettings.disablecanvas)
                {
                    settings.CefCommandLineArgs.Add("disable-reading-from-canvas");
                }

                if (gSettings.disablegpu)
                {
                    settings.CefCommandLineArgs.Add("disable-gpu");
                }

                if (gSettings.disablewebgl)
                {
                    settings.CefCommandLineArgs.Add("disable-webgl");
                }


                if (gSettings.enableWebRTC)
                {
                    settings.CefCommandLineArgs.Add("enable-media-stream", "1");
                }

                //test @
                //https://test.webrtc.org/
                //https://www.vidyard.com/mic-test/


                //Initialize
                Cef.Initialize(settings);

                chrome = new ChromiumWebBrowser(w.url);
                chrome.DownloadHandler = new DownloadHandler();
                chrome.MenuHandler     = new CustomMenuHandler();
            }
            else
            {
                //  https://github.com/cefsharp/CefSharp/wiki/General-Usage#request-context-browser-isolation

                var requestContextSettings = new RequestContextSettings();
                requestContextSettings.CachePath             = cache_dir_local;
                requestContextSettings.PersistSessionCookies = true;

                chrome = new ChromiumWebBrowser(w.url);
                chrome.DownloadHandler = new DownloadHandler();
                chrome.MenuHandler     = new CustomMenuHandler();
                chrome.RequestContext  = new RequestContext(requestContextSettings);
            }

            this.Controls.Add(chrome);

            //https://cefsharp.github.io/api/57.0.0/html/E_CefSharp_OffScreen_ChromiumWebBrowser_TitleChanged.htm
            chrome.TitleChanged += new EventHandler <TitleChangedEventArgs>(this.CefBrowserTitleChanged);


            ////https://stackoverflow.com/a/31156730/1320686

            //chrome.FrameLoadEnd += (sender, args) =>
            //{
            //    // Console.WriteLine("##" + args.Frame.Name);
            //    //Wait for the MainFrame to finish loading
            //    if (args.Frame.IsMain)
            //    {

            //        Console.WriteLine("***" + args.Frame.Name);
            //        //   args.Frame.ExecuteJavaScriptAsync(this.GetScriptsBundle(), "about:blank", 1);
            //    }
            //};
        }
Exemplo n.º 11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            txtTabTitle.Text          = txtTabTitle.Text.Trim();
            txtCookieJarName.Text     = General.MakeSafeFilename(txtCookieJarName.Text.Trim());
            txtNotifIconFilename.Text = General.MakeSafeFilename(txtNotifIconFilename.Text.Trim());
            txtWebsite.Text           = txtWebsite.Text.Trim();

            if (string.IsNullOrEmpty(txtTabTitle.Text) || string.IsNullOrEmpty(txtCookieJarName.Text) || string.IsNullOrEmpty(txtWebsite.Text))
            {
                MessageBox.Show("Title / CookieJAR / Website fields are mandatory, operation aborted!");
                return;
            }

            if (lst.SelectedItem == null)
            { //add new
                if (General.cfg != null)
                {
                    int validation = General.cfg.wList.Where(x => x.title.Equals(txtTabTitle.Text, StringComparison.OrdinalIgnoreCase)).Count();

                    if (validation > 0)
                    {
                        MessageBox.Show("Title already exists, operation aborted!");
                        return;
                    }
                }
                else
                {
                    General.cfg = new ConfigApp();
                }

                General.cfg.wList.Add(new WebsiteDetail()
                {
                    cookiesJar             = txtCookieJarName.Text,
                    noAtStartup            = chkDontShowStartup.Checked,
                    notificationIcon       = txtNotifIconFilename.Text,
                    notificationKeyword    = txtNotifKeyword.Text.Trim(),
                    notificationShowWindow = chkNotifShowWindow.Checked,
                    title = txtTabTitle.Text,
                    url   = txtWebsite.Text
                });
            }
            else
            {
                //WARN - duplication is not prevented

                WebsiteDetail x = General.cfg.wList.Where(y => y.title.Equals((lst.SelectedItem as WebsiteDetail).title)).FirstOrDefault();

                x.cookiesJar             = txtCookieJarName.Text;
                x.noAtStartup            = chkDontShowStartup.Checked;
                x.notificationIcon       = txtNotifIconFilename.Text;
                x.notificationKeyword    = txtNotifKeyword.Text.Trim();
                x.notificationShowWindow = chkNotifShowWindow.Checked;
                x.title = txtTabTitle.Text;
                x.url   = txtWebsite.Text;
            }

            //save
            XmlHelper.ToXmlFile(General.cfg, General.configPath);


            //signalize parent form
            SetIsDirty();

            lst.Enabled    = true;
            btnAddnew.Text = "add new";

            FillList();
        }