mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-13 18:15:48 +02:00
Add option to show media previews in notification
This commit is contained in:
parent
485ef684be
commit
c235c55b19
@ -53,6 +53,7 @@ static UserConfig(){
|
||||
public string DismissedUpdate { get; set; } = null;
|
||||
|
||||
public bool DisplayNotificationColumn { get; set; } = false;
|
||||
public bool NotificationMediaPreviews { get; set; } = true;
|
||||
public bool NotificationSkipOnLinkClick { get; set; } = false;
|
||||
public bool NotificationNonIntrusiveMode { get; set; } = true;
|
||||
public int NotificationIdlePauseSeconds { get; set; } = 0;
|
||||
|
@ -10,7 +10,8 @@ public enum Properties{
|
||||
HasCustomNotificationSound = 4,
|
||||
SkipOnLinkClick = 8,
|
||||
SwitchAccountSelectors = 16,
|
||||
AllBrowser = ExpandLinksOnHover | SwitchAccountSelectors | MuteNotifications | HasCustomNotificationSound,
|
||||
NotificationMediaPreviews = 32,
|
||||
AllBrowser = ExpandLinksOnHover | SwitchAccountSelectors | MuteNotifications | HasCustomNotificationSound | NotificationMediaPreviews,
|
||||
AllNotification = ExpandLinksOnHover | SkipOnLinkClick
|
||||
}
|
||||
|
||||
@ -34,6 +35,10 @@ public static string GenerateScript(Properties properties){
|
||||
build.Append("c.hasCustomNotificationSound=").Append(Program.UserConfig.NotificationSoundPath.Length > 0 ? "true;" : "false;");
|
||||
}
|
||||
|
||||
if (properties.HasFlag(Properties.NotificationMediaPreviews)){
|
||||
build.Append("c.notificationMediaPreviews=").Append(Program.UserConfig.NotificationMediaPreviews ? "true;" : "false;");
|
||||
}
|
||||
|
||||
if (properties.HasFlag(Properties.SkipOnLinkClick)){
|
||||
build.Append("c.skipOnLinkClick=").Append(Program.UserConfig.NotificationSkipOnLinkClick ? "true;" : "false;");
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ public void OpenSettings(Type startTab){
|
||||
memoryUsageTracker.Stop();
|
||||
}
|
||||
|
||||
UpdateProperties(PropertyBridge.Properties.ExpandLinksOnHover | PropertyBridge.Properties.SwitchAccountSelectors | PropertyBridge.Properties.HasCustomNotificationSound);
|
||||
UpdateProperties(PropertyBridge.Properties.ExpandLinksOnHover | PropertyBridge.Properties.SwitchAccountSelectors | PropertyBridge.Properties.HasCustomNotificationSound | PropertyBridge.Properties.NotificationMediaPreviews);
|
||||
|
||||
notification.RequiresResize = true;
|
||||
form.Dispose();
|
||||
|
@ -9,7 +9,7 @@ sealed class TweetNotification{
|
||||
|
||||
private const string DefaultFontSizeClass = "medium";
|
||||
private const string DefaultHeadTag = @"<meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='chrome=1'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/font.5ef884f9f9.css'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/app-dark.5631e0dd42.css'><style type='text/css'>body{background:#222426}</style>";
|
||||
private const string CustomCSS = @"body:before{content:none}body{overflow-y:auto}.scroll-styled-v::-webkit-scrollbar{width:7px}.scroll-styled-v::-webkit-scrollbar-thumb{border-radius:0}.scroll-styled-v::-webkit-scrollbar-track{border-left:0}#td-skip{opacity:0;cursor:pointer;transition:opacity 0.15s ease}.td-hover #td-skip{opacity:0.75}#td-skip:hover{opacity:1}";
|
||||
private const string CustomCSS = @"body:before{content:none}body{overflow-y:auto}.scroll-styled-v::-webkit-scrollbar{width:7px}.scroll-styled-v::-webkit-scrollbar-thumb{border-radius:0}.scroll-styled-v::-webkit-scrollbar-track{border-left:0}#td-skip{opacity:0;cursor:pointer;transition:opacity 0.15s ease}.td-hover #td-skip{opacity:0.75}#td-skip:hover{opacity:1}.media-size-medium{height:calc(100vh - 16px)!important;max-height:240px;border-radius:1px!important}.js-quote-detail .media-size-medium{height:calc(100vh - 28px)!important;}.js-media.margin-vm, .js-media-preview-container.margin-vm{margin-bottom:0!important}";
|
||||
|
||||
public static int FontSizeLevel{
|
||||
get{
|
||||
|
@ -63,6 +63,7 @@ private void InitializeComponent() {
|
||||
this.labelSize = new System.Windows.Forms.Label();
|
||||
this.panelMiscellaneous = new System.Windows.Forms.Panel();
|
||||
this.durationUpdateTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.checkMediaPreviews = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
|
||||
this.tableLayoutDurationButtons.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarDuration)).BeginInit();
|
||||
@ -273,11 +274,11 @@ private void InitializeComponent() {
|
||||
// checkSkipOnLinkClick
|
||||
//
|
||||
this.checkSkipOnLinkClick.AutoSize = true;
|
||||
this.checkSkipOnLinkClick.Location = new System.Drawing.Point(6, 28);
|
||||
this.checkSkipOnLinkClick.Location = new System.Drawing.Point(6, 51);
|
||||
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 = 1;
|
||||
this.checkSkipOnLinkClick.TabIndex = 2;
|
||||
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;
|
||||
@ -297,32 +298,32 @@ private void InitializeComponent() {
|
||||
// labelIdlePause
|
||||
//
|
||||
this.labelIdlePause.AutoSize = true;
|
||||
this.labelIdlePause.Location = new System.Drawing.Point(3, 83);
|
||||
this.labelIdlePause.Location = new System.Drawing.Point(3, 106);
|
||||
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);
|
||||
this.labelIdlePause.TabIndex = 3;
|
||||
this.labelIdlePause.TabIndex = 4;
|
||||
this.labelIdlePause.Text = "Pause When Idle";
|
||||
//
|
||||
// comboBoxIdlePause
|
||||
//
|
||||
this.comboBoxIdlePause.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxIdlePause.FormattingEnabled = true;
|
||||
this.comboBoxIdlePause.Location = new System.Drawing.Point(5, 99);
|
||||
this.comboBoxIdlePause.Location = new System.Drawing.Point(5, 122);
|
||||
this.comboBoxIdlePause.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.comboBoxIdlePause.Name = "comboBoxIdlePause";
|
||||
this.comboBoxIdlePause.Size = new System.Drawing.Size(144, 21);
|
||||
this.comboBoxIdlePause.TabIndex = 4;
|
||||
this.comboBoxIdlePause.TabIndex = 5;
|
||||
this.toolTip.SetToolTip(this.comboBoxIdlePause, "Pauses new notifications after going idle for a set amount of time.");
|
||||
//
|
||||
// checkNonIntrusive
|
||||
//
|
||||
this.checkNonIntrusive.AutoSize = true;
|
||||
this.checkNonIntrusive.Location = new System.Drawing.Point(6, 51);
|
||||
this.checkNonIntrusive.Location = new System.Drawing.Point(6, 74);
|
||||
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 = 3;
|
||||
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;
|
||||
@ -389,6 +390,7 @@ private void InitializeComponent() {
|
||||
//
|
||||
this.panelGeneral.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panelGeneral.Controls.Add(this.checkMediaPreviews);
|
||||
this.panelGeneral.Controls.Add(this.checkColumnName);
|
||||
this.panelGeneral.Controls.Add(this.checkSkipOnLinkClick);
|
||||
this.panelGeneral.Controls.Add(this.checkNonIntrusive);
|
||||
@ -396,7 +398,7 @@ private void InitializeComponent() {
|
||||
this.panelGeneral.Controls.Add(this.comboBoxIdlePause);
|
||||
this.panelGeneral.Location = new System.Drawing.Point(9, 31);
|
||||
this.panelGeneral.Name = "panelGeneral";
|
||||
this.panelGeneral.Size = new System.Drawing.Size(322, 126);
|
||||
this.panelGeneral.Size = new System.Drawing.Size(322, 149);
|
||||
this.panelGeneral.TabIndex = 1;
|
||||
//
|
||||
// labelScrollSpeedValue
|
||||
@ -437,7 +439,7 @@ private void InitializeComponent() {
|
||||
//
|
||||
this.labelLocation.AutoSize = true;
|
||||
this.labelLocation.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelLocation.Location = new System.Drawing.Point(6, 372);
|
||||
this.labelLocation.Location = new System.Drawing.Point(6, 395);
|
||||
this.labelLocation.Margin = new System.Windows.Forms.Padding(0, 21, 0, 0);
|
||||
this.labelLocation.Name = "labelLocation";
|
||||
this.labelLocation.Size = new System.Drawing.Size(70, 20);
|
||||
@ -458,7 +460,7 @@ private void InitializeComponent() {
|
||||
this.panelLocation.Controls.Add(this.radioLocBL);
|
||||
this.panelLocation.Controls.Add(this.radioLocCustom);
|
||||
this.panelLocation.Controls.Add(this.radioLocBR);
|
||||
this.panelLocation.Location = new System.Drawing.Point(9, 395);
|
||||
this.panelLocation.Location = new System.Drawing.Point(9, 418);
|
||||
this.panelLocation.Name = "panelLocation";
|
||||
this.panelLocation.Size = new System.Drawing.Size(322, 165);
|
||||
this.panelLocation.TabIndex = 5;
|
||||
@ -473,7 +475,7 @@ private void InitializeComponent() {
|
||||
this.panelTimer.Controls.Add(this.checkTimerCountDown);
|
||||
this.panelTimer.Controls.Add(this.labelDurationValue);
|
||||
this.panelTimer.Controls.Add(this.trackBarDuration);
|
||||
this.panelTimer.Location = new System.Drawing.Point(9, 204);
|
||||
this.panelTimer.Location = new System.Drawing.Point(9, 227);
|
||||
this.panelTimer.Name = "panelTimer";
|
||||
this.panelTimer.Size = new System.Drawing.Size(322, 144);
|
||||
this.panelTimer.TabIndex = 3;
|
||||
@ -492,7 +494,7 @@ private void InitializeComponent() {
|
||||
//
|
||||
this.labelTimer.AutoSize = true;
|
||||
this.labelTimer.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelTimer.Location = new System.Drawing.Point(6, 181);
|
||||
this.labelTimer.Location = new System.Drawing.Point(6, 204);
|
||||
this.labelTimer.Margin = new System.Windows.Forms.Padding(0, 21, 0, 0);
|
||||
this.labelTimer.Name = "labelTimer";
|
||||
this.labelTimer.Size = new System.Drawing.Size(48, 20);
|
||||
@ -503,7 +505,7 @@ private void InitializeComponent() {
|
||||
//
|
||||
this.labelSize.AutoSize = true;
|
||||
this.labelSize.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelSize.Location = new System.Drawing.Point(6, 584);
|
||||
this.labelSize.Location = new System.Drawing.Point(6, 607);
|
||||
this.labelSize.Margin = new System.Windows.Forms.Padding(0, 21, 0, 0);
|
||||
this.labelSize.Name = "labelSize";
|
||||
this.labelSize.Size = new System.Drawing.Size(40, 20);
|
||||
@ -519,7 +521,7 @@ private void InitializeComponent() {
|
||||
this.panelMiscellaneous.Controls.Add(this.labelScrollSpeedValue);
|
||||
this.panelMiscellaneous.Controls.Add(this.trackBarScrollSpeed);
|
||||
this.panelMiscellaneous.Controls.Add(this.labelScrollSpeed);
|
||||
this.panelMiscellaneous.Location = new System.Drawing.Point(9, 607);
|
||||
this.panelMiscellaneous.Location = new System.Drawing.Point(9, 630);
|
||||
this.panelMiscellaneous.Name = "panelMiscellaneous";
|
||||
this.panelMiscellaneous.Size = new System.Drawing.Size(322, 92);
|
||||
this.panelMiscellaneous.TabIndex = 7;
|
||||
@ -529,6 +531,18 @@ private void InitializeComponent() {
|
||||
this.durationUpdateTimer.Interval = 200;
|
||||
this.durationUpdateTimer.Tick += new System.EventHandler(this.durationUpdateTimer_Tick);
|
||||
//
|
||||
// checkMediaPreviews
|
||||
//
|
||||
this.checkMediaPreviews.AutoSize = true;
|
||||
this.checkMediaPreviews.Location = new System.Drawing.Point(6, 28);
|
||||
this.checkMediaPreviews.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.checkMediaPreviews.Name = "checkMediaPreviews";
|
||||
this.checkMediaPreviews.Size = new System.Drawing.Size(131, 17);
|
||||
this.checkMediaPreviews.TabIndex = 1;
|
||||
this.checkMediaPreviews.Text = "Show Media Previews";
|
||||
this.toolTip.SetToolTip(this.checkMediaPreviews, "Shows image and video thumbnails in the notification window.");
|
||||
this.checkMediaPreviews.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// TabSettingsNotifications
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -542,7 +556,7 @@ private void InitializeComponent() {
|
||||
this.Controls.Add(this.labelGeneral);
|
||||
this.Controls.Add(this.panelTimer);
|
||||
this.Name = "TabSettingsNotifications";
|
||||
this.Size = new System.Drawing.Size(340, 708);
|
||||
this.Size = new System.Drawing.Size(340, 731);
|
||||
this.ParentChanged += new System.EventHandler(this.TabSettingsNotifications_ParentChanged);
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).EndInit();
|
||||
this.tableLayoutDurationButtons.ResumeLayout(false);
|
||||
@ -601,5 +615,6 @@ private void InitializeComponent() {
|
||||
private System.Windows.Forms.Timer durationUpdateTimer;
|
||||
private System.Windows.Forms.RadioButton radioSizeCustom;
|
||||
private System.Windows.Forms.RadioButton radioSizeAuto;
|
||||
private System.Windows.Forms.CheckBox checkMediaPreviews;
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ public TabSettingsNotifications(FormNotificationMain notification){
|
||||
checkNotificationTimer.Checked = Config.DisplayNotificationTimer;
|
||||
checkTimerCountDown.Enabled = checkNotificationTimer.Checked;
|
||||
checkTimerCountDown.Checked = Config.NotificationTimerCountDown;
|
||||
checkMediaPreviews.Checked = Config.NotificationMediaPreviews;
|
||||
checkSkipOnLinkClick.Checked = Config.NotificationSkipOnLinkClick;
|
||||
checkNonIntrusive.Checked = Config.NotificationNonIntrusiveMode;
|
||||
|
||||
@ -96,6 +97,7 @@ public override void OnReady(){
|
||||
checkColumnName.CheckedChanged += checkColumnName_CheckedChanged;
|
||||
checkNotificationTimer.CheckedChanged += checkNotificationTimer_CheckedChanged;
|
||||
checkTimerCountDown.CheckedChanged += checkTimerCountDown_CheckedChanged;
|
||||
checkMediaPreviews.CheckedChanged += checkMediaPreviews_CheckedChanged;
|
||||
checkSkipOnLinkClick.CheckedChanged += checkSkipOnLinkClick_CheckedChanged;
|
||||
checkNonIntrusive.CheckedChanged += checkNonIntrusive_CheckedChanged;
|
||||
|
||||
@ -218,6 +220,10 @@ private void checkTimerCountDown_CheckedChanged(object sender, EventArgs e){
|
||||
notification.ShowNotificationForSettings(true);
|
||||
}
|
||||
|
||||
private void checkMediaPreviews_CheckedChanged(object sender, EventArgs e){
|
||||
Config.NotificationMediaPreviews = checkMediaPreviews.Checked;
|
||||
}
|
||||
|
||||
private void checkSkipOnLinkClick_CheckedChanged(object sender, EventArgs e){
|
||||
Config.NotificationSkipOnLinkClick = checkSkipOnLinkClick.Checked;
|
||||
}
|
||||
|
@ -124,26 +124,48 @@
|
||||
return false;
|
||||
};
|
||||
|
||||
let fixMedia = (html, media) => {
|
||||
return html.find(".js-media a[data-media-entity-id='"+media.mediaId+"']").css("background-image", 'url("'+media.thumb()+'")').removeClass("is-zoomable");
|
||||
};
|
||||
|
||||
return function(column, tweet){
|
||||
if (checkRecentTweet(tweet.id)){
|
||||
return;
|
||||
}
|
||||
|
||||
if (column.model.getHasNotification()){
|
||||
let previews = $TDX.notificationMediaPreviews;
|
||||
|
||||
let html = $(tweet.render({
|
||||
withFooter: false,
|
||||
withTweetActions: false,
|
||||
withMediaPreview: true,
|
||||
isMediaPreviewOff: true,
|
||||
isMediaPreviewSmall: false,
|
||||
isMediaPreviewLarge: false
|
||||
isMediaPreviewOff: !previews,
|
||||
isMediaPreviewSmall: previews,
|
||||
isMediaPreviewLarge: false,
|
||||
isMediaPreviewCompact: false,
|
||||
isMediaPreviewInQuoted: previews,
|
||||
thumbSizeClass: "media-size-medium"
|
||||
}));
|
||||
|
||||
|
||||
html.css("border", "0");
|
||||
html.find("footer").last().remove(); // apparently withTweetActions breaks for certain tweets, nice
|
||||
html.find(".js-media").last().remove(); // and quoted tweets still show media previews, nice nice
|
||||
html.find(".js-quote-detail").removeClass("is-actionable"); // prevent quoted tweets from changing the cursor
|
||||
|
||||
html.find(".js-quote-detail").removeClass("is-actionable margin-b--8"); // prevent quoted tweets from changing the cursor and reduce bottom margin
|
||||
|
||||
if (previews){
|
||||
html.find(".reverse-image-search").remove();
|
||||
|
||||
for(let media of tweet.getMedia()){
|
||||
fixMedia(html, media);
|
||||
}
|
||||
|
||||
if (tweet.quotedTweet){
|
||||
for(let media of tweet.quotedTweet.getMedia()){
|
||||
fixMedia(html, media).addClass("media-size-medium");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
html.find("a[href='#']").each(function(){ // remove <a> tags around links that don't lead anywhere (such as account names the tweet replied to)
|
||||
this.outerHTML = this.innerHTML;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user