1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-06 14:34:05 +02:00

Add a way to register callbacks when $TDX property object gets updated

This commit is contained in:
chylex 2020-02-16 14:38:46 +01:00
parent 9480ba26e0
commit c1aefc7163
3 changed files with 18 additions and 2 deletions
Core/Bridge
Resources/Scripts

View File

@ -12,7 +12,7 @@ public static string GenerateScript(Environment environment){
static string Str(string value) => $"\"{value}\";";
UserConfig config = Program.Config.User;
StringBuilder build = new StringBuilder(128).Append("(function(x){");
StringBuilder build = new StringBuilder(384).Append("(function(x){");
build.Append("x.expandLinksOnHover=").Append(Bool(config.ExpandLinksOnHover));
@ -29,7 +29,7 @@ public static string GenerateScript(Environment environment){
build.Append("x.skipOnLinkClick=").Append(Bool(config.NotificationSkipOnLinkClick));
}
return build.Append("})(window.$TDX=window.$TDX||{})").ToString();
return build.Append("})(window.$TDX=window.$TDX||{});if(window.TDGF_onPropertiesUpdated)window.TDGF_onPropertiesUpdated()").ToString();
}
}
}

View File

@ -1716,6 +1716,21 @@
window.TDGF_reload = function(){}; // redefine to prevent reloading multiple times
};
//
// Block: Setup global functions to respond to updating $TDX properties.
//
(function(){
var callbacks = [];
window.TDGF_registerPropertyUpdateCallback = function(callback){
callbacks.push(callback);
};
window.TDGF_onPropertiesUpdated = function(){
callbacks.forEach(func => func($TDX));
};
})();
//
// Block: Disable default TweetDeck update notification.
//

View File

@ -123,6 +123,7 @@
window.TDPF_reloadColumns = window.TDGF_reloadColumns;
window.TDPF_prioritizeNewestEvent = window.TDGF_prioritizeNewestEvent;
window.TDPF_injectMustache = window.TDGF_injectMustache;
window.TDPF_registerPropertyUpdateCallback = window.TDGF_registerPropertyUpdateCallback;
window.TDPF_playVideo = function(urlOrObject, username){
if (typeof urlOrObject === "string"){