Skip to content

Commit 9c93767

Browse files
authored
Create README.md
1 parent fcdc183 commit 9c93767

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ShadowFunction
2+
该方案能让你的网页安全的植入第三方代码,在运行时分配沙箱隔离,被隔离代码在调用"location, top, document.cookie, alert, console, prototype"等时均会被拦截及记录操作行为并返回空值,同时运行器也能对代码设置类操作权限,以控制代码的有效操作。
3+
# 上手
4+
npm 安装:
5+
```bash
6+
$ npm install shadow-function --save
7+
```
8+
简单的应用:
9+
```js
10+
import { ShadowFunction, ShadowDocument } from 'shadow-function'
11+
new ShadowFunction('console.log(a + b)')({a: 1, b: 2, console}) // 3
12+
let sDoc = new ShadowDocument(document.body, '<div>123</div>')
13+
sDoc(`
14+
document.body.append($template.content);
15+
console.log(document.body.getElementsByTagName("div")[0].innerText)
16+
`)({console})
17+
```

0 commit comments

Comments
 (0)