-
-
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, fileNameUser, fileNameDefault, onSuccess, onDefault) |
Available |
browser.js notification.js
|
Since | 1.3.3 |
Reads a JavaScript object from a file, usually used to read user configuration.
-
fileNameUser - path to the user configuration file, should be same as
[configfile]
in.meta
-
fileNameDefault - path to the default configuration file, should be same as
[configdefault]
in.meta
- 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
var configuration = { defaultAccount: "#preferred" };
window.TDPF_loadConfigurationFile(this, "configuration.js", "configuration.default.js", obj => 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:
-
element - property containing the
HTMLElement
object - insert(rule) - function that takes a CSS-formatted string and inserts it into the style element
-
remove() - function that removes the style element, don't forget to call this in
disabled()
enabled(){
this.css = window.TDPF_createCustomStyle(this);
this.css.insert(".tweet-actions { float: right !important; width: auto !important; }");
this.css.insert(".tweet-action { opacity: 0; }");
this.css.insert(".is-favorite .tweet-action, .is-retweet .tweet-action { opacity: 0.5; visibility: visible !important; }");
this.css.insert(".tweet:hover .tweet-action, .is-favorite .tweet-action[rel='favorite'], .is-retweet .tweet-action[rel='retweet'] { opacity: 1; visibility: visible !important; }");
this.css.insert(".tweet-actions > li:nth-child(4) { margin-right: 2px !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, custom) |
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
- custom - the string which, based on the operation, will either replace the searched substring, or be inserted before or after it
window.TDGF_injectMustache("status/media_thumb.mustache", "append", "is-gif", " is-paused");
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 (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 regular JavaScript. They have no icon by default, but a custom icon can be set by prefixing the message 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 |