mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-31 08:34:10 +02:00
Add plugin object validation to TDPF functions
This commit is contained in:
parent
c578f36644
commit
1e8c62ac25
@ -3,10 +3,18 @@
|
|||||||
console.error("Missing $TDP");
|
console.error("Missing $TDP");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const validatePluginObject = function(pluginObject){
|
||||||
|
if (!("$token" in pluginObject)){
|
||||||
|
throw "Invalid plugin object.";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Block: Setup a simple JavaScript object configuration loader.
|
// Block: Setup a simple JavaScript object configuration loader.
|
||||||
//
|
//
|
||||||
window.TDPF_loadConfigurationFile = function(pluginObject, fileNameUser, fileNameDefault, onSuccess, onFailure){
|
window.TDPF_loadConfigurationFile = function(pluginObject, fileNameUser, fileNameDefault, onSuccess, onFailure){
|
||||||
|
validatePluginObject(pluginObject);
|
||||||
|
|
||||||
let identifier = pluginObject.$id;
|
let identifier = pluginObject.$id;
|
||||||
let token = pluginObject.$token;
|
let token = pluginObject.$token;
|
||||||
|
|
||||||
@ -43,6 +51,8 @@
|
|||||||
// Block: Setup a function to add/remove custom CSS.
|
// Block: Setup a function to add/remove custom CSS.
|
||||||
//
|
//
|
||||||
window.TDPF_createCustomStyle = function(pluginObject){
|
window.TDPF_createCustomStyle = function(pluginObject){
|
||||||
|
validatePluginObject(pluginObject);
|
||||||
|
|
||||||
let element = document.createElement("style");
|
let element = document.createElement("style");
|
||||||
element.id = "plugin-" + pluginObject.$id + "-"+Math.random().toString(36).substring(2, 7);
|
element.id = "plugin-" + pluginObject.$id + "-"+Math.random().toString(36).substring(2, 7);
|
||||||
document.head.appendChild(element);
|
document.head.appendChild(element);
|
||||||
|
Loading…
Reference in New Issue
Block a user