File tree Expand file tree Collapse file tree 3 files changed +29
-9
lines changed
Expand file tree Collapse file tree 3 files changed +29
-9
lines changed Original file line number Diff line number Diff line change 1212
1313 let key = "activeScripts" ;
1414 let ids = ( await chrome . storage . sync . get ( [ key ] ) ) ?. [ key ] ;
15+ let search = new URLSearchParams ( {
16+ ids : ids ,
17+ path : chrome . runtime . getURL ( "/scripts/" ) ,
18+ event : "onDocumentStart" ,
19+ } ) . toString ( ) ;
1520
1621 injectScript (
1722 chrome . runtime . getURL ( "/scripts/content-scripts/load_scripts.js" ) +
18- "?ids= " +
19- ids
23+ "?" +
24+ search
2025 ) ;
2126} ) ( ) ;
2227
Original file line number Diff line number Diff line change 1- const params = new URLSearchParams ( document . currentScript . src . split ( "?" ) ?. [ 1 ] ) ;
2- console . log ( params ) ;
1+ ( async ( ) => {
2+ const params = new URLSearchParams (
3+ document . currentScript . src . split ( "?" ) ?. [ 1 ]
4+ ) ;
5+ console . log ( params ) ;
6+
7+ let param_ids = params . get ( "ids" ) ;
8+ let path = params . get ( "path" ) ;
9+ let event = params . get ( "event" ) ;
10+
11+ if ( param_ids ) {
12+ let ids = param_ids . split ( "," ) ;
13+ for ( let id of ids ) {
14+ import ( path + "/" + id + ".js" ) . then ( ( script ) => {
15+ script [ event ] ?. ( ) ;
16+ } ) ;
17+ }
18+ }
19+ } ) ( ) ;
Original file line number Diff line number Diff line change @@ -31,11 +31,9 @@ export const localStorage = {
3131const listActiveScriptsKey = "activeScripts" ;
3232export async function setActiveScript ( scriptId , isActive = true ) {
3333 let list = await getAllActiveScriptId ( ) ;
34- if ( isActive ) {
35- list . push ( scriptId ) ;
36- } else {
37- list = list . filter ( ( _ ) => _ != scriptId ) ;
38- }
34+ if ( isActive ) list . push ( scriptId ) ;
35+ else list = list . filter ( ( _ ) => _ != scriptId ) ;
36+ list = list . filter ( ( _ ) => _ ) ;
3937 await localStorage . set ( listActiveScriptsKey , list . join ( "," ) ) ;
4038 return list ;
4139}
You can’t perform that action at this time.
0 commit comments