拍单功能继续优化
This commit is contained in:
1 parent
29042424dc
commit
34c51c6fcd
64 files changed
+7138
-305
No files matched your search
@@ -0,0 +1,616 @@
|
||||
using AllBase;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.Result;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
//using TemuKJD.DashBoardForms;
|
||||
using Microsoft.Win32;
|
||||
using NaiBa.CefHelper;
|
||||
using NaiBa.CefHelper.Handler;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
//using System.Web.Hosting;
|
||||
using System.Windows.Forms;
|
||||
using Work;
|
||||
using Work._29Tools.CefTools;
|
||||
|
||||
namespace Work.BaseForms
|
||||
{
|
||||
public enum EnumOpenType
|
||||
{
|
||||
login,
|
||||
manage,
|
||||
refresh_cookie,
|
||||
order_login,
|
||||
}
|
||||
|
||||
// temu 一个登录账号下可以有多个店铺
|
||||
public class ShopCompany
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public string LoginName { get; set; }
|
||||
public string AccountId { get; set; }
|
||||
public string AccountName { get; set; }
|
||||
public string LoginStatus { get; set; }
|
||||
/// <summary>
|
||||
/// 拼多多校验数据列表
|
||||
/// </summary>
|
||||
public string AntiContent { get; set; }
|
||||
/// <summary>
|
||||
/// 拼多多店铺信息
|
||||
/// </summary>
|
||||
public string MallId { get; set; }
|
||||
/// <summary>
|
||||
/// 微信小店开放Id信息
|
||||
/// </summary>
|
||||
public string openid { get; set; }
|
||||
}
|
||||
|
||||
public partial class PddMobileLoginForm : BaseGeneralForm
|
||||
{
|
||||
public static PddMobileLoginForm PddMobileLoginInstance { get; set; } = null;
|
||||
|
||||
public int CloseAfterSecond { get; set; }
|
||||
public EnumOpenType openType = EnumOpenType.manage;
|
||||
public string InitUrl = "";
|
||||
private string shopCookieHead = "yangkeduo.com";
|
||||
private string shopLoginUrl = "https://mobile.yangkeduo.com/login.html?from=https%3A%2F%2Fmobile.yangkeduo.com%2Fpersonal.html";
|
||||
private string shopMainUrl = "https://mobile.yangkeduo.com/index.html";
|
||||
public ChromiumWebBrowser cefWebBrowser = null;
|
||||
private BuyerLoginInfo buyer = null;
|
||||
private List<ShopCompany> lstShopCompany = new List<ShopCompany>();
|
||||
private string currentUrl = "";
|
||||
|
||||
public PddMobileLoginForm(BuyerLoginInfo buyerInfo)
|
||||
{
|
||||
PddMobileLoginInstance = this;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
this.buyer = buyerInfo;
|
||||
this.txtUserName.Text = buyerInfo?.buyer_name;
|
||||
this.txtPassWord.Text = ""; //DataOpenSSL.DecryptString(buyerInfo.Password);
|
||||
}
|
||||
|
||||
private void ShopLoginForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
//this.splitContainer1.SplitterDistance = this.splitContainer1.Height - 62;
|
||||
if (openType == EnumOpenType.login)
|
||||
{
|
||||
this.label3.Visible = true;
|
||||
this.panel3.Visible = true;
|
||||
}
|
||||
|
||||
if (CloseAfterSecond > 0)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
Thread.Sleep(1000 * CloseAfterSecond);
|
||||
if (this.Created)
|
||||
{
|
||||
Invoke(new Action(() => { this.Close(); }));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
AutoLogin();
|
||||
CheckAndSaveShop(); //判断登录是否成功,成功则保存店铺信息和店铺cookie
|
||||
//ClosePopWindow(); //自动关闭弹窗
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断登录,保存店铺
|
||||
/// </summary>
|
||||
private void CheckAndSaveShop()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动关闭弹窗
|
||||
/// </summary>
|
||||
private void ClosePopWindow()
|
||||
{
|
||||
// 关闭弹窗
|
||||
Task.Run(() =>
|
||||
{
|
||||
var sleepTime = 2500;
|
||||
int i = 0;
|
||||
while (true && i++ < 50)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.Sleep(sleepTime);
|
||||
var jsStr1 = "function ClosePopWindow(txt) {\r\n" +
|
||||
" var result = 'no_pop'\r\n" +
|
||||
" var item = document.getElementsByClassName(txt);\r\n" +
|
||||
" for(i = 0; i < item.length; i++) {\r\n" +
|
||||
" item[i].click();\r\n" +
|
||||
" result = 'success'\r\n" +
|
||||
" }\r\n" +
|
||||
" return result;\r\n" +
|
||||
"}\r\n" +
|
||||
"ClosePopWindow('anticon-close-circle');\r\n" +
|
||||
"ClosePopWindow('ant-modal-close-x');\r\n";
|
||||
var jsStr2 = "function clickPopWindow(txt) {\r\n"
|
||||
+ "var child = document.body.firstElementChild;\r\n"
|
||||
+ "var element1 = null;\r\n"
|
||||
+ " while (child) {\r\n"
|
||||
+ " if (child.innerHTML.indexOf(txt) >= 0) {\r\n"
|
||||
+ " element1 = child;\r\n"
|
||||
+ " if (child.firstElementChild) {\r\n"
|
||||
+ " child = child.firstElementChild; continue;\r\n"
|
||||
+ " } else break;\r\n"
|
||||
+ " }\r\n"
|
||||
+ " child = child.nextElementSibling;\r\n"
|
||||
+ " }\r\n"
|
||||
+ " if (element1) {\r\n"
|
||||
+ " element1.click(); return 'success';\r\n"
|
||||
+ " } else return 'no_pop';\r\n"
|
||||
+ "}\r\n"
|
||||
+ "clickPopWindow('我知道了');\r\n"
|
||||
+ "clickPopWindow('知道了');\r\n";
|
||||
if (cefWebBrowser != null && cefWebBrowser.IsBrowserInitialized)
|
||||
{
|
||||
var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1);
|
||||
t1.Wait();
|
||||
var t2 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr2);
|
||||
t2.Wait();
|
||||
if (t1.Result?.Result?.ToString() == "success" || t2.Result?.Result?.ToString() == "success")
|
||||
sleepTime = Randomx.GetId(550, 650);
|
||||
else
|
||||
sleepTime = Randomx.GetId(1500, 2000);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动登录店铺后台
|
||||
/// </summary>
|
||||
private void AutoLogin()
|
||||
{
|
||||
if (openType != EnumOpenType.login && buyer == null)
|
||||
return;
|
||||
|
||||
if (cefWebBrowser == null)
|
||||
{
|
||||
//cefWebBrowser = CEFBrowser.CreateChromiumWebBrowser("about:blank", false);
|
||||
if (!string.IsNullOrEmpty(InitUrl))
|
||||
cefWebBrowser = CEFBrowser.CreateChromiumWebBrowser(InitUrl, false);
|
||||
else
|
||||
cefWebBrowser = CEFBrowser.CreateChromiumWebBrowser(shopMainUrl, false);
|
||||
CustomResourceRequestHandlerLocal resourceRequestHandler = new CustomResourceRequestHandlerLocal();
|
||||
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
|
||||
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
|
||||
cefWebBrowser.RequestHandler = new CustomRequestHandler(resourceRequestHandler);
|
||||
var lifeSapnHandler = new LifeSpanHandlerLocal(PopWindowType.SelfWindow);
|
||||
cefWebBrowser.LifeSpanHandler = lifeSapnHandler;
|
||||
cefWebBrowser.KeyboardHandler = new KeyboardHandler();
|
||||
cefWebBrowser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
|
||||
cefWebBrowser.AddressChanged += CefWebBrowser_AddressChanged;
|
||||
cefWebBrowser.LoadError += CefWebBrowser_LoadError;
|
||||
cefWebBrowser.Dock = DockStyle.Fill;
|
||||
|
||||
//js绑定C#对象
|
||||
//PDDShopBrowserObject shopObj = new PDDShopBrowserObject();
|
||||
//shopObj.OnInfoReceived += ShopObj_OnInfoReceived;
|
||||
//CefSharpSettings.WcfEnabled = true;
|
||||
//cefWebBrowser.JavascriptObjectRepository.Register(
|
||||
// name: "shopObj",
|
||||
// objectToBind: shopObj,
|
||||
// isAsync: false,
|
||||
// options: new BindingOptions { Binder = BindingOptions.DefaultBinder.Binder /*CamelCaseJavascriptNames = false*/ /*cef79*/ }
|
||||
//);
|
||||
|
||||
//if (buyer.cookie == null)
|
||||
// buyer.cookie = "";
|
||||
|
||||
List<Cookie> cookieLst = new List<Cookie>();
|
||||
try
|
||||
{
|
||||
if (buyer != null)
|
||||
{
|
||||
cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(buyer?.cookie);
|
||||
if (cookieLst == null)
|
||||
cookieLst = new List<Cookie>();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
splitContainer1.Panel1.Controls.Add(cefWebBrowser);
|
||||
//cefWebBrowser.Load(shopMainUrl);
|
||||
}));
|
||||
// cef138必须init后方可设置或删除cookie
|
||||
while (!cefWebBrowser.IsBrowserInitialized || !cefWebBrowser.GetBrowser().MainFrame.IsValid)
|
||||
Thread.Sleep(20);
|
||||
CEFBrowser.DeleteCookie(cefWebBrowser.GetCookieManager(null));
|
||||
|
||||
//if (cookieLst.Any(c => c.Value.StartsWith("windows_1")))
|
||||
// cefWebBrowser.ExecuteScriptAsync("navigator.__defineGetter__('userAgent', function() { return 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.5.40.8 Safari/537.36 PddWorkbench-Online PddBrowser pdd_windows_version/3.0.3.12'; });");
|
||||
|
||||
//cef 138 如果没有设置RequestContext 可能为空,直接getCookieManager
|
||||
//if (this.openType != EnumOpenType.login)
|
||||
{
|
||||
var t = CEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), cefWebBrowser.GetCookieManager(null));
|
||||
foreach (var cook in cookieLst)
|
||||
{
|
||||
//var t = CEFBrowser.SetCookieAsync(cook.Domain.Trim('.'), cook.Name + "=" + cook.Value + ";", cefWebBrowser.GetCookieManager(null));
|
||||
//t.Wait(5000);
|
||||
|
||||
//if (cook.Name == "PDDAccessToken")
|
||||
//{
|
||||
// var jsStr = "var date = new Date();" +
|
||||
// "date.setTime(date.getTime() + (465 * 24 * 60 * 60 * 1000)); " +
|
||||
// "document.cookie='PDDAccessToken=" + cook.Value + ";domain=mobile.yangkeduo.com; expires=' + date.toUTCString()";
|
||||
|
||||
// jsStr = "document.cookie='PDDAccessToken=" + cook.Value + ";domain=mobile.yangkeduo.com;'";
|
||||
// cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
|
||||
|
||||
// //cook.Expires = DateTime.Now.AddDays(465);
|
||||
// //cefWebBrowser.GetCookieManager(null).SetCookie("https://" + cook.Domain.Trim('.'), cook);
|
||||
//}
|
||||
////else
|
||||
//// cefWebBrowser.GetCookieManager(null).SetCookie("https://" + cook.Domain, cook);
|
||||
}
|
||||
}
|
||||
|
||||
//根据登录的具体店铺设置local storage
|
||||
if (!string.IsNullOrEmpty(buyer?.buyer_id))
|
||||
{
|
||||
//var storageJsCode = "window.localStorage.setItem('" + "mall-info-id" + "', '" + shop.ShopId + "');\r\n";
|
||||
//storageJsCode += "window.localStorage.setItem('" + "agentseller-mall-info-id" + "', '" + shop.ShopId + "');\r\n";
|
||||
//while (!cefWebBrowser.IsBrowserInitialized || !cefWebBrowser.GetBrowser().MainFrame.IsValid)
|
||||
// Thread.Sleep(20);
|
||||
//cefWebBrowser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(storageJsCode);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(InitUrl))
|
||||
cefWebBrowser.Load(InitUrl);
|
||||
else
|
||||
cefWebBrowser.Load(shopMainUrl);
|
||||
|
||||
//不是登录的话就此返回
|
||||
if (openType != EnumOpenType.login)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
chkCloseAfterLogin.Visible = false;
|
||||
btnLoginAgain.Visible = false;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
if (cefWebBrowser.IsLoading)
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(1500,2000));
|
||||
|
||||
if (!this.Created)
|
||||
return;
|
||||
|
||||
while (!cefWebBrowser.Address.StartsWith(shopLoginUrl))
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
if (!this.Created)
|
||||
return;
|
||||
}
|
||||
|
||||
//CEFBrowser.DeleteCookie(cefWebBrowser.GetCookieManager(null));
|
||||
//InputUserNameAndPassword(cefWebBrowser, shop.LoginName, DataOpenSSL.DecryptString(shop.Password));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ShopObj_OnInfoReceived(string information)
|
||||
{
|
||||
//BaseMsgForm.ShowInfo(information);
|
||||
if (!string.IsNullOrEmpty(information))
|
||||
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync("alert('" + information + "');");
|
||||
}
|
||||
|
||||
private void CefWebBrowser_LoadError(object sender, CefSharp.LoadErrorEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void CefWebBrowser_AddressChanged(object sender, CefSharp.AddressChangedEventArgs e)
|
||||
{
|
||||
if (this.Created && !this.Disposing && !this.IsDisposed)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
currentUrl = e.Address;
|
||||
txtAddress.Text = e.Address;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void CefWebBrowser_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
|
||||
{
|
||||
//js绑定C#对象 html页面内声明绑定的C#对象
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("(function(){");
|
||||
sb.Append("CefSharp.BindObjectAsync('shopObj');");
|
||||
sb.Append("})();");
|
||||
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sb.ToString());
|
||||
}
|
||||
|
||||
//public Func<object, string, string, request, bool> BeforeResourceLoadEvent; // sender, requestUrl, postData, request, true(表示取消执行)
|
||||
private bool RequestHandler_BeforeResourceLoad(object sender, string url, string postData, IRequest request)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static int GetAntiContentsTimes = 40;
|
||||
private void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData, IRequest request)
|
||||
{
|
||||
//if (url.Contains("https://mobile.yangkeduo.com/personal.html?refer_page_name=login") && openType == EnumOpenType.login)
|
||||
if (url.Contains("https://mobile.yangkeduo.com/index.html") && openType == EnumOpenType.login)
|
||||
{
|
||||
Task.Run(() => { cefWebBrowser.Load("https://mobile.yangkeduo.com/personal.html"); });
|
||||
}
|
||||
|
||||
if (url.Contains("https://mobile.yangkeduo.com/personal.html"))
|
||||
{
|
||||
if (openType == EnumOpenType.login)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
var data = responseData;
|
||||
if (data.Contains("\"success\":true") || data.Contains("nickname"))
|
||||
{
|
||||
var uid = BaseRegex.GetStringJson(ref data, "uid");
|
||||
var nickname = BaseRegex.GetStringJson(ref data, "nickname");
|
||||
var username = nickname;
|
||||
|
||||
if (!string.IsNullOrEmpty(nickname) && !string.IsNullOrEmpty(uid))
|
||||
{
|
||||
Thread.Sleep(2000);
|
||||
|
||||
List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.GetCookieManager(null));
|
||||
|
||||
var buyerUrl = BaseClass.BuildPDDObjString("user/add_buyer");
|
||||
|
||||
if (this.buyer == null || this.buyer.buyer_id != uid)
|
||||
this.buyer = GlobalConfig.BuyerLoginList.FirstOrDefault(b => b.buyer_id == uid);
|
||||
if (this.buyer != null)
|
||||
{
|
||||
this.buyer.user_name = username;
|
||||
this.buyer.buyer_nick = nickname;
|
||||
this.buyer.cookie = JsonHelper.SerializeObject(cookieList);
|
||||
buyerUrl = BaseClass.BuildPDDObjString("user/mdy_buyer");
|
||||
}
|
||||
|
||||
var buyerData = UserLogin.GetSignaturex()
|
||||
+ "&buyer_id=" + uid
|
||||
+ "&buyer_name=" + username
|
||||
+ "&buyer_nick=" + nickname;
|
||||
var result = GetHtml.PostUtf8(buyerUrl, buyerData);
|
||||
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||
result = GetHtml.PostUtf8(buyerUrl, buyerData);
|
||||
|
||||
buyerUrl = BaseClass.BuildPDDObjString("user/mdy_buyer_cookie");
|
||||
buyerData = UserLogin.GetSignaturex()
|
||||
+ "&buyer_id=" + uid
|
||||
+ "&status=" + "在线"
|
||||
+ "&cookie=" + GetHtml.UrlEncodeUtf8(JsonHelper.SerializeObject(cookieList));
|
||||
result = GetHtml.PostUtf8(buyerUrl, buyerData);
|
||||
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||
result = GetHtml.PostUtf8(buyerUrl, buyerData);
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (chkCloseAfterLogin.Checked)
|
||||
this.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ }
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标左键按下,移动,移动...左键抬起。
|
||||
public static void CefMouseDragDou(ChromiumWebBrowser webBrowser, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
var host = webBrowser.GetBrowser().GetHost();
|
||||
|
||||
var rx = -6 + Randomx.GetId(13);
|
||||
x2 = x2 + rx;
|
||||
// 随机按下点的位置(正负6像素),提高仿真性
|
||||
int x = x1 + rx;
|
||||
int y = y1 - 6 + Randomx.GetId(13);
|
||||
|
||||
// 按下鼠标左键
|
||||
host.SendMouseClickEvent(x, y, MouseButtonType.Left, false, 1, CefEventFlags.None);
|
||||
Thread.Sleep(100 + Randomx.GetId(300));
|
||||
|
||||
// 滑动光标
|
||||
int times = -20;
|
||||
while (x < x2 + 4 - Randomx.GetId(9))
|
||||
{
|
||||
times++;
|
||||
x += (15 + Randomx.GetId(15)) / 8;
|
||||
if (times % 5 == 0)
|
||||
y = y - 1 + Randomx.GetId(3);
|
||||
Thread.Sleep(6 + Math.Abs(times) / 5 + Randomx.GetId(16));
|
||||
host.SendMouseMoveEvent((int)x, (int)y, false, CefEventFlags.LeftMouseButton);
|
||||
}
|
||||
if (x < x2 - 1)
|
||||
while (x < x2)
|
||||
{
|
||||
times++;
|
||||
x += (8 + Randomx.GetId(8)) / 8;
|
||||
if (times % 5 == 0)
|
||||
y = y - 1 + Randomx.GetId(3);
|
||||
Thread.Sleep(6 + Math.Abs(times) / 5 + Randomx.GetId(16));
|
||||
host.SendMouseMoveEvent((int)x, (int)y, false, CefEventFlags.LeftMouseButton);
|
||||
}
|
||||
else if (x > x2 + 1)
|
||||
while (x > x2)
|
||||
{
|
||||
times++;
|
||||
x -= (8 + Randomx.GetId(8)) / 8;
|
||||
if (times % 5 == 0)
|
||||
y = y - 1 + Randomx.GetId(3);
|
||||
Thread.Sleep(6 + Math.Abs(times) / 5 + Randomx.GetId(16));
|
||||
host.SendMouseMoveEvent((int)x, (int)y, false, CefEventFlags.LeftMouseButton);
|
||||
}
|
||||
|
||||
// 如果最后位置偏差较多,再做一次调整
|
||||
x = x2 - 1 + Randomx.GetId(3);
|
||||
x = x2;
|
||||
Thread.Sleep(18 + Math.Abs(times) / 5 + Randomx.GetId(16));
|
||||
Thread.Sleep(18 + Math.Abs(times) / 5 + Randomx.GetId(16));
|
||||
host.SendMouseMoveEvent((int)x, (int)y, false, CefEventFlags.LeftMouseButton);
|
||||
|
||||
// 抬起鼠标左键
|
||||
Thread.Sleep(300 + Randomx.GetId(500));
|
||||
host.SendMouseClickEvent(x, y, MouseButtonType.Left, true, 1, CefEventFlags.None);
|
||||
host.SendMouseClickEvent(x, y, MouseButtonType.Left, true, 1, CefEventFlags.None);
|
||||
}
|
||||
|
||||
private void btnStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btnCopyUserName_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(txtUserName.Text))
|
||||
Clipboard.SetDataObject(txtUserName.Text);
|
||||
}
|
||||
|
||||
private void btnCopyPassword_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(txtPassWord.Text))
|
||||
Clipboard.SetDataObject(txtPassWord.Text);
|
||||
}
|
||||
|
||||
private void btnReload_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (cefWebBrowser != null)
|
||||
{
|
||||
if (txtAddress.Text != "about:blank")
|
||||
cefWebBrowser.Load(txtAddress.Text);
|
||||
else
|
||||
cefWebBrowser.Load(shopMainUrl);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShopLoginForm_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
//OnSaveComplete(shop);
|
||||
Task.Run(() => {
|
||||
Thread.Sleep(500);
|
||||
if (!this.Disposing && !this.IsDisposed)
|
||||
{
|
||||
//MainForm.instance.Invoke(new Action(() => { this.Dispose(); }));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void txtAddress_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
if (cefWebBrowser != null)
|
||||
{
|
||||
cefWebBrowser.Load(txtAddress.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string sInputValueChange { get; set; } = @"
|
||||
let usernameId = document.getElementById('usernameId');
|
||||
usernameId.value = '1';
|
||||
|
||||
var event = document.createEvent('HTMLEvents');
|
||||
event.initEvent('input', true, true);
|
||||
event.eventType = 'message';
|
||||
usernameId.dispatchEvent(event);
|
||||
";
|
||||
|
||||
string sInputValueChange2 { get; set; } = @"
|
||||
function changeReactInputValue(inputDom,newText){
|
||||
let lastValue = inputDom.value;
|
||||
inputDom.value = newText;
|
||||
let event = new Event('input', { bubbles: true });
|
||||
event.simulated = true;
|
||||
let tracker = inputDom._valueTracker;
|
||||
if (tracker) {
|
||||
tracker.setValue(lastValue);
|
||||
}
|
||||
inputDom.dispatchEvent(event);
|
||||
}
|
||||
";
|
||||
|
||||
string sGetElementWithText { get; set; } = @"
|
||||
function getElementWithText(sText)
|
||||
{
|
||||
var elem=null;
|
||||
const elements = document.querySelectorAll('*'); // 选择所有元素
|
||||
elements.forEach(element => {
|
||||
if (element.textContent.includes(sText)) {
|
||||
// 对每个匹配的元素执行操作
|
||||
//console.log(element);
|
||||
elem=element;
|
||||
}
|
||||
});
|
||||
return elem;
|
||||
};
|
||||
";
|
||||
|
||||
private void btnLoginAgain_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.currentUrl != shopLoginUrl)
|
||||
this.cefWebBrowser.Load(shopLoginUrl);
|
||||
}
|
||||
|
||||
private void splitContainer1_Panel2_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void btnSaveCookie_Click(object sender, EventArgs e)
|
||||
{
|
||||
Cookie cookie = new Cookie();
|
||||
cookie.Name = "PDDAccessToken";
|
||||
cookie.Domain = "mobile.yangkeduo.com";
|
||||
cookie.Expires = DateTime.Now.AddDays(465);
|
||||
cookie.HttpOnly = true;
|
||||
cookie.Secure = true;
|
||||
cookie.Value = textBox1.Text.Trim();
|
||||
|
||||
if (this.cefWebBrowser != null)
|
||||
{
|
||||
var t = CEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(new List<Cookie> { cookie }), cefWebBrowser.GetCookieManager(null));
|
||||
t.Wait(2000);
|
||||
cefWebBrowser.Load("https://mobile.yangkeduo.com/personal.html");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user