- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontent_script.js
More file actions
Latest commit
30 lines (25 loc) · 545 Bytes
/
Copy pathcontent_script.js
File metadata and controls
30 lines (25 loc) · 545 Bytes
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
functionid(){
return`javascript.chee.${location.host}`
}
functioninject(){
browser.storage.local.get().then(store=>{
letjavascript=store[location.host]
if(!javascript){
return
}
letscript=document.createElement("script")
script.id=id()
script.textContent=javascript
document.body.append(script)
})
}
inject()
browser.runtime.onMessage.addListener(request=>{
if(request.rerun){
letscript=document.getElementById(id())
if(script){
document.body.removeChild(script)
}
inject()
}
})