From e5777bd81e864b93123bf67e4bf58fa5f8c76c09 Mon Sep 17 00:00:00 2001 From: DhruvJain1122 Date: Tue, 21 Dec 2021 15:37:29 +0530 Subject: [PATCH 1/2] Notes aren't Persistent #7 issue solved --- manifest.json | 3 ++- popup.css | 3 ++- popup.html | 7 ++++--- popup.js | 20 +++++++++++++++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/manifest.json b/manifest.json index c6577fe..9b2e0e6 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,8 @@ "version": "1.0", "manifest_version": 3, "permissions": [ - "tabs" + "tabs", + "storage" ], "action" : { "default_title": "EtherScan Scraper", diff --git a/popup.css b/popup.css index 15bce83..8dec59b 100644 --- a/popup.css +++ b/popup.css @@ -58,7 +58,8 @@ input[type=text] { } #scrapeButton { - height: 40vh; + height: 30px; + width: 95vw; } #prompt { diff --git a/popup.html b/popup.html index 59b6e53..720b0a1 100644 --- a/popup.html +++ b/popup.html @@ -14,9 +14,7 @@

EtherScan Address Notes Scraper

-
- -
+

Open 'etherscan.io/mynotes_address'? @@ -33,6 +31,9 @@

+
+ +
\ No newline at end of file diff --git a/popup.js b/popup.js index 1733b55..ad6b636 100644 --- a/popup.js +++ b/popup.js @@ -14,7 +14,14 @@ document.addEventListener('DOMContentLoaded', async() => { let addressNotes; // address notes returned from a scrape let displayNotes; // address notes being displayed in a table, whether all or just those returned from a search - + chrome.storage.sync.get(/* String or Array */["data"], function(items){ + // items = [ { "phasersTo": "awesome" } ] + addressNotes = items.data; + displayNotes = items.data; + // alert(displayNotes.length); + generateNotesTable(); + // console.log(items); + }); /** * Retrieves the currently focused tab * @returns {Promise<*>} @@ -122,11 +129,18 @@ document.addEventListener('DOMContentLoaded', async() => { if (addressNotes.length === 0) { generateError("There are no address notes"); } else { + chrome.storage.sync.set({ "data": displayNotes}, function(){ + // alert("hello"); + }); + // chrome.storage.sync.set({ "data2": displayNotes}, function(){ + // // alert("hello"); + // }); + document.getElementById("notes").style.display = "block"; document.getElementById("search").style.display = "block"; - document.getElementById("scrape").style.display = "none"; + // document.getElementById("scrape").style.display = "none"; document.getElementById("downloadButton").style.display = "block"; - + scrapeButton.innerText = "SCRAPE"; let div = document.getElementById("notes-table"); let table = document.createElement("table"); let tableBody = document.createElement("tbody"); From 489b1446f42ae813e7f12b883675bb8c800d760a Mon Sep 17 00:00:00 2001 From: DhruvJain1122 Date: Tue, 21 Dec 2021 15:52:59 +0530 Subject: [PATCH 2/2] bug fix --- popup.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/popup.js b/popup.js index ad6b636..ff5a831 100644 --- a/popup.js +++ b/popup.js @@ -19,7 +19,9 @@ document.addEventListener('DOMContentLoaded', async() => { addressNotes = items.data; displayNotes = items.data; // alert(displayNotes.length); - generateNotesTable(); + if(addressNotes.length > 0){ + generateNotesTable(); + } // console.log(items); }); /** @@ -126,12 +128,13 @@ document.addEventListener('DOMContentLoaded', async() => { * Either displays all scraped address note values, or address note values returned in a search. */ function generateNotesTable() { + chrome.storage.sync.set({ "data": displayNotes}, function(){ + // alert("hello"); + }); if (addressNotes.length === 0) { generateError("There are no address notes"); } else { - chrome.storage.sync.set({ "data": displayNotes}, function(){ - // alert("hello"); - }); + // chrome.storage.sync.set({ "data2": displayNotes}, function(){ // // alert("hello"); // });