Skip to content

Commit

Permalink
优化清空ck缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanggaolei001 committed Oct 11, 2021
1 parent 007e375 commit c83e89e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 4 additions & 3 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ private void Browser_TitleChanged(object sender, DependencyPropertyChangedEventA
ICookieManager cm = Browser.WebBrowser.GetCookieManager();
var visitor = new TaskCookieVisitor();
cm.VisitAllCookies(visitor);
ck = visitor.Task.Result.Where(cookie => cookie.Name == "pt_key" || cookie.Name == "pt_pin").Aggregate(ck, (current, cookie) => current + $"{cookie.Name}={System.Web.HttpUtility.UrlEncode(cookie.Value)};");
var cks = visitor.Task.Result;
ck = cks.Where(cookie => cookie.Name == "pt_key" || cookie.Name == "pt_pin").Aggregate(ck, (current, cookie) => current + $"{cookie.Name}={System.Web.HttpUtility.UrlEncode(cookie.Value)};");
if (ck.Contains("pt_key") && ck.Contains("pt_pin"))
{
Clipboard.SetText(ck);
UploadToServer(ck);
UploadToQingLong(ck);
cm.DeleteCookies(".jd.com", "");
cm.DeleteCookies(".jd.com", "pt_key");
cm.DeleteCookies(".jd.com", "pt_pin");
Browser.Address = "m.jd.com";
}
}));
Expand Down
10 changes: 2 additions & 8 deletions Program.netcore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,8 @@ public static int Main(string[] args)
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

var app = new App();
app.InitializeComponent();
app.Exit += CleanCache;
app.InitializeComponent();
return app.Run();
}

private static void CleanCache(object sender, System.Windows.ExitEventArgs e)
{
Cef.GetGlobalCookieManager().DeleteCookies(".jd.com", "");
}
}
}
}

0 comments on commit c83e89e

Please sign in to comment.