@@ -3,7 +3,7 @@ import { getHosts, getHostKey, findMatchedHosts } from 'libs'
33
44const baseURL = chrome . runtime . getURL ( 'base.js' )
55
6- const catchErr = e => {
6+ const catchErr = ( e ) => {
77 console . error ( 'Failed to inject scripts:' , e )
88}
99
@@ -42,36 +42,36 @@ const extractScripts = (customjs, injections) => {
4242 // Extra include
4343 ; ( extra || '' )
4444 . 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 ) {
4848 injections . add ( line )
4949 }
5050 } )
5151
5252 return source
5353}
5454
55- const loadScripts = async location => {
55+ const loadScripts = async ( location ) => {
5656 const hosts = await getHosts ( )
5757 const matchedHosts = findMatchedHosts ( hosts , location )
5858 const injections = new Set ( )
5959 Promise . all (
60- matchedHosts . map ( async host => {
60+ matchedHosts . map ( async ( host ) => {
6161 const hostKey = getHostKey ( host )
6262 const obj = await chrome . storage . sync . get ( hostKey )
6363 return extractScripts ( obj [ hostKey ] , injections )
6464 } )
6565 )
66- . then ( values => values . filter ( x => x ) )
67- . then ( values => {
66+ . then ( ( values ) => values . filter ( ( x ) => x ) )
67+ . then ( ( values ) => {
6868 if ( values . length ) {
6969 console . info (
7070 'Custom JavaScript for websites enabled.\nPlease visit https://xcv58.xyz/inject-js if you have any issue.'
7171 )
7272 }
7373 return Promise . all (
74- [ ...injections ] . map ( src => {
74+ [ ...injections ] . map ( ( src ) => {
7575 if ( src ) {
7676 return injectScriptPromise ( src )
7777 }
@@ -80,7 +80,7 @@ const loadScripts = async location => {
8080 . then ( ( ) => values )
8181 . catch ( catchErr )
8282 } )
83- . then ( values => values . map ( src => injectScriptPromise ( src , 'body' ) ) )
83+ . then ( ( values ) => values . map ( ( src ) => injectScriptPromise ( src , 'body' ) ) )
8484 . catch ( catchErr )
8585}
8686
0 commit comments