aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2025-06-13 00:48:31 +0200
committerache <ache@ache.one>2025-06-13 00:48:31 +0200
commit4b89f6af4d241c397600622279f0a845b3be0ac1 (patch)
tree6957ba4b5b355cd2f9d7f360a725ec4ebee789f7
parentPlugin popup fix (diff)
Add JS to popup menu
-rw-r--r--control.html10
-rw-r--r--control.js27
2 files changed, 33 insertions, 4 deletions
diff --git a/control.html b/control.html
index e7235d9..09c616e 100644
--- a/control.html
+++ b/control.html
@@ -7,9 +7,11 @@
<link href="control.css" rel="stylesheet">
</head>
<body>
- <img src="icons/certificate-48.png" id="logo">
- <h1>Cert Check</h1>
- <button>Export data as JSON</button>
- <button>Clear data</button>
+ <img src="icons/certificate-96.png" id="logo">
+ <h2>Cert Check</h2>
+ <br>
+ <button id="exportJSON">Export data as JSON</button>
+ <button id="clearData">Clear data</button>
+ <script src="control.js"></script>
</body>
</html>
diff --git a/control.js b/control.js
new file mode 100644
index 0000000..e1d346a
--- /dev/null
+++ b/control.js
@@ -0,0 +1,27 @@
+document.querySelector('#exportJSON').addEventListener('click', () => {
+ const data = JSON.stringify();
+ console.log("Ask to export in JSON");
+
+ chrome.runtime.sendMessage({export: "JSON"}, function(response) {
+ if (response && response.data && response.data != "") {
+ writeClipboardText(response.data);
+ }
+ });
+});
+
+document.querySelector('#clearData').addEventListener('click', () => {
+ const data = JSON.stringify();
+ chrome.runtime.sendMessage({clear: "<all>"}, function(response) {
+ if (response && response.status && response.status == "cleared") {
+ console.log("Cleared !");
+ }
+ });
+});
+
+async function writeClipboardText(text) {
+ try {
+ await navigator.clipboard.writeText(text);
+ } catch (error) {
+ console.error(error.message);
+ }
+}