mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-30 05:34:06 +02:00
Rewrite custom selector in reply-account plugin to fix and futureproof TweetDeck changes
This commit is contained in:
parent
e8394b9c08
commit
5205d59b96
Resources/Plugins/reply-account
@ -8,7 +8,7 @@ Custom reply account
|
|||||||
chylex
|
chylex
|
||||||
|
|
||||||
[version]
|
[version]
|
||||||
1.1
|
1.2
|
||||||
|
|
||||||
[website]
|
[website]
|
||||||
https://tweetduck.chylex.com
|
https://tweetduck.chylex.com
|
||||||
|
@ -14,8 +14,20 @@ enabled(){
|
|||||||
|
|
||||||
if (configuration.useAdvancedSelector){
|
if (configuration.useAdvancedSelector){
|
||||||
if (configuration.customSelector){
|
if (configuration.customSelector){
|
||||||
var column = TD.controller.columnManager.get(data.element.closest("section.column").attr("data-column"));
|
var section = data.element.closest("section.column");
|
||||||
query = configuration.customSelector(column);
|
|
||||||
|
var column = TD.controller.columnManager.get(section.attr("data-column"));
|
||||||
|
var header = $("h1.column-title", section);
|
||||||
|
|
||||||
|
var columnTitle = header.children(".column-head-title").text();
|
||||||
|
var columnAccount = header.children(".attribution").text();
|
||||||
|
|
||||||
|
try{
|
||||||
|
query = configuration.customSelector(column.getColumnType(), columnTitle, columnAccount, column);
|
||||||
|
}catch(e){
|
||||||
|
$TD.alert("warning", "Plugin reply-account has invalid configuration: customSelector threw an error: "+e.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$TD.alert("warning", "Plugin reply-account has invalid configuration: useAdvancedSelector is true, but customSelector function is missing");
|
$TD.alert("warning", "Plugin reply-account has invalid configuration: useAdvancedSelector is true, but customSelector function is missing");
|
||||||
|
@ -34,42 +34,43 @@
|
|||||||
* The 'customSelector' function should return a string in one of the formats supported by 'defaultAccount'.
|
* The 'customSelector' function should return a string in one of the formats supported by 'defaultAccount'.
|
||||||
* If it returns anything else (for example, false or undefined), it falls back to 'defaultAccount' behavior.
|
* If it returns anything else (for example, false or undefined), it falls back to 'defaultAccount' behavior.
|
||||||
*
|
*
|
||||||
* The 'column' parameter is a TweetDeck column object. If you want to see all properties of the object, open your browser, nagivate to TweetDeck,
|
|
||||||
* log in, and run the following code in your browser console, which will return an object containing all of the column objects mapped to their IDs:
|
|
||||||
* TD.controller.columnManager.getAll()
|
|
||||||
*
|
|
||||||
* The example below shows how to extract the column type, title, and account from the object.
|
|
||||||
* Column type is prefixed with col_, and may be one of the following:
|
|
||||||
*
|
*
|
||||||
|
* 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_timeline, col_interactions, col_mentions, col_followers, col_search, col_list,
|
||||||
* col_customtimeline, col_messages, col_usertweets, col_favorites, col_activity,
|
* col_customtimeline, col_messages, col_usertweets, col_favorites, col_activity,
|
||||||
* col_dataminr, col_home, col_me, col_inbox, col_scheduled, col_unknown
|
* col_dataminr, col_home, col_me, col_inbox, col_scheduled, col_unknown
|
||||||
*
|
*
|
||||||
* Some of these appear to be unused (for example, Home columns are 'col_timeline' instead of 'col_home').
|
* If you want to see your current column types, run this in your browser console:
|
||||||
|
* TD.controller.columnManager.getAllOrdered().map(obj => obj.getColumnType());
|
||||||
*
|
*
|
||||||
* If you want to see your column types, run this in your browser console:
|
*
|
||||||
* Object.values(TD.controller.columnManager.getAll()).forEach(obj => console.log(obj.getColumnType()));
|
* The 'title' parameter is the column title. Some are fixed (such as 'Home' or 'Notifications'),
|
||||||
*
|
* some contain specific information (for example, Search columns contain the search query).
|
||||||
* You can also get the jQuery column object using: $("section.column[data-column='"+column.ui.state.columnKey+"']")
|
*
|
||||||
|
*
|
||||||
|
* The 'account' parameter is the account name displayed next to the column title (including the @).
|
||||||
|
* This parameter is empty for some columns (such as Messages, or Notifications for all accounts) or can
|
||||||
|
* contain other text (for example, the Scheduled column contains the string 'All accounts').
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* The 'column' parameter is a TweetDeck column object. If you want to see all properties of the object,
|
||||||
|
* run the following code in your browser console, which will return an array containing all of your
|
||||||
|
* current column objects in order:
|
||||||
|
* TD.controller.columnManager.getAllOrdered()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
useAdvancedSelector: false,
|
useAdvancedSelector: false,
|
||||||
|
|
||||||
/*customSelector: function(column){
|
/*customSelector: function(type, title, account, column){
|
||||||
var titleObj = $(column.getTitleHTML());
|
if (type === "col_search" && title === "TweetDuck"){
|
||||||
|
|
||||||
var columnType = column.getColumnType(); // col_timeline
|
|
||||||
var columnTitle = titleObj.siblings(".column-head-title").text(); // Home
|
|
||||||
var columnAccount = titleObj.siblings(".attribution").text(); // @chylexmc
|
|
||||||
|
|
||||||
if (columnType === "col_search" && columnTitle === "TweetDuck"){
|
|
||||||
// This is a search column that looks for 'TweetDuck' in the tweets,
|
// This is a search column that looks for 'TweetDuck' in the tweets,
|
||||||
// search columns are normally linked to the preferred account
|
// search columns are normally linked to the preferred account
|
||||||
// so this forces the @TryTweetDuck account to be used instead.
|
// so this forces the @TryTweetDuck account to be used instead.
|
||||||
return "@TryTweetDuck";
|
return "@TryTweetDuck";
|
||||||
}
|
}
|
||||||
else if (columnType === "col_timeline" && columnAccount === "@chylexcz"){
|
else if (type === "col_timeline" && account === "@chylexcz"){
|
||||||
// This is a Home column of my test account @chylexcz,
|
// This is a Home column of my test account @chylexcz,
|
||||||
// but I want to reply to tweets from my official account.
|
// but I want to reply to tweets from my official account.
|
||||||
return "@chylexmc";
|
return "@chylexmc";
|
||||||
|
Loading…
Reference in New Issue
Block a user