Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
victorb committed Feb 21, 2017
1 parent c0d138f commit 95d8b08
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
web-ext-artifacts
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
10 changes: 0 additions & 10 deletions page-script.js
Original file line number Diff line number Diff line change
@@ -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})
Expand All @@ -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;
18 changes: 18 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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
16 changes: 15 additions & 1 deletion testpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,24 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>window.ipfs test page</title>
<style>
body {
font-family: sans-serif;
height: 100vh;
background: linear-gradient(to bottom,#041727 0%,#062b3f 100%);
color: white;
text-align: center;
padding-top: 50px;
}

div {
margin-top: 50px;
}
</style>
</head>
<body>
<h1>Is IPFS in the browser yet?</h1>
<div id="status">Loading</div>
<div><code>window.ipfs</code> exists? <span id="status">Loading</span></div>
<div>Your ID: <span id='peerid'>N/A</span></div>
<script>
document.addEventListener('DOMContentLoaded', () => {
Expand Down

0 comments on commit 95d8b08

Please sign in to comment.