mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-23 03:15:48 +02:00
Add a global function to easily add custom styles in plugins
This commit is contained in:
parent
2c30613279
commit
be77f753e7
@ -34,4 +34,21 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//
|
||||
// Block: Setup a function to add/remove custom CSS.
|
||||
//
|
||||
window.TDPF_createCustomStyle = function(pluginObject){
|
||||
var element = document.createElement("style");
|
||||
element.id = "plugin-"+pluginObject.$id+"-"+Math.random().toString(36).substring(2, 7);
|
||||
document.head.appendChild(element);
|
||||
|
||||
var obj = {
|
||||
insert: (rule) => element.sheet.insertRule(rule, 0),
|
||||
remove: () => $(element).remove()
|
||||
};
|
||||
|
||||
obj.element = element;
|
||||
return obj;
|
||||
};
|
||||
})($TDP);
|
Loading…
Reference in New Issue
Block a user