-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.tsx
62 lines (53 loc) · 1.39 KB
/
popup.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { useState } from "react"
import { sendToBackground, sendToContentScript } from "@plasmohq/messaging"
function IndexPopup() {
const [txHash, setTxHash] = useState(undefined)
const [txInput, setTxInput] = useState(0)
const [txInput2, setTxInput2] = useState(0)
const [selector, setSelector] = useState("#itero")
const [csResponse, setCsData] = useState("")
return (
<div>
<input
type="number"
value={txInput}
onChange={(e) => setTxInput(e.target.valueAsNumber)}
/>
<input
type="number"
value={txInput2}
onChange={(e) => setTxInput2(e.target.valueAsNumber)}
/>
<button
onClick={async () => {
const resp = await sendToBackground({
name: "hash-tx",
body: {
input: txInput,
input2: txInput2
}
})
setTxHash(resp)
}}>
Sum
</button>
<p>Sum: {txHash}</p>
<hr />
<button
onClick={async () => {
const csResponse = await sendToContentScript({
name: "query-selector-text",
body: txHash
})
setCsData(csResponse)
}}>
Sent to Content Script
</button>
<br />
<label>Text Data:</label>
<p>{csResponse}</p>
<footer>Crafted by @PlamoHQ</footer>
</div>
)
}
export default IndexPopup