class Disclosure { constructor(root) { this.root = root; this.$ = (id) => root.getElementById(id); } async accept() { try { const reply = await chrome.runtime.sendMessage({ cmd: "accept" }); if (!reply || reply.error) { throw new Error(reply ? reply.error : "The background worker did not answer"); } this.$("error").textContent = ""; this.$("done").textContent = "Accepted. Open the extension popup, connect your device secret and switch sharing on."; } catch (error) { this.$("error").textContent = error.message; } } decline() { this.$("done").textContent = "Nothing was enabled. You can close this tab."; } start() { this.$("accept").addEventListener("click", () => this.accept()); this.$("decline").addEventListener("click", () => this.decline()); } } new Disclosure(document).start();