mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-02 11:34:08 +02:00
Add protection to prevent code.js from crashing if Twitter changes something again
This commit is contained in:
parent
5929067a3d
commit
1677b73ff8
@ -204,13 +204,15 @@
|
|||||||
//
|
//
|
||||||
// Block: Enable popup notifications.
|
// Block: Enable popup notifications.
|
||||||
//
|
//
|
||||||
TD.controller.notifications.hasNotifications = function(){
|
if (ensurePropertyExists(TD, "controller", "notifications")){
|
||||||
return true;
|
TD.controller.notifications.hasNotifications = function(){
|
||||||
};
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
TD.controller.notifications.isPermissionGranted = function(){
|
TD.controller.notifications.isPermissionGranted = function(){
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
$.subscribe("/notifications/new", function(obj){
|
$.subscribe("/notifications/new", function(obj){
|
||||||
for(let index = obj.items.length-1; index >= 0; index--){
|
for(let index = obj.items.length-1; index >= 0; index--){
|
||||||
@ -554,6 +556,10 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!ensurePropertyExists(TD, "vo", "Column", "prototype", "clear")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TD.vo.Column.prototype.clear = prependToFunction(TD.vo.Column.prototype.clear, function(){
|
TD.vo.Column.prototype.clear = prependToFunction(TD.vo.Column.prototype.clear, function(){
|
||||||
window.setTimeout(resetActiveFocus, 0); // unfocuses the Clear button, otherwise it steals keyboard input
|
window.setTimeout(resetActiveFocus, 0); // unfocuses the Clear button, otherwise it steals keyboard input
|
||||||
|
|
||||||
@ -576,7 +582,11 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$(".js-drawer[data-drawer='compose']").delegate(".js-account-list > .js-account-item", "click", toggleEventShiftKey);
|
$(".js-drawer[data-drawer='compose']").delegate(".js-account-list > .js-account-item", "click", toggleEventShiftKey);
|
||||||
|
|
||||||
|
if (!ensurePropertyExists(TD, "components", "AccountSelector", "prototype", "refreshPostingAccounts")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TD.components.AccountSelector.prototype.refreshPostingAccounts = appendToFunction(TD.components.AccountSelector.prototype.refreshPostingAccounts, function(){
|
TD.components.AccountSelector.prototype.refreshPostingAccounts = appendToFunction(TD.components.AccountSelector.prototype.refreshPostingAccounts, function(){
|
||||||
if (!this.$node.attr("td-account-selector-hook")){
|
if (!this.$node.attr("td-account-selector-hook")){
|
||||||
this.$node.attr("td-account-selector-hook", "1");
|
this.$node.attr("td-account-selector-hook", "1");
|
||||||
@ -631,6 +641,10 @@
|
|||||||
(function(){
|
(function(){
|
||||||
var cancelModal = false;
|
var cancelModal = false;
|
||||||
|
|
||||||
|
if (!ensurePropertyExists(TD, "components", "MediaGallery", "prototype", "_loadTweet") ||
|
||||||
|
!ensurePropertyExists(TD, "components", "BaseModal", "prototype", "setAndShowContainer") ||
|
||||||
|
!ensurePropertyExists(TD, "ui", "Column", "prototype", "playGifIfNotManuallyPaused"))return;
|
||||||
|
|
||||||
TD.components.MediaGallery.prototype._loadTweet = appendToFunction(TD.components.MediaGallery.prototype._loadTweet, function(){
|
TD.components.MediaGallery.prototype._loadTweet = appendToFunction(TD.components.MediaGallery.prototype._loadTweet, function(){
|
||||||
var media = this.chirp.getMedia().find(media => media.mediaId === this.clickedMediaEntityId);
|
var media = this.chirp.getMedia().find(media => media.mediaId === this.clickedMediaEntityId);
|
||||||
|
|
||||||
@ -662,38 +676,53 @@
|
|||||||
//
|
//
|
||||||
// Block: Fix youtu.be previews not showing up for https links.
|
// Block: Fix youtu.be previews not showing up for https links.
|
||||||
//
|
//
|
||||||
TD.services.TwitterMedia.YOUTUBE_TINY_RE = new RegExp(TD.services.TwitterMedia.YOUTUBE_TINY_RE.source.replace("http:", "https?:"));
|
if (ensurePropertyExists(TD, "services", "TwitterMedia")){
|
||||||
TD.services.TwitterMedia.YOUTUBE_RE = new RegExp(TD.services.TwitterMedia.YOUTUBE_LONG_RE.source+"|"+TD.services.TwitterMedia.YOUTUBE_TINY_RE.source);
|
var media = TD.services.TwitterMedia;
|
||||||
TD.services.TwitterMedia.SERVICES["youtube"] = TD.services.TwitterMedia.YOUTUBE_RE;
|
|
||||||
|
if (!ensurePropertyExists(media, "YOUTUBE_TINY_RE") ||
|
||||||
|
!ensurePropertyExists(media, "YOUTUBE_LONG_RE") ||
|
||||||
|
!ensurePropertyExists(media, "YOUTUBE_RE") ||
|
||||||
|
!ensurePropertyExists(media, "SERVICES", "youtube"))return;
|
||||||
|
|
||||||
|
media.YOUTUBE_TINY_RE = new RegExp(media.YOUTUBE_TINY_RE.source.replace("http:", "https?:"));
|
||||||
|
media.YOUTUBE_RE = new RegExp(media.YOUTUBE_LONG_RE.source+"|"+media.YOUTUBE_TINY_RE.source);
|
||||||
|
media.SERVICES["youtube"] = media.YOUTUBE_RE;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Block: Fix DM reply input box not getting focused after opening a conversation.
|
// Block: Fix DM reply input box not getting focused after opening a conversation.
|
||||||
//
|
//
|
||||||
TD.components.ConversationDetailView.prototype.showChirp = appendToFunction(TD.components.ConversationDetailView.prototype.showChirp, function(){
|
if (ensurePropertyExists(TD, "components", "ConversationDetailView", "prototype", "showChirp")){
|
||||||
setTimeout(function(){
|
TD.components.ConversationDetailView.prototype.showChirp = appendToFunction(TD.components.ConversationDetailView.prototype.showChirp, function(){
|
||||||
$(".js-reply-tweetbox").first().focus();
|
setTimeout(function(){
|
||||||
}, 100);
|
$(".js-reply-tweetbox").first().focus();
|
||||||
});
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Block: Fix DM notifications not showing if the conversation is open.
|
// Block: Fix DM notifications not showing if the conversation is open.
|
||||||
//
|
//
|
||||||
(function(prevFunc){
|
if (ensurePropertyExists(TD, "services", "TwitterConversation", "prototype", "getUnreadChirps")){
|
||||||
|
var prevFunc = TD.services.TwitterConversation.prototype.getUnreadChirps;
|
||||||
|
|
||||||
TD.services.TwitterConversation.prototype.getUnreadChirps = function(e){
|
TD.services.TwitterConversation.prototype.getUnreadChirps = function(e){
|
||||||
return (e && e.sortIndex && !e.id && !this.notificationsDisabled)
|
return (e && e.sortIndex && !e.id && !this.notificationsDisabled)
|
||||||
? this.messages.filter(t => t.chirpType === TD.services.ChirpBase.MESSAGE && !t.isOwnChirp() && !t.read && !t.belongsBelow(e)) // changed from belongsAbove
|
? this.messages.filter(t => t.chirpType === TD.services.ChirpBase.MESSAGE && !t.isOwnChirp() && !t.read && !t.belongsBelow(e)) // changed from belongsAbove
|
||||||
: prevFunc.apply(this, arguments);
|
: prevFunc.apply(this, arguments);
|
||||||
};
|
};
|
||||||
})(TD.services.TwitterConversation.prototype.getUnreadChirps);
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Block: Disable TweetDeck metrics.
|
// Block: Disable TweetDeck metrics.
|
||||||
//
|
//
|
||||||
TD.metrics.inflate = function(){};
|
if (ensurePropertyExists(TD, "metrics")){
|
||||||
TD.metrics.inflateMetricTriple = function(){};
|
TD.metrics.inflate = function(){};
|
||||||
TD.metrics.log = function(){};
|
TD.metrics.inflateMetricTriple = function(){};
|
||||||
TD.metrics.makeKey = function(){};
|
TD.metrics.log = function(){};
|
||||||
TD.metrics.send = function(){};
|
TD.metrics.makeKey = function(){};
|
||||||
|
TD.metrics.send = function(){};
|
||||||
|
}
|
||||||
|
|
||||||
onAppReady.push(function(){
|
onAppReady.push(function(){
|
||||||
let data = $._data(window);
|
let data = $._data(window);
|
||||||
@ -718,7 +747,9 @@
|
|||||||
//
|
//
|
||||||
// Block: Skip the initial pre-login page.
|
// Block: Skip the initial pre-login page.
|
||||||
//
|
//
|
||||||
TD.controller.init.showLogin = function(){
|
if (ensurePropertyExists(TD, "controller", "init", "showLogin")){
|
||||||
location.href = "https://twitter.com/login?hide_message=true&redirect_after_login=https%3A%2F%2Ftweetdeck.twitter.com%2F%3Fvia_twitter_login%3Dtrue";
|
TD.controller.init.showLogin = function(){
|
||||||
};
|
location.href = "https://twitter.com/login?hide_message=true&redirect_after_login=https%3A%2F%2Ftweetdeck.twitter.com%2F%3Fvia_twitter_login%3Dtrue";
|
||||||
|
};
|
||||||
|
}
|
||||||
})($, $TD, $TDX, TD);
|
})($, $TD, $TDX, TD);
|
||||||
|
Loading…
Reference in New Issue
Block a user