1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-28 09:15:46 +02:00
TweetDuck/Resources/code.js

32 lines
811 B
JavaScript

(function($,$TD){
//
// Variable: Says whether TweetDick events was initialized.
//
var isInitialized = false;
//
// Function: Initializes TweetDick events. Called after the website app is loaded.
//
var initializeTweetDick = function(){
isInitialized = true;
};
//
// Block: Observe the app <div> element and initialize TweetDick whenever possible.
//
var app = $("body").children(".js-app");
new MutationObserver(function(mutations){
if (mutations.some(mutation => mutation.attributeName === "class")){
if (isInitialized && app.hasClass("is-hidden")){
isInitialized = false;
}
else if (!isInitialized && !app.hasClass("is-hidden")){
initializeTweetDick();
}
}
}).observe(app[0],{
attributes: true
});
})($,$TD);