diff --git a/.gitignore b/.gitignore index f06235c..60ed31e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules dist +web-ext-artifacts diff --git a/package.json b/package.json index a3877ff..7b6c6b9 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,14 @@ "ipfs": "^0.22.0", "setimmediate": "^1.0.5" }, - "devDependencies": {}, + "devDependencies": { + "web-ext": "^1.8.1" + }, "scripts": { "test": "mocha", - "build": "browserify start-daemon.js -o dist/start-daemon.js" + "build": "browserify start-daemon.js -o dist/start-daemon.js", + "package": "web-ext build", + "sign": "web-ext sign" }, "keywords": [], "author": "", diff --git a/page-script.js b/page-script.js index d8f4c52..3643f17 100644 --- a/page-script.js +++ b/page-script.js @@ -1,12 +1,10 @@ /* global browser, cloneInto */ -// window.wrappedJSObject.ipfs = false console.log('declared a public ipfs object!') const myPort = browser.runtime.connect({name: 'port-from-cs'}) const makeCall = (method, cb) => { myPort.onMessage.addListener(function (m) { - // myPort.onMessage.removeListener(this) cb(cloneInto(m, window, {cloneFunctions: true})) }) myPort.postMessage({method}) @@ -16,15 +14,7 @@ const ipfs = { id: (callback) => { makeCall('id', callback) } } -// ipfs.id((id) => { -// console.log('lol', id) -// }) - window.wrappedJSObject.ipfs = cloneInto( ipfs, window, {cloneFunctions: true}) - -// window.ipfs = ipfs -// unsafeWindow.clonedContentScriptObject = cloneInto(ipfs, unsafeWindow) -// unsafeWindow.assignedContentScriptObject = ipfs; diff --git a/readme.md b/readme.md index 699fc83..15169b3 100644 --- a/readme.md +++ b/readme.md @@ -1 +1,19 @@ ## js-ipfs in the browser + +### Running locally + +* `npm install` +* `npm run build` +* Open `about:debugging` in Firefox and point it to the manifest.json in this repository +* Now try the test page: https://ipfs.io/ipfs/QmcVc8eQiWkR23wMKiQjipLRSjCxR1FEj4TL99aY89J83d + +### Packaging + +* Sign up for AMO https://addons.mozilla.org/ +* Run `npm run package` +* Upload the resulting zip to AMO +* You'll get back an .xpi you can use for installing the extension + +## License + +MIT 2017 - Victor Bjelkholm diff --git a/testpage.html b/testpage.html index decc01f..35017d9 100644 --- a/testpage.html +++ b/testpage.html @@ -4,10 +4,24 @@ window.ipfs test page +

Is IPFS in the browser yet?

-
Loading
+
window.ipfs exists? Loading
Your ID: N/A