const {St, Clutter, Soup} = imports.gi; const Main = imports.ui.main; const Self = imports.misc.extensionUtils.getCurrentExtension(); const Timer = Self.imports.timer; let panelButton; function getFront() { let soupSyncSession = new Soup.SessionSync(); let message = Soup.Message.new('GET', "https://home.cetacean.club/front"); let responseCode = soupSyncSession.send_message(message); let res; if(responseCode == 200) { return message['response-body'].data; } } function updateButton() { let panelButtonText = new St.Label({ text : getFront(), y_align: Clutter.ActorAlign.CENTER, }); panelButton.set_child(panelButtonText); } function init() { panelButton = new St.Bin({ style_class : "panel-button", }); } function enable() { updateButton(); Main.panel._rightBox.insert_child_at_index(panelButton, 0); let timer = new Timer.AFTimer(); timer.registerCallback(updateButton); timer.setMinutes(5); timer.start(); } function disable() { Main.panel._rightBox.remove_child(panelButton); let timer = new Timer.AFTimer(); timer.cleanup(); }