https://hackmd.io/ts-swiss https://hackmd.io/p/ts-swiss
<style> .reveal section img { border-width: 0px; background-color: transparent; } </style>
Yukai Huang
@TypeScript Switzerland
slide: hackmd.io/p/ts-swiss
We have a collaborative session
please prepare laptop or smartphone to join!
- Yukai Huang
- Full Stack Developer @HackMD π
- VSCode β€οΈ
- I use tabs. π±
Shamelss plug here π
π
{%youtube E8Nj7RwXf0s %}
π
- Run after the extension start
- Long run action, web request, heavy works, ...
- Kinda backend
- Bind with each page
- Manipulate DOM
- Add event listeners
- Isolated JavaScript environment
- It doesn't break things
- Injected with content script
- Accessing global variable
- Call global function
- Acts as JavaScript inserted with HTML script tag
<script>
π
- We can't send message between two injected scripts
- We need to manage flow by ourself
- Different set of API
content <-> background
content <-> injected
<style> code.blue { color: #337AB7 !important; } code.orange { color: #F7A004 !important; } </style>
onMessage('event')
: Register event listenersendMessage('event')
: Trigger event
- Dead simple API
- Only cares about application logic
import * as Channeru from 'channeru'
// setup channel in different page environment, once
const channel = Channeru.create()
// in background script
const fakeLogin = async () => true
channel.answer('isLogin', async () => {
return await fakeLogin()
})
// in inject script
const isLogin = await channel.callBackground('isLogin')
console.log(isLogin) //-> true
Our extension is not open sourced for now π
Use crx-bridge
as alternative
https://github.com/NeekSandhu/crx-bridge
- Strongly Typed: Manage different protocol with ease
- IDE Features (I β€οΈ VSCode)
(recursive acronym
)
hackmd.io/hackdf
- an GitHub App
- Integrate GitHub With HackMD
- Remind you when should update documentation
- Commit and push documentation changes right on HackMD
- Cross envornment commnication
- A small library to solve messaging pain
- TypeScript Rocks π
Wishlist
You can find me on
- GitHub (@Yukaii)
- Twitter (@yukaii_h)
- or send an email to [email protected]