-
-
Notifications
You must be signed in to change notification settings - Fork 25
Plugins꞉ 2. Global functions
Plugins have access to the following functions which are defined globally in the window
object. Please note that not all functions are available in both browser.js
and notification.js
.
Some functions have a pluginObject
parameter which requires you to pass the plugin object itself into the function - you can do that by passing this
, but don't forget that this
will have different meaning based on the context:
enabled(){
let obj = this; // 'this' is the plugin object
let f = () => {
// arrow function does not change the context, 'this' is the plugin object
};
let h = function(){
// normal function changes the context, 'this' is not the plugin object!
};
}
Signature | void TDPF_loadConfigurationFile(pluginObject, pathConfigFile, pathConfigDefault, onSuccess, onFailure) |
Available |
browser.js notification.js
|
Since | 1.3.3 |
Reads a JavaScript object from a file, usually used to read user configuration. Note that onSuccess
may be called before or after ready()
, do not execute any code that relies on the configuration until you receive the result.
-
pathConfigFile - path to the created config file, should be same as
[configfile]
-
pathConfigDefault - path to the default config file, should be same as
[configdefault]
- onSuccess - function that takes the read JavaScript object
- onFailure (optional) - function that takes an exception object or a string with an error message if the process failed; should return true to prevent default error handling, which displays an alert window to the user
enabled(){
this.configuration = { columnWidth: "310px" };
window.TDPF_loadConfigurationFile(this, "configuration.js", "configuration.default.js", obj => this.configuration = obj);
}
Signature | object TDPF_createCustomStyle(pluginObject) |
Available |
browser.js notification.js
|
Since | 1.4.1 |
Creates a new <style> element on the page, and returns an object with the following properties:
- insert(rule) - function that takes a single CSS rule and inserts it into the style element
-
remove() - function that removes the style element, don't forget to call this in
disabled()
-
element - property containing the
HTMLElement
object
enabled(){
this.css = window.TDPF_createCustomStyle(this);
this.css.insert(".avatar { border-radius: 0 !important }");
this.css.insert(".column { width: 500px !important }");
}
disabled(){
this.css.remove();
}
Signature | void TDPF_getColumnName(column) |
Available | browser.js |
Since | 1.13.5 |
Retrieves the column name, such as Home, Notifications, or Search.
-
column - the column object; see
TD.controller.columnManager
methods that let you retrieve all or individual column objects
Signature | void TDPF_injectMustache(mustache, operation, search, html) |
Available | browser.js |
Since | 1.14 |
Performs one of available operations on a mustache template. All declared mustaches are in the TD.mustaches
object.
- mustache - name of the mustache
-
operation - one of
replace
,prepend
,append
- search - the searched substring inside the mustache
- html - the string which, based on the operation, will either replace the searched substring, or be inserted before or after it
enabled(){
this.prevThumbnailMustache = window.TDGF_injectMustache("status/media_thumb.mustache", "append", "is-gif", " is-paused");
}
disabled(){
TD.mustaches["status/media_thumb.mustache"] = this.prevThumbnailMustache;
}
Signature | void TDPF_playVideo(url, username) |
Available | browser.js |
Since | 1.10.3 |
Plays a video file from URL using the integrated video player.
- url is the direct link to a video file
- username is an optional username which will be used in the file name if the user saves the video
Signature | void TDPF_prioritizeNewestEvent(element, event) |
Available | browser.js |
Since | 1.11 |
Event handlers are normally executed in the same order they were added. This function reprioritizes the most recently added event handler to run first instead, to allow stopping its propagation before it hits events added by TweetDeck. The event must be added using jQuery, i.e. using on()
, delegate()
, or a shortcut function such as click()
.
- element is the target element object (the element must not be wrapped in a jQuery object)
- event is the name of the event
Signature | void TDPF_reloadColumns() |
Available | browser.js |
Since | 1.11.1 |
Convenience function to re-render tweets in all columns.
Signature | void alert(text) |
Signature | bool confirm(text) |
Signature | string prompt(text) |
Available |
browser.js notification.js
|
Since | 1.9 |
These 3 functions are from vanilla JavaScript. They display a message, optionally with Yes/No buttons (confirm
) or a text input (prompt
). Use \n
for new lines. You can add an icon to the message by prefixing the text:
info|your message
question|your message
warning|your message
error|your message
App Documentation | 1. User interface | 2. Notifications | 3. Plugins | 4. Advanced |
Plugin Development |
1. The basics | 2. Global functions | 3. Bridge object | 4. Remote functions | 5. Browser window | 6. Notification window |
Miscellaneous | Send anonymous data | Supported systems | Troubleshooting |