diff --git a/Nostore.xcodeproj/project.pbxproj b/Nostore.xcodeproj/project.pbxproj index 1075dea..97ecc4c 100644 --- a/Nostore.xcodeproj/project.pbxproj +++ b/Nostore.xcodeproj/project.pbxproj @@ -81,6 +81,8 @@ 948C69E3297F891F00FB3574 /* options.build.js in Resources */ = {isa = PBXBuildFile; fileRef = 948C69E1297F891F00FB3574 /* options.build.js */; }; 948C69E5297F8BA600FB3574 /* options.build.css in Resources */ = {isa = PBXBuildFile; fileRef = 948C69E4297F8BA600FB3574 /* options.build.css */; }; 948C69E6297F8BA600FB3574 /* options.build.css in Resources */ = {isa = PBXBuildFile; fileRef = 948C69E4297F8BA600FB3574 /* options.build.css */; }; + 948C69E82982DFE900FB3574 /* background.html in Resources */ = {isa = PBXBuildFile; fileRef = 948C69E72982DFE900FB3574 /* background.html */; }; + 948C69E92982DFE900FB3574 /* background.html in Resources */ = {isa = PBXBuildFile; fileRef = 948C69E72982DFE900FB3574 /* background.html */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -174,6 +176,7 @@ 948C69DC297F88A200FB3574 /* options.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = options.js; sourceTree = ""; }; 948C69E1297F891F00FB3574 /* options.build.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = options.build.js; sourceTree = ""; }; 948C69E4297F8BA600FB3574 /* options.build.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = options.build.css; sourceTree = ""; }; + 948C69E72982DFE900FB3574 /* background.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = background.html; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -273,6 +276,7 @@ 941B03A8296FA90400CA291E /* popup.html */, 941B03A9296FA90400CA291E /* popup.css */, 941B03AA296FA90400CA291E /* popup.js */, + 948C69E72982DFE900FB3574 /* background.html */, ); path = Resources; sourceTree = ""; @@ -495,6 +499,7 @@ buildActionMask = 2147483647; files = ( 941B0413297110F100CA291E /* background.build.js in Resources */, + 948C69E82982DFE900FB3574 /* background.html in Resources */, 948C69DF297F88A200FB3574 /* options.js in Resources */, 948C69DD297F88A200FB3574 /* options.css in Resources */, 941B03F2296FA90400CA291E /* background.js in Resources */, @@ -528,6 +533,7 @@ buildActionMask = 2147483647; files = ( 941B0414297110F100CA291E /* background.build.js in Resources */, + 948C69E92982DFE900FB3574 /* background.html in Resources */, 948C69E0297F88A200FB3574 /* options.js in Resources */, 948C69DE297F88A200FB3574 /* options.css in Resources */, 941B03F3296FA90400CA291E /* background.js in Resources */, diff --git a/Shared (Extension)/Resources/background.html b/Shared (Extension)/Resources/background.html new file mode 100644 index 0000000..bb54024 --- /dev/null +++ b/Shared (Extension)/Resources/background.html @@ -0,0 +1 @@ + diff --git a/Shared (Extension)/Resources/background.js b/Shared (Extension)/Resources/background.js index 29f3c87..0b84c33 100644 --- a/Shared (Extension)/Resources/background.js +++ b/Shared (Extension)/Resources/background.js @@ -27,6 +27,9 @@ browser.runtime.onMessage.addListener( console.log(message); switch (message.kind) { + case 'log': + console.log('Background Log: ', message.payload); + break; case 'init': await initialize(); break; @@ -101,6 +104,7 @@ browser.runtime.onMessage.addListener( default: break; } + return false; } ); @@ -121,7 +125,12 @@ async function getOrSetDefault(key, def) { async function initialize() { await getOrSetDefault('profileIndex', 0); await getOrSetDefault('profiles', [ - { name: 'Default', privKey: generatePrivateKey(), hosts: [] }, + { + name: 'Default', + privKey: generatePrivateKey(), + hosts: [], + relays: [], + }, ]); } diff --git a/Shared (Extension)/Resources/manifest.json b/Shared (Extension)/Resources/manifest.json index ff1458f..0e68c68 100644 --- a/Shared (Extension)/Resources/manifest.json +++ b/Shared (Extension)/Resources/manifest.json @@ -12,8 +12,7 @@ "512": "images/icon-512.png" }, "background": { - "service_worker": "background.build.js", - "type": "module" + "page": "background.html" }, "content_scripts": [ { @@ -48,7 +47,8 @@ "nostr.build.js", "popup.build.js", "options.build.js", - "options.build.css" + "options.build.css", + "options.html" ], "matches": [ "" diff --git a/Shared (Extension)/Resources/options.css b/Shared (Extension)/Resources/options.css index 28285c3..f92fc4c 100644 --- a/Shared (Extension)/Resources/options.css +++ b/Shared (Extension)/Resources/options.css @@ -3,15 +3,15 @@ @tailwind utilities; @layer components { - .btn { - @apply rounded-lg p-1.5 bg-fuchsia-900 text-fuchsia-400 hover:bg-fuchsia-800 hover:text-fuchsia-300 active:bg-fuchsia-700 active:text-fuchsia-200; + .button { + @apply rounded-lg p-1 lg:p-1.5 bg-fuchsia-900 hover:bg-fuchsia-800 active:bg-fuchsia-700 text-fuchsia-200 w-24 text-center; } .input { - @apply bg-fuchsia-200 text-fuchsia-800 rounded-lg p-1.5; + @apply bg-fuchsia-200 text-fuchsia-800 rounded-lg p-1 lg:p-1.5 focus:border-fuchsia-800; } - [type="checkbox"] { - @apply text-fuchsia-800 bg-fuchsia-200 rounded-full accent-fuchsia-200 w-5 h-5; + .checkbox { + @apply text-fuchsia-800 bg-fuchsia-200 rounded-full accent-fuchsia-200 w-4 h-4 lg:w-5 lg:h-5; } } \ No newline at end of file diff --git a/Shared (Extension)/Resources/options.html b/Shared (Extension)/Resources/options.html index 6d32e91..32453ad 100644 --- a/Shared (Extension)/Resources/options.html +++ b/Shared (Extension)/Resources/options.html @@ -9,16 +9,16 @@ - -

Advanced

+ +

Advanced Settings

- -

Relays

+

Relays

@@ -31,24 +31,25 @@
- + - + - +
- - + +
- +
diff --git a/Shared (Extension)/Resources/options.js b/Shared (Extension)/Resources/options.js index b636922..fc8724b 100644 --- a/Shared (Extension)/Resources/options.js +++ b/Shared (Extension)/Resources/options.js @@ -9,6 +9,7 @@ Alpine.data('options', () => ({ urlError: '', async init() { + await browser.runtime.getBackgroundPage(); await this.getProfileNames(); await this.getRelaysForProfile(); diff --git a/Shared (Extension)/Resources/popup.html b/Shared (Extension)/Resources/popup.html index 1d23ddf..056a02e 100644 --- a/Shared (Extension)/Resources/popup.html +++ b/Shared (Extension)/Resources/popup.html @@ -61,7 +61,7 @@
- +
diff --git a/Shared (Extension)/Resources/popup.js b/Shared (Extension)/Resources/popup.js index 219c022..f092782 100644 --- a/Shared (Extension)/Resources/popup.js +++ b/Shared (Extension)/Resources/popup.js @@ -1,3 +1,5 @@ +console.log('test!'); + import Alpine from 'alpinejs'; window.Alpine = Alpine; @@ -61,11 +63,15 @@ Alpine.data('popup', () => ({ }, async getNpubKey() { - this.pubKey = await browser.runtime.sendMessage({ kind: 'getNpubKey' }); + this.pubKey = await browser.runtime.sendMessage({ + kind: 'getNpubKey', + }); }, async getHosts() { - this.hosts = await browser.runtime.sendMessage({ kind: 'getHosts' }); + this.hosts = await browser.runtime.sendMessage({ + kind: 'getHosts', + }); }, async getProfileNames() { @@ -115,6 +121,11 @@ Alpine.data('popup', () => ({ this.confirmDelete = false; }, + async openOptions() { + await browser.runtime.openOptionsPage(); + window.close(); + }, + // Properties get hasValidPubKey() { diff --git a/Shared (Extension)/Resources/utils.js b/Shared (Extension)/Resources/utils.js new file mode 100644 index 0000000..34c825a --- /dev/null +++ b/Shared (Extension)/Resources/utils.js @@ -0,0 +1,3 @@ +export async function bglog(msg) { + await browser.runtime.sendMessage({ kind: 'log', payload: msg }); +} diff --git a/build.js b/build.js index 0c04377..e37c035 100755 --- a/build.js +++ b/build.js @@ -22,7 +22,7 @@ require('esbuild') outdir: './Shared (Extension)/Resources', sourcemap: 'inline', bundle: true, - minify: true, + // minify: true, watch, }) .catch(() => process.exit(1));