]> saetta.ns0.it Git - zakbrowse/extension/commitdiff
First draft. master
authorAndrea Zagli <azagli@libero.it>
Sat, 1 Apr 2023 07:11:32 +0000 (09:11 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 1 Apr 2023 07:11:32 +0000 (09:11 +0200)
.gitignore [new file with mode: 0644]
icons/border-48.png [new file with mode: 0644]
manifest.json [new file with mode: 0644]
options.html [new file with mode: 0644]
options.js [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..5fd42d7
--- /dev/null
@@ -0,0 +1 @@
+*.~*~
diff --git a/icons/border-48.png b/icons/border-48.png
new file mode 100644 (file)
index 0000000..90687de
Binary files /dev/null and b/icons/border-48.png differ
diff --git a/manifest.json b/manifest.json
new file mode 100644 (file)
index 0000000..13c7aaf
--- /dev/null
@@ -0,0 +1,23 @@
+{
+
+       "manifest_version": 2,
+       "name": "ZakBrowse",
+       "version": "1.0",
+
+       "description": "Sync history between devices.",
+
+       "icons": {
+               "48": "icons/border-48.png"
+       },
+
+       "permissions": [
+               "storage",
+               "history"
+       ],
+
+       "options_ui": {
+               "page": "options.html",
+               "browser_style": true
+       }
+
+}
diff --git a/options.html b/options.html
new file mode 100644 (file)
index 0000000..5f8fd29
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+
+<html lang="en">
+  <head>
+    <meta charset="utf-8" />
+  </head>
+
+  <body>
+    <form>
+      <label for="server">Server URL</label>
+      <input type="text" id="server" name="server" />
+      <button type="submit">Save</button>
+    </form>
+    <button id="btn_history">History</button>
+       <div id="history"></div>
+    <script src="options.js"></script>
+  </body>
+</html>
diff --git a/options.js b/options.js
new file mode 100644 (file)
index 0000000..2091361
--- /dev/null
@@ -0,0 +1,42 @@
+function saveOptions(e) {
+  browser.storage.local.set({
+    server: document.querySelector("#server").value
+  });
+  e.preventDefault();
+}
+
+function restoreOptions() {
+  let gettingItem = browser.storage.local.get('server');
+  gettingItem.then((res) => {
+      document.querySelector("#server").value = res.server || 'https://127.0.0.1:9090';
+  });
+}
+
+function history() {
+       let list = document.getElementById('history');
+       list.innerHTML = "";
+
+       let li = document.createElement('p');
+       li.innerText = "HISTORY";
+       list.appendChild(li);
+
+       let searchingHistory = browser.history.search({text: "", maxResults: 5});
+       searchingHistory.then((results) => {
+               if (results.length < 1) {
+                       let li = document.createElement('p');
+                       li.innerText = "NO HISTORY";
+                       list.appendChild(li);
+               } else {
+                       for (let k in results) {
+                               let history = results[k];
+                               let li = document.createElement('p');
+                               li.innerText = history.url;
+                               list.appendChild(li);
+                       }
+               }
+       });
+}
+
+document.addEventListener('DOMContentLoaded', restoreOptions);
+document.querySelector("form").addEventListener("submit", saveOptions);
+document.getElementById("btn_history").addEventListener("click", history);