1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-17 03:15:47 +02:00

Update t.co bypass to work for media and bio urls

This commit is contained in:
chylex 2017-09-05 21:47:22 +02:00
parent b1abf87320
commit 61d3ed891a

View File

@ -407,15 +407,49 @@
})(); })();
// //
// Block: Bypass t.co when clicking links. // Block: Bypass t.co when clicking links and media.
// //
$(document.body).delegate("a[data-full-url]", "click", function(e){ $(document.body).delegate("a[data-full-url]", "click", function(e){
$TD.openBrowser($(this).attr("data-full-url")); $TD.openBrowser($(this).attr("data-full-url"));
e.preventDefault(); e.preventDefault();
}); });
if (ensurePropertyExists(TD, "services", "TwitterUser", "prototype", "fromJSONObject")){
let prevFunc = TD.services.TwitterUser.prototype.fromJSONObject;
TD.services.TwitterUser.prototype.fromJSONObject = function(){
let obj = prevFunc.apply(this, arguments);
let e = arguments[0].entities;
if (e && e.url && e.url.urls && e.url.urls.length && e.url.urls[0].expanded_url){
obj.url = e.url.urls[0].expanded_url;
}
return obj;
};
}
if (ensurePropertyExists(TD, "services", "TwitterMedia", "prototype", "fromMediaEntity")){
let prevFunc = TD.services.TwitterMedia.prototype.fromMediaEntity;
TD.services.TwitterMedia.prototype.fromMediaEntity = function(){
let obj = prevFunc.apply(this, arguments);
let e = arguments[0];
if (e.expanded_url){
if (obj.url === obj.shortUrl){
obj.shortUrl = e.expanded_url;
}
obj.url = e.expanded_url;
}
return obj;
};
}
// //
// Block: Bypass t.co and include additional information in context menus. // Block: Include additional information in context menus.
// //
$(document.body).delegate("a", "contextmenu", function(){ $(document.body).delegate("a", "contextmenu", function(){
let me = $(this)[0]; let me = $(this)[0];
@ -716,9 +750,7 @@
$(".js-drawer[data-drawer='compose']").delegate(".js-account-list > .js-account-item", "click", onAccountClick); $(".js-drawer[data-drawer='compose']").delegate(".js-account-list > .js-account-item", "click", onAccountClick);
if (!ensurePropertyExists(TD, "components", "AccountSelector", "prototype", "refreshPostingAccounts")){ return 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")){