Skip to content

Commit 77624a7

Browse files
committed
README improvement and name consistency
1 parent c0ba802 commit 77624a7

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
# page-to-extension-rpc
1+
# Scuttle Shell Browser
22

33
## What it does
44

5-
This projet provides a webextension an a webpage that demostrate an RPC Connection between
6-
page an extension.
5+
This projet provides a webextension that allows accessing scuttlebutt from scripts in websites.
6+
7+
An script running on the Host provides an RPC connection to scuttlebutt via native messages. The web exension allows to decide which pages can access Scuttlebutt.
8+
9+
10+
![Context menu to enable SSB aceess](images/scuttle-shell-browser-screenshot.png)
711

812
This extension includes a content script, which is injected into the accessed pages. This
913
content script provides an api that can be accessed from any page using a [muxrpc](https://github.com/ssb-js/muxrpc) connection.
@@ -21,7 +25,11 @@ Building
2125

2226
Running
2327

24-
To run the example you need to have the extension intalle and acce the example page.
28+
To use Scuttle Shell Browser you need an ssb-sever running on your machine (this is the case when you
29+
are running Patchwork). You need to install native mesaging for the manifest in `host/scuttle_shell_browser.json`, see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging to learn how to do this on your platform. Note that you need to adapt the paths in the manifest file and that `host/host-script.js` must be executable.
30+
31+
32+
To run the example you need to have the extension intalled and access the example page.
2533

2634
npm run-script start:ext
2735

@@ -32,6 +40,3 @@ This should start a browser with the extension. Alternatively you can also load
3240
Now you can access http://localhost:9090/page.html
3341

3442

35-
## What it shows
36-
37-
How to make an RPC connection between an extension's content scripts, and scripts running in a web page.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "ssb4all",
3-
"description": "A Native Messaging host that gives access to ssb to e ssb4all web extension",
2+
"name": "scuttle_shell_browser",
3+
"description": "A Native Messaging host that gives access to ssb to the Scuttle Shell Browser web extension",
44
"path": "/home/reto/Documents/retog/ssb4all/host/host-script.js",
55
"type": "stdio",
6-
"allowed_extensions": [ "ssb4all@example.org" ]
6+
"allowed_extensions": [ "scuttle-shell-browser@example.org" ]
77
}
135 KB
Loading

src/background-script.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function notify(message) {
1818
connectPort(con.stream)
1919
portConnections[con.port.sender.tab.id].connected = true
2020
} else {
21+
console.log(con.stream)
2122
con.stream.abort()
2223
}
2324
})
@@ -32,7 +33,7 @@ browser.runtime.onConnect.addListener(async function connected(port) {
3233
console.log('connection from', port.sender.url)
3334
const stream = createConnection(port)
3435
const relevantURL = port.sender.url.split('?')[0].split('#')[0]
35-
const { granted } = await browser.storage.local.get('granted')
36+
const { granted } = await browser.storage.local.get({'granted': []})
3637
if (~granted.indexOf(relevantURL)) {
3738
connectPort(stream)
3839
portConnections[port.sender.tab.id] = { port, stream, connected: true }
@@ -60,7 +61,7 @@ function connectPort(contentScriptStream) {
6061
}
6162

6263
function createNativeConnection() {
63-
const port = browser.runtime.connectNative("ssb4all")
64+
const port = browser.runtime.connectNative("scuttle_shell_browser")
6465
return createConnection(port)
6566
}
6667

webext/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
"browser_specific_settings": {
3232
"gecko": {
33-
"id": "scuttle-shell@example.org",
33+
"id": "scuttle-shell-browser@example.org",
3434
"strict_min_version": "50.0"
3535
}
3636
},

webext/menu-script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ browser.tabs.query({ "active": true, "currentWindow": true, "windowType": "norma
77
tab => {
88
const relevantURL = tab.url.split('?')[0].split('#')[0]
99
locationArea.innerText = relevantURL
10-
browser.storage.local.get('granted').then(result => {
10+
browser.storage.local.get({'granted': []}).then(result => {
1111
let granted = result.granted
1212
const enabled = !!~granted.indexOf(relevantURL)
1313
toggleSwitch.checked = enabled

0 commit comments

Comments
 (0)