+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);