1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-21 03:54:07 +02:00
Files
.github
.idea
bld
lib
linux
resources
Content
api
error
images
introduction
login
notification
plugins
tweetdeck
globals
add_tweetduck_to_settings_menu.js
bypass_t.co_links.js
clear_search_input.js
configure_first_day_of_week.js
configure_language_for_translations.js
disable_clipboard_formatting.js
disable_td_metrics.js
disable_tweetdeck_preview.js
drag_links_onto_columns.js
expand_links_or_show_tooltip.js
fix_dm_input_box_focus.js
fix_horizontal_scrolling_of_column_container.js
fix_marking_dm_as_read_when_replying.js
fix_media_preview_urls.js
fix_missing_bing_translator_languages.js
fix_os_name.js
fix_scheduled_tweets_not_appearing.js
fix_youtube_previews.js
focus_composer_after_alt_tab.js
focus_composer_after_image_upload.js
focus_composer_after_switching_account.js
handle_extra_mouse_buttons.js
hook_theme_settings.js
inject_css.js
keep_like_follow_dialogs_open.js
limit_loaded_dm_count.js
make_retweets_lowercase.js
middle_click_tweet_icon_actions.js
move_accounts_above_hashtags_in_search.js
mute_accounts_with_nft_avatars.js
offline_notification.js
open_search_externally.js
open_search_in_first_column.js
paste_images_from_clipboard.js
perform_search.js
pin_composer_icon.js
ready_plugins.js
register_composer_active_event.js
register_global_functions.js
register_global_functions_jquery.js
restore_cleared_column.js
screenshot_tweet.js
setup_column_type_attributes.js
setup_desktop_notifications.js
setup_link_context_menu.js
setup_sound_notifications.js
setup_tweet_context_menu.js
setup_tweetduck_account_bamboozle.js
setup_video_player.js
skip_pre_login_page.js
tweetdeck.css
tweetdeck_preview_warning.js
update
.all.js
bootstrap.js
load.js
Design
Guide
Plugins
..code-workspace
windows
.gitattributes
.gitignore
LICENSE.md
README.md
TweetDuck.sln
TweetDuck.sln.DotSettings
Version.cs
global.json
TweetDuck/resources/Content/tweetdeck/middle_click_tweet_icon_actions.js

96 lines
2.1 KiB
JavaScript

import { $ } from "../api/jquery.js";
import { TD } from "../api/td.js";
/**
* @param {HTMLElement} ele
* @param {ChirpBase} tweet
*/
function replyInComposeDrawer(ele, tweet) {
const main = tweet.getMainTweet();
// noinspection JSUnusedGlobalSymbols
$(document).trigger("uiDockedComposeTweet", {
type: "reply",
from: [ tweet.account.getKey() ],
inReplyTo: {
id: tweet.id,
htmlText: main.htmlText,
user: {
screenName: main.user.screenName,
name: main.user.name,
profileImageURL: main.user.profileImageURL
}
},
mentions: tweet.getReplyUsers(),
element: ele
});
}
/**
* @param {ChirpBase} tweet
*/
function openFavoriteDialog(tweet) {
$(document).trigger("uiShowFavoriteFromOptions", { tweet });
}
/**
* @param {HTMLElement} ele
* @param {ChirpBase} tweet
*/
function quoteTweet(ele, tweet) {
TD.controller.stats.quoteTweet();
$(document).trigger("uiComposeTweet", {
type: "tweet",
from: [ tweet.account.getKey() ],
quotedTweet: tweet.getMainTweet(),
element: ele // triggers reply-account plugin
});
}
/**
* Adds support for middle-clicking icons under tweets for alternative behaviors:
* - Reply icon opens the compose drawer
* - Favorite icon open a 'Like from accounts...' dialog
* - Retweet icon triggers a quote
*/
export default function() {
$(".js-app").delegate(".tweet-action,.tweet-detail-action", "auxclick", function(e) {
if (e.which !== 2) {
return;
}
const column = TD.controller.columnManager.get($(this).closest("section.js-column").attr("data-column"));
if (!column) {
return;
}
const ele = $(this).closest("article");
const tweet = column.findChirp(ele.attr("data-tweet-id")) || column.findChirp(ele.attr("data-key"));
if (!tweet) {
return;
}
switch ($(this).attr("rel")) {
case "reply":
replyInComposeDrawer(ele, tweet);
break;
case "favorite":
openFavoriteDialog(tweet);
break;
case "retweet":
quoteTweet(ele, tweet);
break;
default:
return;
}
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
});
};