-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.exmaple.js
56 lines (52 loc) · 1.52 KB
/
config.exmaple.js
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
const config = {
root: 'https://www.google.com',
base: 'https://www.google.com/',
start: 'https://www.google.com/static/',
// the urls you known
urls: [
'index.htm'
],
// outputs
directory: './dist/googl',
allowthirdDomain: false,
captureSceenshot: true, // capture screenshot for website
// parse url recursive
allowParseUrl: (url)=> { return /\.(htm|css)$/.test(url)},
// buffer type
getEncode: (url)=> {
return /png|cur|jpe?g|gif|eot|woff2?|ttf/.test(url) ? 'base64' : 'utf8'
},
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
// match rules
bodyReplace: {
'/template/default/' : /__PUBLIC__\//g
},
plugins: [
'bodyParse',
'cssUrlParse'
],
sources: [
{ callback:(body)=> {
let u = [];
// match the body to return urls
return u
}
},
// example
{ callback:(body)=> {
let u = [];
let r = /url\(([\"\'])?(\S+?)\1\)/g
let matchd = body.match(r);
if(matchd) {
u = matchd.map((item)=> {
return item.match(/url\(([\"\'])?(\S+?)\1\)/)[2].replace(/(eot|woff2?|ttf|svg)(\S+)/, '$1')
})
}
// fiilter data base64
u = u.filter(item => !~item.indexOf('data:'))
return u
}
}
]
}
module.exports = config;