document.addEventListener('DOMContentLoaded', function() {
    chrome.storage.sync.get({
        username: '',
        password: ''
    }, function(items) {
        malGenerator.username = items.username;
        malGenerator.password = items.password;
    });
    $.wait(500).then(function() {
        malGenerator.loginToMAL(malGenerator.username, malGenerator.password);
    });
    $.wait(4000).then(function() {
        malGenerator.whenLoad();
    });
 
});
 
(function($) {
    $.wait = function(time) {
        return $.Deferred(function(dfd) {
            setTimeout(dfd.resolve, time);
        }).promise();
    }
}(jQuery));