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

Add plugin object validation to TDPF functions

This commit is contained in:
chylex 2020-06-07 10:28:55 +02:00
parent c578f36644
commit 1e8c62ac25

View File

@ -3,10 +3,18 @@
console.error("Missing $TDP");
}
const validatePluginObject = function(pluginObject){
if (!("$token" in pluginObject)){
throw "Invalid plugin object.";
}
};
//
// Block: Setup a simple JavaScript object configuration loader.
//
window.TDPF_loadConfigurationFile = function(pluginObject, fileNameUser, fileNameDefault, onSuccess, onFailure){
validatePluginObject(pluginObject);
let identifier = pluginObject.$id;
let token = pluginObject.$token;
@ -43,6 +51,8 @@
// Block: Setup a function to add/remove custom CSS.
//
window.TDPF_createCustomStyle = function(pluginObject){
validatePluginObject(pluginObject);
let element = document.createElement("style");
element.id = "plugin-" + pluginObject.$id + "-"+Math.random().toString(36).substring(2, 7);
document.head.appendChild(element);