From 2c2f860f26f86e913849801d6bfbecfdd35deece Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Sat, 14 Apr 2018 19:40:51 +0200 Subject: [PATCH] Fix issues caused by recent TweetDeck update (notifications, column styles, reply account) Closes #211 --- Resources/Plugins/reply-account/.meta | 2 +- Resources/Plugins/reply-account/browser.js | 10 ++++++-- .../reply-account/configuration.default.js | 23 +++++++++++-------- Resources/Scripts/code.js | 14 ++++++++++- Resources/Scripts/styles/browser.css | 6 ++--- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Resources/Plugins/reply-account/.meta b/Resources/Plugins/reply-account/.meta index d1d2865e..b6c25ed6 100644 --- a/Resources/Plugins/reply-account/.meta +++ b/Resources/Plugins/reply-account/.meta @@ -8,7 +8,7 @@ Custom reply account chylex [version] -1.2.4 +1.3 [website] https://tweetduck.chylex.com diff --git a/Resources/Plugins/reply-account/browser.js b/Resources/Plugins/reply-account/browser.js index 2c69352a..8fdff4f5 100644 --- a/Resources/Plugins/reply-account/browser.js +++ b/Resources/Plugins/reply-account/browser.js @@ -12,10 +12,16 @@ enabled(){ if (configuration.useAdvancedSelector){ if (configuration.customSelector){ - if (configuration.customSelector.toString().startsWith("function (column){")){ + let customSelectorDef = configuration.customSelector.toString(); + + if (customSelectorDef.startsWith("function (column){")){ $TD.alert("warning", "Plugin reply-account has invalid configuration: customSelector needs to be updated due to TweetDeck changes, please read the default configuration file for the updated guide"); return; } + else if (customSelectorDef.startsWith("function (type,")){ + $TD.alert("warning", "Plugin reply-account has invalid configuration: the type parameter is no longer present due to TweetDeck changes, please read the default configuration file for the updated guide"); + return; + } var section = data.element.closest("section.js-column"); @@ -35,7 +41,7 @@ enabled(){ } try{ - query = configuration.customSelector(column.getColumnType(), columnTitle, columnAccount, column, section.hasClass("column-temp")); + query = configuration.customSelector(columnTitle, columnAccount, column, section.hasClass("column-temp")); }catch(e){ $TD.alert("warning", "Plugin reply-account has invalid configuration: customSelector threw an error: "+e.message); return; diff --git a/Resources/Plugins/reply-account/configuration.default.js b/Resources/Plugins/reply-account/configuration.default.js index 44d697f3..0710a95d 100644 --- a/Resources/Plugins/reply-account/configuration.default.js +++ b/Resources/Plugins/reply-account/configuration.default.js @@ -30,14 +30,19 @@ * https://tweetduck.chylex.com/guide/#dev-tools * * - * The 'type' parameter is TweetDeck column type. Here is the full list of column types, note that some are - * unused and have misleading names (for example, Home columns are 'col_timeline' instead of 'col_home'): - * col_timeline, col_interactions, col_mentions, col_followers, col_search, col_list, - * col_customtimeline, col_messages, col_usertweets, col_favorites, col_activity, - * col_dataminr, col_home, col_me, col_inbox, col_scheduled, col_unknown + * In order to check the column type, use the 'column.isOfType' function. It is recommended to always put it + * last in an 'if' statement, because it is much more demanding than checking the title/account. + * + * Here is the full list of column types, note that some are unused and have misleading names. + * (for example, Home columns are 'col_timeline' instead of 'col_home') + * + * col_activity, col_customtimeline, col_dataminr, col_favorites, col_followers, col_home, + * col_inbox, col_interactions, col_list, col_livevideo, col_me, col_mentions, + * col_messages, col_scheduled, col_search, col_timeline, col_usertweets, col_unknown * * If you want to see your current column types, run this in your browser console: - * TD.controller.columnManager.getAllOrdered().map(obj => obj.getColumnType()); + * + * (c=>c.columnManager.getAllOrdered().map(o=>Object.keys(c.stats.columnNamespaces).find(t=>o.isOfType(t))).map(t=>t==""+void 0?"col_unknown":t))(TD.controller) * * * The 'title' parameter is the column title. Some are fixed (such as 'Home' or 'Notifications'), @@ -61,16 +66,16 @@ useAdvancedSelector: false, - customSelector: function(type, title, account, column, isTemporary){ + customSelector: function(title, account, column, isTemporary){ console.info(arguments); // Prints all arguments into the console - if (type === "col_search" && title === "TweetDuck"){ + if (title === "TweetDuck" && column.isOfType("col_search")){ // This is a search column that looks for 'TweetDuck' in the tweets, // search columns are normally linked to the preferred account // so this forces the @TryTweetDuck account to be used instead return "@TryTweetDuck"; } - else if (type === "col_timeline" && account === "@chylexcz"){ + else if (account === "@chylexcz" && column.isOfType("col_timeline")){ // This is a Home column of my test account @chylexcz, // but I want to reply to tweets from my official account return "@chylexmc"; diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 8aa6e3a7..ad962576 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -98,6 +98,13 @@ return value; }; + // + // Function: Retrieves column name + const getColumnName = function(column){ + let cached = column._tduck_type || (column._tduck_type = Object.keys(columnTypes).find(type => column.isOfType(type))); + return columnTypes[cached] || ""; + }; + // // Function: Event callback for a new tweet. // @@ -220,7 +227,7 @@ let tweetUrl = source ? source.getChirpURL() : ""; let quoteUrl = source && source.quotedTweet ? source.quotedTweet.getChirpURL() : ""; - $TD.onTweetPopup(column.model.privateState.apiid, chirpId, columnTypes[column.getColumnType()] || "", html.html(), duration, tweetUrl, quoteUrl); + $TD.onTweetPopup(column.model.privateState.apiid, chirpId, getColumnName(column), html.html(), duration, tweetUrl, quoteUrl); } if (column.model.getHasSound()){ @@ -1310,6 +1317,11 @@ }; } + // + // Block: Fix columns missing any identifiable attributes to allow individual styles. + // + TD.mustaches["column.mustache"] = TD.mustaches["column.mustache"].replace("{{columnclass}}\"", "{{columnclass}}\" data-td-icon=\"{{columniconclass}}\""); + // // Block: Remove column mouse wheel handler, which allows smooth scrolling inside columns, and horizontally scrolling column container when holding Shift. // diff --git a/Resources/Scripts/styles/browser.css b/Resources/Scripts/styles/browser.css index 565c5051..46d7d343 100644 --- a/Resources/Scripts/styles/browser.css +++ b/Resources/Scripts/styles/browser.css @@ -361,18 +361,18 @@ html[data-td-font='smallest'] .tweet-detail-wrapper .badge-verified:before { /* Fix cut off usernames in Messages column */ /********************************************/ -.column-type-message.is-shifted-1 .column-title-container { +[data-td-icon="icon-message"].is-shifted-1 .column-title-container { height: 100%; border-bottom-color: transparent; } -#tduck .column-type-message.is-shifted-1 .column-title-items { +#tduck [data-td-icon="icon-message"].is-shifted-1 .column-title-items { height: 100%; margin-left: 4px !important; padding-top: 1px; } -.column-type-message.is-shifted-1 .username { +[data-td-icon="icon-message"].is-shifted-1 .username { vertical-align: bottom; }