-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrowser.cs
87 lines (85 loc) · 3.7 KB
/
Browser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System.Drawing;
using System.Windows.Forms;
using CefSharp.WinForms;
using CefSharp;
using CefSharp.Handler;
using System.Diagnostics;
using System.Collections;
namespace ZoomAutoRecorder
{
public partial class Browser : Form
{
public ChromiumWebBrowser browser;
public string TCKN, Pass;
public bool isMax;
public Browser(string tckn, string pass, bool isMax, bool isAuto = false)
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Browser));
this.SuspendLayout();
this.ClientSize = new Size(250, 250);
this.isMax = isMax;
if (isMax) this.WindowState = FormWindowState.Maximized;
this.Name = "Browser";
this.Text = "Tarayıcı";
this.Icon = (Icon)resources.GetObject("$this.Icon");
this.ResumeLayout(false);
TCKN = tckn;
Pass = pass;
InitializeCEF(isAuto);
}
public void InitializeCEF(bool auto)
{
if (!Cef.IsInitialized)
{
CefSettings settings = new CefSettings();
Cef.Initialize(settings);
}
browser = new ChromiumWebBrowser("https://giris.eba.gov.tr/EBA_GIRIS/giris.jsp");
browser.Dock = DockStyle.Fill;
browser.FrameLoadEnd += FrameLoadEnd;
browser.KeyDown += Browser_KeyDown;
if (auto) browser.TitleChanged += Browser_TitleChanged;
browser.RequestHandler = new CefHandler(this);
this.Controls.Add(browser);
}
private void Browser_TitleChanged(object sender, TitleChangedEventArgs e)
{
if (e.Title.Contains("EBA, Eğitim Bilişim Ağı, Ders, Haber"))
{
Utils.Lesson lesson = Main.Lessons.Find(x => x.ID == Utils.ZoomEntities.StartedLessonID);
Utils.ZoomEntities.StartLesson(Properties.Settings.Default.RecordLesson, false, lesson).Wait();
Main.BGWorker.isEBA = false;
this.Close();
}
}
private void Browser_KeyDown(object sender, KeyEventArgs e)
{
if (isMax && e.KeyData == Keys.F5)
browser.Reload(true);
}
private void FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
{
browser.ExecuteScriptAsync("document.getElementById('tckn').value='" + TCKN + "'");
browser.ExecuteScriptAsync("document.getElementById('password').value='" + Pass + "'");
browser.ExecuteScriptAsync("document.getElementsByClassName('nl-form-send-btn')[0].click()");
browser.ExecuteScriptAsync("if (document.getElementById('joinMeeting') != null) document.getElementById('joinMeeting').click()");
browser.ExecuteScriptAsync("document.getElementById('join').click()");
}
public class CefHandler : RequestHandler
{
public Form Main { get; set; }
public CefHandler(Form form) { Main = form; }
protected override bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect)
{
if (request.Url.StartsWith("ebazoom") || request.Url.StartsWith("zoommtg"))
{
Debug.WriteLine("EBA Linki: " + request.Url);
Utils.MainClass.EBALink = request.Url;
Process.Start(request.Url);
Main.Close();
}
return base.OnBeforeBrowse(chromiumWebBrowser, browser, frame, request, userGesture, isRedirect);
}
}
}
}