const storage = chrome.storage.local; var settings = null; function cityline_msg_start(status) { if(settings) { let settings_div=""; $("body").append(settings_div); let status_div=""; $("body").append(status_div); //console.log("dom append"); } } storage.get('settings', function (items) { if (items.settings) { settings = items.settings; } }); storage.get('status', function (items) { if (items.status && items.status=='ON') { cityline_msg_start(items.status); } else { console.log('no status found'); } });