@@ -3,7 +3,7 @@ import { getHosts, getHostKey, findMatchedHosts } from 'libs'
3
3
4
4
const baseURL = chrome . runtime . getURL ( 'base.js' )
5
5
6
- const catchErr = e => {
6
+ const catchErr = ( e ) => {
7
7
console . error ( 'Failed to inject scripts:' , e )
8
8
}
9
9
@@ -42,36 +42,36 @@ const extractScripts = (customjs, injections) => {
42
42
// Extra include
43
43
; ( extra || '' )
44
44
. split ( ';' )
45
- . map ( x => x . trim ( ) )
46
- . forEach ( line => {
47
- if ( line && line . startsWith ( '//' ) ) {
45
+ . map ( ( x ) => x . trim ( ) )
46
+ . forEach ( ( line ) => {
47
+ if ( line ) {
48
48
injections . add ( line )
49
49
}
50
50
} )
51
51
52
52
return source
53
53
}
54
54
55
- const loadScripts = async location => {
55
+ const loadScripts = async ( location ) => {
56
56
const hosts = await getHosts ( )
57
57
const matchedHosts = findMatchedHosts ( hosts , location )
58
58
const injections = new Set ( )
59
59
Promise . all (
60
- matchedHosts . map ( async host => {
60
+ matchedHosts . map ( async ( host ) => {
61
61
const hostKey = getHostKey ( host )
62
62
const obj = await chrome . storage . sync . get ( hostKey )
63
63
return extractScripts ( obj [ hostKey ] , injections )
64
64
} )
65
65
)
66
- . then ( values => values . filter ( x => x ) )
67
- . then ( values => {
66
+ . then ( ( values ) => values . filter ( ( x ) => x ) )
67
+ . then ( ( values ) => {
68
68
if ( values . length ) {
69
69
console . info (
70
70
'Custom JavaScript for websites enabled.\nPlease visit https://xcv58.xyz/inject-js if you have any issue.'
71
71
)
72
72
}
73
73
return Promise . all (
74
- [ ...injections ] . map ( src => {
74
+ [ ...injections ] . map ( ( src ) => {
75
75
if ( src ) {
76
76
return injectScriptPromise ( src )
77
77
}
@@ -80,7 +80,7 @@ const loadScripts = async location => {
80
80
. then ( ( ) => values )
81
81
. catch ( catchErr )
82
82
} )
83
- . then ( values => values . map ( src => injectScriptPromise ( src , 'body' ) ) )
83
+ . then ( ( values ) => values . map ( ( src ) => injectScriptPromise ( src , 'body' ) ) )
84
84
. catch ( catchErr )
85
85
}
86
86
0 commit comments