Interface and basic functionality.
Just learning how to make a basic extension. Creating an interface and setting up some basic plumbing.
This commit is contained in:
@@ -1,7 +1,3 @@
|
|||||||
browser.runtime.sendMessage({ greeting: "hello" }).then((response) => {
|
let script = document.createElement('script');
|
||||||
console.log("Received response: ", response);
|
script.setAttribute('src', browser.runtime.getURL('nostr.js'));
|
||||||
});
|
document.body.appendChild(script);
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
|
||||||
console.log("Received request: ", request);
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
"content_scripts": [{
|
"content_scripts": [{
|
||||||
"js": [ "content.js" ],
|
"js": [ "content.js" ],
|
||||||
"matches": [ "*://example.com/*" ]
|
"matches": [ "<all_urls>" ]
|
||||||
}],
|
}],
|
||||||
|
|
||||||
"action": {
|
"action": {
|
||||||
@@ -35,5 +35,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"permissions": [ ]
|
"permissions": [ "storage" ],
|
||||||
|
|
||||||
|
"web_accessible_resources": [
|
||||||
|
{
|
||||||
|
"resources": ["nostr.js"],
|
||||||
|
"matches": ["<all_urls>"]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
14
Shared (Extension)/Resources/nostr.js
Normal file
14
Shared (Extension)/Resources/nostr.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
console.log("hello from nostr module");
|
||||||
|
|
||||||
|
window.nostr = {
|
||||||
|
async getPublicKey() {
|
||||||
|
console.log("getting public key!");
|
||||||
|
return "285d4ca25cbe209832aa15a4b94353b877a2fe6c3b94dee1a4c8bc36770304db";
|
||||||
|
},
|
||||||
|
|
||||||
|
async signEvent(event) {
|
||||||
|
console.log("Signing event");
|
||||||
|
console.log(event);
|
||||||
|
return "signed event";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
width: 100px;
|
width: 500px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
font-family: system-ui;
|
font-family: system-ui;
|
||||||
|
|||||||
@@ -3,9 +3,14 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="popup.css">
|
<link rel="stylesheet" href="popup.css">
|
||||||
<script type="module" src="popup.js"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<strong>Hello World!</strong>
|
<form id="priv-key-form">
|
||||||
|
<label for="priv-key">Private Key</label>
|
||||||
|
<input type="password" id="priv-key" name="priv-key" />
|
||||||
|
<button type="submit">Save</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script src="popup.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1 +1,21 @@
|
|||||||
console.log("Hello World!", browser);
|
async function savePrivateKey(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
let privKey = document.getElementById('priv-key');
|
||||||
|
browser.storage.local.set({ "priv-key": privKey.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getPrivateKey() {
|
||||||
|
let key = await browser.storage.local.get("priv-key");
|
||||||
|
return key["priv-key"];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setPrivKeyInput() {
|
||||||
|
let privKey = await getPrivateKey();
|
||||||
|
|
||||||
|
if (privKey) {
|
||||||
|
document.getElementById("priv-key").value = privKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("priv-key-form").addEventListener("submit", savePrivateKey);
|
||||||
|
setPrivKeyInput();
|
||||||
|
|||||||
@@ -45,6 +45,8 @@
|
|||||||
941B03F9296FA90400CA291E /* popup.css in Resources */ = {isa = PBXBuildFile; fileRef = 941B03A9296FA90400CA291E /* popup.css */; };
|
941B03F9296FA90400CA291E /* popup.css in Resources */ = {isa = PBXBuildFile; fileRef = 941B03A9296FA90400CA291E /* popup.css */; };
|
||||||
941B03FA296FA90400CA291E /* popup.js in Resources */ = {isa = PBXBuildFile; fileRef = 941B03AA296FA90400CA291E /* popup.js */; };
|
941B03FA296FA90400CA291E /* popup.js in Resources */ = {isa = PBXBuildFile; fileRef = 941B03AA296FA90400CA291E /* popup.js */; };
|
||||||
941B03FB296FA90400CA291E /* popup.js in Resources */ = {isa = PBXBuildFile; fileRef = 941B03AA296FA90400CA291E /* popup.js */; };
|
941B03FB296FA90400CA291E /* popup.js in Resources */ = {isa = PBXBuildFile; fileRef = 941B03AA296FA90400CA291E /* popup.js */; };
|
||||||
|
941B040D296FAD6900CA291E /* nostr.js in Resources */ = {isa = PBXBuildFile; fileRef = 941B040C296FAD6900CA291E /* nostr.js */; };
|
||||||
|
941B040E296FAD6900CA291E /* nostr.js in Resources */ = {isa = PBXBuildFile; fileRef = 941B040C296FAD6900CA291E /* nostr.js */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@@ -120,6 +122,7 @@
|
|||||||
941B03D7296FA90400CA291E /* nostore Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "nostore Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
|
941B03D7296FA90400CA291E /* nostore Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "nostore Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
941B03DC296FA90400CA291E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
941B03DC296FA90400CA291E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
941B03DD296FA90400CA291E /* nostore.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = nostore.entitlements; sourceTree = "<group>"; };
|
941B03DD296FA90400CA291E /* nostore.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = nostore.entitlements; sourceTree = "<group>"; };
|
||||||
|
941B040C296FAD6900CA291E /* nostr.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = nostr.js; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -205,6 +208,7 @@
|
|||||||
941B03A5296FA90400CA291E /* manifest.json */,
|
941B03A5296FA90400CA291E /* manifest.json */,
|
||||||
941B03A6296FA90400CA291E /* background.js */,
|
941B03A6296FA90400CA291E /* background.js */,
|
||||||
941B03A7296FA90400CA291E /* content.js */,
|
941B03A7296FA90400CA291E /* content.js */,
|
||||||
|
941B040C296FAD6900CA291E /* nostr.js */,
|
||||||
941B03A8296FA90400CA291E /* popup.html */,
|
941B03A8296FA90400CA291E /* popup.html */,
|
||||||
941B03A9296FA90400CA291E /* popup.css */,
|
941B03A9296FA90400CA291E /* popup.css */,
|
||||||
941B03AA296FA90400CA291E /* popup.js */,
|
941B03AA296FA90400CA291E /* popup.js */,
|
||||||
@@ -417,6 +421,7 @@
|
|||||||
941B03F2296FA90400CA291E /* background.js in Resources */,
|
941B03F2296FA90400CA291E /* background.js in Resources */,
|
||||||
941B03F8296FA90400CA291E /* popup.css in Resources */,
|
941B03F8296FA90400CA291E /* popup.css in Resources */,
|
||||||
941B03F6296FA90400CA291E /* popup.html in Resources */,
|
941B03F6296FA90400CA291E /* popup.html in Resources */,
|
||||||
|
941B040D296FAD6900CA291E /* nostr.js in Resources */,
|
||||||
941B03EE296FA90400CA291E /* images in Resources */,
|
941B03EE296FA90400CA291E /* images in Resources */,
|
||||||
941B03F0296FA90400CA291E /* manifest.json in Resources */,
|
941B03F0296FA90400CA291E /* manifest.json in Resources */,
|
||||||
941B03EC296FA90400CA291E /* _locales in Resources */,
|
941B03EC296FA90400CA291E /* _locales in Resources */,
|
||||||
@@ -432,6 +437,7 @@
|
|||||||
941B03F3296FA90400CA291E /* background.js in Resources */,
|
941B03F3296FA90400CA291E /* background.js in Resources */,
|
||||||
941B03F9296FA90400CA291E /* popup.css in Resources */,
|
941B03F9296FA90400CA291E /* popup.css in Resources */,
|
||||||
941B03F7296FA90400CA291E /* popup.html in Resources */,
|
941B03F7296FA90400CA291E /* popup.html in Resources */,
|
||||||
|
941B040E296FAD6900CA291E /* nostr.js in Resources */,
|
||||||
941B03EF296FA90400CA291E /* images in Resources */,
|
941B03EF296FA90400CA291E /* images in Resources */,
|
||||||
941B03F1296FA90400CA291E /* manifest.json in Resources */,
|
941B03F1296FA90400CA291E /* manifest.json in Resources */,
|
||||||
941B03ED296FA90400CA291E /* _locales in Resources */,
|
941B03ED296FA90400CA291E /* _locales in Resources */,
|
||||||
|
|||||||
Reference in New Issue
Block a user