mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-09 06:15:49 +02:00
Merge remote-tracking branch 'origin/master' into cef_update
This commit is contained in:
commit
c6f4656d4c
@ -5,7 +5,6 @@ namespace TweetDuck.Configuration{
|
||||
static class Arguments{
|
||||
// public args
|
||||
public const string ArgDataFolder = "-datafolder";
|
||||
public const string ArgChromeUA = "-chromeagent";
|
||||
public const string ArgLogging = "-log";
|
||||
|
||||
// internal args
|
||||
|
@ -8,6 +8,7 @@
|
||||
using TweetDuck.Core.Handling.General;
|
||||
using TweetDuck.Core.Utils;
|
||||
using System.Text.RegularExpressions;
|
||||
using TweetDuck.Data;
|
||||
using TweetDuck.Resources;
|
||||
|
||||
namespace TweetDuck.Core.Other{
|
||||
@ -15,6 +16,8 @@ sealed partial class FormGuide : Form{
|
||||
private const string GuideUrl = "https://tweetduck.chylex.com/guide/v2/";
|
||||
private const string GuidePathRegex = @"^guide(?:/v\d+)?(?:/(#.*))?";
|
||||
|
||||
private static readonly ResourceLink DummyPage = new ResourceLink("http://td/dummy", ResourceHandler.FromString(""));
|
||||
|
||||
public static bool CheckGuideUrl(string url, out string hash){
|
||||
if (!url.Contains("//tweetduck.chylex.com/guide")){
|
||||
hash = null;
|
||||
@ -53,6 +56,7 @@ public static void Show(string hash = null){
|
||||
}
|
||||
|
||||
private readonly ChromiumWebBrowser browser;
|
||||
private string nextUrl;
|
||||
|
||||
private FormGuide(string url, FormBrowser owner){
|
||||
InitializeComponent();
|
||||
@ -75,6 +79,9 @@ private FormGuide(string url, FormBrowser owner){
|
||||
browser.BrowserSettings.BackgroundColor = (uint)BackColor.ToArgb();
|
||||
browser.Dock = DockStyle.None;
|
||||
browser.Location = ControlExtensions.InvisibleLocation;
|
||||
|
||||
browser.SetupResourceHandler(DummyPage);
|
||||
|
||||
Controls.Add(browser);
|
||||
|
||||
Disposed += (sender, args) => {
|
||||
@ -86,21 +93,26 @@ private FormGuide(string url, FormBrowser owner){
|
||||
}
|
||||
|
||||
private void Reload(string url){
|
||||
nextUrl = url;
|
||||
browser.LoadingStateChanged += browser_LoadingStateChanged;
|
||||
browser.Dock = DockStyle.None;
|
||||
browser.Location = ControlExtensions.InvisibleLocation;
|
||||
browser.Load("about:blank");
|
||||
browser.Load(url);
|
||||
browser.Load(DummyPage.Url);
|
||||
}
|
||||
|
||||
private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){
|
||||
if (!e.IsLoading && browser.Address != "about:blank"){
|
||||
this.InvokeAsyncSafe(() => {
|
||||
browser.Location = Point.Empty;
|
||||
browser.Dock = DockStyle.Fill;
|
||||
});
|
||||
if (!e.IsLoading){
|
||||
if (browser.Address == DummyPage.Url){
|
||||
browser.Load(nextUrl);
|
||||
}
|
||||
else{
|
||||
this.InvokeAsyncSafe(() => {
|
||||
browser.Location = Point.Empty;
|
||||
browser.Dock = DockStyle.Fill;
|
||||
});
|
||||
|
||||
browser.LoadingStateChanged -= browser_LoadingStateChanged;
|
||||
browser.LoadingStateChanged -= browser_LoadingStateChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +121,6 @@ private void browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e){
|
||||
}
|
||||
|
||||
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
// idiot chromium
|
||||
ScriptLoader.ExecuteScript(e.Frame, "Array.prototype.forEach.call(document.getElementsByTagName('A'), ele => ele.addEventListener('click', e => { e.preventDefault(); window.open(ele.getAttribute('href')); }))", "gen:links");
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ private void InitializeComponent() {
|
||||
this.cbLogging = new System.Windows.Forms.CheckBox();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.tbDataFolder = new System.Windows.Forms.TextBox();
|
||||
this.cbChromeAgent = new System.Windows.Forms.CheckBox();
|
||||
this.tbShortcutTarget = new System.Windows.Forms.TextBox();
|
||||
this.labelDataFolder = new System.Windows.Forms.Label();
|
||||
this.labelShortcutTarget = new System.Windows.Forms.Label();
|
||||
@ -42,7 +41,7 @@ private void InitializeComponent() {
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.AutoSize = true;
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnCancel.Location = new System.Drawing.Point(215, 170);
|
||||
this.btnCancel.Location = new System.Drawing.Point(215, 146);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnCancel.Size = new System.Drawing.Size(57, 25);
|
||||
@ -56,7 +55,7 @@ private void InitializeComponent() {
|
||||
this.btnRestart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnRestart.AutoSize = true;
|
||||
this.btnRestart.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnRestart.Location = new System.Drawing.Point(152, 170);
|
||||
this.btnRestart.Location = new System.Drawing.Point(152, 146);
|
||||
this.btnRestart.Name = "btnRestart";
|
||||
this.btnRestart.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnRestart.Size = new System.Drawing.Size(57, 25);
|
||||
@ -81,25 +80,12 @@ private void InitializeComponent() {
|
||||
// tbDataFolder
|
||||
//
|
||||
this.tbDataFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.tbDataFolder.Location = new System.Drawing.Point(3, 78);
|
||||
this.tbDataFolder.Location = new System.Drawing.Point(3, 54);
|
||||
this.tbDataFolder.Name = "tbDataFolder";
|
||||
this.tbDataFolder.Size = new System.Drawing.Size(260, 23);
|
||||
this.tbDataFolder.TabIndex = 3;
|
||||
this.tbDataFolder.TabIndex = 2;
|
||||
this.toolTip.SetToolTip(this.tbDataFolder, "Path to the data folder. Must be either an absolute path,\r\nor a simple folder nam" +
|
||||
"e that will be created in LocalAppData.");
|
||||
//
|
||||
// cbChromeAgent
|
||||
//
|
||||
this.cbChromeAgent.AutoSize = true;
|
||||
this.cbChromeAgent.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.cbChromeAgent.Location = new System.Drawing.Point(3, 27);
|
||||
this.cbChromeAgent.Margin = new System.Windows.Forms.Padding(3, 3, 3, 2);
|
||||
this.cbChromeAgent.Name = "cbChromeAgent";
|
||||
this.cbChromeAgent.Size = new System.Drawing.Size(130, 19);
|
||||
this.cbChromeAgent.TabIndex = 1;
|
||||
this.cbChromeAgent.Text = "Chrome User Agent";
|
||||
this.toolTip.SetToolTip(this.cbChromeAgent, "Masks user agent using a generic Chrome UA.");
|
||||
this.cbChromeAgent.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tbShortcutTarget
|
||||
//
|
||||
@ -107,33 +93,33 @@ private void InitializeComponent() {
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tbShortcutTarget.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.tbShortcutTarget.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.tbShortcutTarget.Location = new System.Drawing.Point(3, 134);
|
||||
this.tbShortcutTarget.Location = new System.Drawing.Point(3, 110);
|
||||
this.tbShortcutTarget.Name = "tbShortcutTarget";
|
||||
this.tbShortcutTarget.ReadOnly = true;
|
||||
this.tbShortcutTarget.Size = new System.Drawing.Size(260, 23);
|
||||
this.tbShortcutTarget.TabIndex = 5;
|
||||
this.tbShortcutTarget.TabIndex = 4;
|
||||
this.tbShortcutTarget.Click += new System.EventHandler(this.tbShortcutTarget_Click);
|
||||
//
|
||||
// labelDataFolder
|
||||
//
|
||||
this.labelDataFolder.AutoSize = true;
|
||||
this.labelDataFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelDataFolder.Location = new System.Drawing.Point(3, 60);
|
||||
this.labelDataFolder.Location = new System.Drawing.Point(3, 36);
|
||||
this.labelDataFolder.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelDataFolder.Name = "labelDataFolder";
|
||||
this.labelDataFolder.Size = new System.Drawing.Size(67, 15);
|
||||
this.labelDataFolder.TabIndex = 2;
|
||||
this.labelDataFolder.TabIndex = 1;
|
||||
this.labelDataFolder.Text = "Data Folder";
|
||||
//
|
||||
// labelShortcutTarget
|
||||
//
|
||||
this.labelShortcutTarget.AutoSize = true;
|
||||
this.labelShortcutTarget.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelShortcutTarget.Location = new System.Drawing.Point(3, 116);
|
||||
this.labelShortcutTarget.Location = new System.Drawing.Point(3, 92);
|
||||
this.labelShortcutTarget.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelShortcutTarget.Name = "labelShortcutTarget";
|
||||
this.labelShortcutTarget.Size = new System.Drawing.Size(171, 15);
|
||||
this.labelShortcutTarget.TabIndex = 4;
|
||||
this.labelShortcutTarget.TabIndex = 3;
|
||||
this.labelShortcutTarget.Text = "Shortcut Target (click to select)";
|
||||
//
|
||||
// flowPanel
|
||||
@ -142,7 +128,6 @@ private void InitializeComponent() {
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.flowPanel.Controls.Add(this.cbLogging);
|
||||
this.flowPanel.Controls.Add(this.cbChromeAgent);
|
||||
this.flowPanel.Controls.Add(this.labelDataFolder);
|
||||
this.flowPanel.Controls.Add(this.tbDataFolder);
|
||||
this.flowPanel.Controls.Add(this.labelShortcutTarget);
|
||||
@ -151,7 +136,7 @@ private void InitializeComponent() {
|
||||
this.flowPanel.Location = new System.Drawing.Point(9, 9);
|
||||
this.flowPanel.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.flowPanel.Name = "flowPanel";
|
||||
this.flowPanel.Size = new System.Drawing.Size(266, 160);
|
||||
this.flowPanel.Size = new System.Drawing.Size(266, 136);
|
||||
this.flowPanel.TabIndex = 0;
|
||||
this.flowPanel.WrapContents = false;
|
||||
//
|
||||
@ -159,7 +144,7 @@ private void InitializeComponent() {
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(284, 207);
|
||||
this.ClientSize = new System.Drawing.Size(284, 183);
|
||||
this.Controls.Add(this.flowPanel);
|
||||
this.Controls.Add(this.btnRestart);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
@ -187,6 +172,5 @@ private void InitializeComponent() {
|
||||
private System.Windows.Forms.TextBox tbShortcutTarget;
|
||||
private System.Windows.Forms.Label labelShortcutTarget;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowPanel;
|
||||
private System.Windows.Forms.CheckBox cbChromeAgent;
|
||||
}
|
||||
}
|
@ -12,10 +12,7 @@ public DialogSettingsRestart(CommandLineArgs currentArgs){
|
||||
|
||||
cbLogging.Checked = currentArgs.HasFlag(Arguments.ArgLogging);
|
||||
cbLogging.CheckedChanged += control_Change;
|
||||
|
||||
cbChromeAgent.Checked = currentArgs.HasFlag(Arguments.ArgChromeUA);
|
||||
cbChromeAgent.CheckedChanged += control_Change;
|
||||
|
||||
|
||||
if (Program.IsPortable){
|
||||
tbDataFolder.Text = "Not available in portable version";
|
||||
tbDataFolder.Enabled = false;
|
||||
@ -36,11 +33,7 @@ private void control_Change(object sender, EventArgs e){
|
||||
if (cbLogging.Checked){
|
||||
Args.AddFlag(Arguments.ArgLogging);
|
||||
}
|
||||
|
||||
if (cbChromeAgent.Checked){
|
||||
Args.AddFlag(Arguments.ArgChromeUA);
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(tbDataFolder.Text) && tbDataFolder.Enabled){
|
||||
Args.SetValue(Arguments.ArgDataFolder, tbDataFolder.Text);
|
||||
}
|
||||
|
@ -11,11 +11,9 @@
|
||||
|
||||
namespace TweetDuck.Core.Utils{
|
||||
static class BrowserUtils{
|
||||
public static string CreateUserAgent(bool useChromeUA){
|
||||
return useChromeUA ? "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/"+Cef.ChromiumVersion+" Safari/537.36"
|
||||
: Program.BrandName+" "+Application.ProductVersion;
|
||||
}
|
||||
|
||||
public static string UserAgentVanilla => Program.BrandName+" "+Application.ProductVersion;
|
||||
public static string UserAgentChrome => "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/"+Cef.ChromiumVersion+" Safari/537.36";
|
||||
|
||||
public static void SetupCefArgs(IDictionary<string, string> args){
|
||||
if (!Program.SystemConfig.HardwareAcceleration){
|
||||
args["disable-gpu"] = "1";
|
||||
@ -170,7 +168,7 @@ public static WebClient CreateWebClient(){
|
||||
WindowsUtils.EnsureTLS12();
|
||||
|
||||
WebClient client = new WebClient{ Proxy = null };
|
||||
client.Headers[HttpRequestHeader.UserAgent] = CreateUserAgent(false);
|
||||
client.Headers[HttpRequestHeader.UserAgent] = UserAgentVanilla;
|
||||
return client;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ static class Program{
|
||||
public const string BrandName = "TweetDuck";
|
||||
public const string Website = "https://tweetduck.chylex.com";
|
||||
|
||||
public const string VersionTag = "1.13.5";
|
||||
public const string VersionTag = "1.13.6";
|
||||
|
||||
public static readonly string ProgramPath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
public static readonly bool IsPortable = File.Exists(Path.Combine(ProgramPath, "makeportable"));
|
||||
@ -133,7 +133,7 @@ private static void Main(){
|
||||
CefSharpSettings.LegacyJavascriptBindingEnabled = true;
|
||||
|
||||
CefSettings settings = new CefSettings{
|
||||
UserAgent = BrowserUtils.CreateUserAgent(Arguments.HasFlag(Arguments.ArgChromeUA)),
|
||||
UserAgent = BrowserUtils.UserAgentChrome,
|
||||
BrowserSubprocessPath = BrandName+".Browser.exe",
|
||||
CachePath = StoragePath,
|
||||
UserDataPath = CefDataPath,
|
||||
@ -142,7 +142,7 @@ private static void Main(){
|
||||
LogSeverity = Arguments.HasFlag(Arguments.ArgLogging) ? LogSeverity.Info : LogSeverity.Disable
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
CommandLineArgs.ReadCefArguments(UserConfig.CustomCefArgs).ToDictionary(settings.CefCommandLineArgs);
|
||||
BrowserUtils.SetupCefArgs(settings.CefCommandLineArgs);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="cef.redist.x64" version="3.3325.1758" targetFramework="net452" xmlns="" />
|
||||
<package id="cef.redist.x86" version="3.3325.1758" targetFramework="net452" xmlns="" />
|
||||
<package id="CefSharp.Common" version="65.0.0-CI2594" targetFramework="net452" xmlns="" />
|
||||
<package id="CefSharp.WinForms" version="65.0.0-CI2594" targetFramework="net452" xmlns="" />
|
||||
<package id="cef.redist.x64" version="3.3282.1731" targetFramework="net452" />
|
||||
<package id="cef.redist.x86" version="3.3282.1731" targetFramework="net452" />
|
||||
<package id="CefSharp.Common" version="64.0.0-CI2508" targetFramework="net452" />
|
||||
<package id="CefSharp.WinForms" version="64.0.0-CI2508" targetFramework="net452" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user