1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-22 00:15:48 +02:00

Add an option to skip current notification when clicking a link inside it

This commit is contained in:
chylex 2017-04-13 19:42:07 +02:00
parent 0d32c168eb
commit 829d69485a
5 changed files with 65 additions and 31 deletions

View File

@ -22,6 +22,7 @@ sealed class UserConfig{
public bool DisplayNotificationColumn { get; set; }
public bool DisplayNotificationTimer { get; set; }
public bool NotificationTimerCountDown { get; set; }
public bool NotificationSkipOnLinkClick { get; set; }
public bool NotificationNonIntrusiveMode { get; set; }
public TweetNotification.Position NotificationPosition { get; set; }

View File

@ -8,8 +8,9 @@ public enum Properties{
ExpandLinksOnHover = 1,
MuteNotifications = 2,
HasCustomNotificationSound = 4,
SkipOnLinkClick = 8,
AllBrowser = ExpandLinksOnHover | MuteNotifications | HasCustomNotificationSound,
AllNotification = ExpandLinksOnHover
AllNotification = ExpandLinksOnHover | SkipOnLinkClick
}
public static string GenerateScript(Properties properties){
@ -28,6 +29,10 @@ public static string GenerateScript(Properties properties){
build.Append("c.hasCustomNotificationSound=").Append(Program.UserConfig.NotificationSoundPath.Length > 0 ? "true;" : "false;");
}
if (properties.HasFlag(Properties.SkipOnLinkClick)){
build.Append("c.skipOnLinkClick=").Append(Program.UserConfig.NotificationSkipOnLinkClick ? "true;" : "false;");
}
build.Append("})(window.$TDX=window.$TDX||{})");
return build.ToString();
}

View File

@ -43,13 +43,14 @@ private void InitializeComponent() {
this.labelDurationValue = new System.Windows.Forms.Label();
this.trackBarDuration = new System.Windows.Forms.TrackBar();
this.groupUserInterface = new System.Windows.Forms.GroupBox();
this.checkSkipOnLinkClick = new System.Windows.Forms.CheckBox();
this.checkColumnName = new System.Windows.Forms.CheckBox();
this.labelIdlePause = new System.Windows.Forms.Label();
this.comboBoxIdlePause = new System.Windows.Forms.ComboBox();
this.checkNonIntrusive = new System.Windows.Forms.CheckBox();
this.checkTimerCountDown = new System.Windows.Forms.CheckBox();
this.checkNotificationTimer = new System.Windows.Forms.CheckBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.checkNotificationTimer = new System.Windows.Forms.CheckBox();
this.checkTimerCountDown = new System.Windows.Forms.CheckBox();
this.groupNotificationLocation.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
this.groupNotificationDuration.SuspendLayout();
@ -72,7 +73,7 @@ private void InitializeComponent() {
this.groupNotificationLocation.Controls.Add(this.trackBarEdgeDistance);
this.groupNotificationLocation.Location = new System.Drawing.Point(198, 9);
this.groupNotificationLocation.Name = "groupNotificationLocation";
this.groupNotificationLocation.Size = new System.Drawing.Size(183, 264);
this.groupNotificationLocation.Size = new System.Drawing.Size(183, 282);
this.groupNotificationLocation.TabIndex = 2;
this.groupNotificationLocation.TabStop = false;
this.groupNotificationLocation.Text = "Location";
@ -80,7 +81,7 @@ private void InitializeComponent() {
// labelEdgeDistanceValue
//
this.labelEdgeDistanceValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelEdgeDistanceValue.Location = new System.Drawing.Point(143, 214);
this.labelEdgeDistanceValue.Location = new System.Drawing.Point(143, 217);
this.labelEdgeDistanceValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelEdgeDistanceValue.Name = "labelEdgeDistanceValue";
this.labelEdgeDistanceValue.Size = new System.Drawing.Size(34, 13);
@ -112,8 +113,8 @@ private void InitializeComponent() {
// labelEdgeDistance
//
this.labelEdgeDistance.AutoSize = true;
this.labelEdgeDistance.Location = new System.Drawing.Point(5, 193);
this.labelEdgeDistance.Margin = new System.Windows.Forms.Padding(3, 9, 3, 0);
this.labelEdgeDistance.Location = new System.Drawing.Point(5, 196);
this.labelEdgeDistance.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelEdgeDistance.Name = "labelEdgeDistance";
this.labelEdgeDistance.Size = new System.Drawing.Size(103, 13);
this.labelEdgeDistance.TabIndex = 7;
@ -185,7 +186,7 @@ private void InitializeComponent() {
this.trackBarEdgeDistance.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.trackBarEdgeDistance.LargeChange = 8;
this.trackBarEdgeDistance.Location = new System.Drawing.Point(8, 209);
this.trackBarEdgeDistance.Location = new System.Drawing.Point(8, 212);
this.trackBarEdgeDistance.Maximum = 40;
this.trackBarEdgeDistance.Minimum = 8;
this.trackBarEdgeDistance.Name = "trackBarEdgeDistance";
@ -200,7 +201,7 @@ private void InitializeComponent() {
this.groupNotificationDuration.Controls.Add(this.tableLayoutDurationButtons);
this.groupNotificationDuration.Controls.Add(this.labelDurationValue);
this.groupNotificationDuration.Controls.Add(this.trackBarDuration);
this.groupNotificationDuration.Location = new System.Drawing.Point(9, 184);
this.groupNotificationDuration.Location = new System.Drawing.Point(9, 202);
this.groupNotificationDuration.Name = "groupNotificationDuration";
this.groupNotificationDuration.Size = new System.Drawing.Size(183, 89);
this.groupNotificationDuration.TabIndex = 1;
@ -298,6 +299,7 @@ private void InitializeComponent() {
//
// groupUserInterface
//
this.groupUserInterface.Controls.Add(this.checkSkipOnLinkClick);
this.groupUserInterface.Controls.Add(this.checkColumnName);
this.groupUserInterface.Controls.Add(this.labelIdlePause);
this.groupUserInterface.Controls.Add(this.comboBoxIdlePause);
@ -306,11 +308,23 @@ private void InitializeComponent() {
this.groupUserInterface.Controls.Add(this.checkNotificationTimer);
this.groupUserInterface.Location = new System.Drawing.Point(9, 9);
this.groupUserInterface.Name = "groupUserInterface";
this.groupUserInterface.Size = new System.Drawing.Size(183, 169);
this.groupUserInterface.Size = new System.Drawing.Size(183, 187);
this.groupUserInterface.TabIndex = 0;
this.groupUserInterface.TabStop = false;
this.groupUserInterface.Text = "General";
//
// checkSkipOnLinkClick
//
this.checkSkipOnLinkClick.AutoSize = true;
this.checkSkipOnLinkClick.Location = new System.Drawing.Point(9, 90);
this.checkSkipOnLinkClick.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
this.checkSkipOnLinkClick.Name = "checkSkipOnLinkClick";
this.checkSkipOnLinkClick.Size = new System.Drawing.Size(113, 17);
this.checkSkipOnLinkClick.TabIndex = 3;
this.checkSkipOnLinkClick.Text = "Skip On Link Click";
this.toolTip.SetToolTip(this.checkSkipOnLinkClick, "Skips current notification when a link\r\ninside the notification is clicked.");
this.checkSkipOnLinkClick.UseVisualStyleBackColor = true;
//
// checkColumnName
//
this.checkColumnName.AutoSize = true;
@ -318,7 +332,7 @@ private void InitializeComponent() {
this.checkColumnName.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3);
this.checkColumnName.Name = "checkColumnName";
this.checkColumnName.Size = new System.Drawing.Size(129, 17);
this.checkColumnName.TabIndex = 5;
this.checkColumnName.TabIndex = 0;
this.checkColumnName.Text = "Display Column Name";
this.toolTip.SetToolTip(this.checkColumnName, "Shows column name each notification originated\r\nfrom in the notification window t" +
"itle.");
@ -328,7 +342,7 @@ private void InitializeComponent() {
//
this.labelIdlePause.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelIdlePause.AutoSize = true;
this.labelIdlePause.Location = new System.Drawing.Point(3, 123);
this.labelIdlePause.Location = new System.Drawing.Point(3, 141);
this.labelIdlePause.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelIdlePause.Name = "labelIdlePause";
this.labelIdlePause.Size = new System.Drawing.Size(89, 13);
@ -341,7 +355,7 @@ private void InitializeComponent() {
| System.Windows.Forms.AnchorStyles.Right)));
this.comboBoxIdlePause.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxIdlePause.FormattingEnabled = true;
this.comboBoxIdlePause.Location = new System.Drawing.Point(6, 139);
this.comboBoxIdlePause.Location = new System.Drawing.Point(6, 157);
this.comboBoxIdlePause.Name = "comboBoxIdlePause";
this.comboBoxIdlePause.Size = new System.Drawing.Size(171, 21);
this.comboBoxIdlePause.TabIndex = 4;
@ -350,28 +364,16 @@ private void InitializeComponent() {
// checkNonIntrusive
//
this.checkNonIntrusive.AutoSize = true;
this.checkNonIntrusive.Location = new System.Drawing.Point(9, 90);
this.checkNonIntrusive.Location = new System.Drawing.Point(9, 113);
this.checkNonIntrusive.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
this.checkNonIntrusive.Name = "checkNonIntrusive";
this.checkNonIntrusive.Size = new System.Drawing.Size(128, 17);
this.checkNonIntrusive.TabIndex = 2;
this.checkNonIntrusive.TabIndex = 4;
this.checkNonIntrusive.Text = "Non-Intrusive Popups";
this.toolTip.SetToolTip(this.checkNonIntrusive, "When not idle and the cursor is within the notification window area,\r\nit will be " +
"delayed until the cursor moves away to prevent accidental clicks.");
this.checkNonIntrusive.UseVisualStyleBackColor = true;
//
// checkTimerCountDown
//
this.checkTimerCountDown.AutoSize = true;
this.checkTimerCountDown.Location = new System.Drawing.Point(9, 67);
this.checkTimerCountDown.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
this.checkTimerCountDown.Name = "checkTimerCountDown";
this.checkTimerCountDown.Size = new System.Drawing.Size(119, 17);
this.checkTimerCountDown.TabIndex = 1;
this.checkTimerCountDown.Text = "Timer Counts Down";
this.toolTip.SetToolTip(this.checkTimerCountDown, "The notification timer counts down instead of up.");
this.checkTimerCountDown.UseVisualStyleBackColor = true;
//
// checkNotificationTimer
//
this.checkNotificationTimer.AutoSize = true;
@ -379,11 +381,22 @@ private void InitializeComponent() {
this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
this.checkNotificationTimer.Name = "checkNotificationTimer";
this.checkNotificationTimer.Size = new System.Drawing.Size(145, 17);
this.checkNotificationTimer.TabIndex = 0;
this.checkNotificationTimer.TabIndex = 1;
this.checkNotificationTimer.Text = "Display Notification Timer";
this.toolTip.SetToolTip(this.checkNotificationTimer, "Shows how much time is left before the current notification disappears.");
this.checkNotificationTimer.UseVisualStyleBackColor = true;
//
// checkTimerCountDown
//
this.checkTimerCountDown.AutoSize = true;
this.checkTimerCountDown.Location = new System.Drawing.Point(9, 67);
this.checkTimerCountDown.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
this.checkTimerCountDown.Name = "checkTimerCountDown";
this.checkTimerCountDown.Size = new System.Drawing.Size(119, 17);
this.checkTimerCountDown.TabIndex = 2;
this.checkTimerCountDown.Text = "Timer Counts Down";
this.toolTip.SetToolTip(this.checkTimerCountDown, "The notification timer counts down instead of up.");
this.checkTimerCountDown.UseVisualStyleBackColor = true;
//
// TabSettingsNotifications
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -421,10 +434,8 @@ private void InitializeComponent() {
private System.Windows.Forms.RadioButton radioLocTL;
private System.Windows.Forms.GroupBox groupNotificationDuration;
private System.Windows.Forms.GroupBox groupUserInterface;
private System.Windows.Forms.CheckBox checkNotificationTimer;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.Label labelEdgeDistanceValue;
private System.Windows.Forms.CheckBox checkTimerCountDown;
private System.Windows.Forms.Label labelDurationValue;
private System.Windows.Forms.TrackBar trackBarDuration;
private System.Windows.Forms.TableLayoutPanel tableLayoutDurationButtons;
@ -435,5 +446,8 @@ private void InitializeComponent() {
private System.Windows.Forms.Label labelIdlePause;
private System.Windows.Forms.ComboBox comboBoxIdlePause;
private System.Windows.Forms.CheckBox checkColumnName;
private System.Windows.Forms.CheckBox checkSkipOnLinkClick;
private System.Windows.Forms.CheckBox checkTimerCountDown;
private System.Windows.Forms.CheckBox checkNotificationTimer;
}
}

View File

@ -59,6 +59,7 @@ public TabSettingsNotifications(FormNotificationMain notification){
checkNotificationTimer.Checked = Config.DisplayNotificationTimer;
checkTimerCountDown.Enabled = checkNotificationTimer.Checked;
checkTimerCountDown.Checked = Config.NotificationTimerCountDown;
checkSkipOnLinkClick.Checked = Config.NotificationSkipOnLinkClick;
checkNonIntrusive.Checked = Config.NotificationNonIntrusiveMode;
trackBarEdgeDistance.SetValueSafe(Config.NotificationEdgeDistance);
@ -82,6 +83,7 @@ public override void OnReady(){
checkColumnName.CheckedChanged += checkColumnName_CheckedChanged;
checkNotificationTimer.CheckedChanged += checkNotificationTimer_CheckedChanged;
checkTimerCountDown.CheckedChanged += checkTimerCountDown_CheckedChanged;
checkSkipOnLinkClick.CheckedChanged += checkSkipOnLinkClick_CheckedChanged;
checkNonIntrusive.CheckedChanged += checkNonIntrusive_CheckedChanged;
comboBoxIdlePause.SelectedValueChanged += comboBoxIdlePause_SelectedValueChanged;
@ -156,6 +158,10 @@ private void checkTimerCountDown_CheckedChanged(object sender, EventArgs e){
notification.ShowNotificationForSettings(true);
}
private void checkSkipOnLinkClick_CheckedChanged(object sender, EventArgs e){
Config.NotificationSkipOnLinkClick = checkSkipOnLinkClick.Checked;
}
private void checkNonIntrusive_CheckedChanged(object sender, EventArgs e){
Config.NotificationNonIntrusiveMode = checkNonIntrusive.Checked;
}

View File

@ -19,6 +19,14 @@
addEventListener(links, "click", function(e){
$TD.openBrowser(e.currentTarget.getAttribute("href"));
e.preventDefault();
if ($TDX.skipOnLinkClick){
let parentClasses = e.currentTarget.parentNode.classList;
if (parentClasses.contains("js-tweet-text") || parentClasses.contains("js-quoted-tweet-text") || parentClasses.contains("js-timestamp")){
$TD.loadNextNotification();
}
}
});
//