File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 50
50
" GM.xmlHttpRequest"
51
51
],
52
52
"exclude" : [],
53
- "resources" : []
53
+ "resources" : [],
54
+ "keyedResources" : {}
54
55
},
55
56
"dependencies" : {
56
57
"@trim21/gm-fetch" : " ^0.1.13" ,
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ interface UserScriptOptions {
36
36
exclude : string [ ] ;
37
37
require : string [ ] ;
38
38
resources : string [ ] ;
39
+ keyedResources : { [ key : string ] : string } ;
39
40
connect : string [ ] ;
40
41
'run-at' : string ;
41
42
grant : string [ ] ;
@@ -209,6 +210,15 @@ export function generateHeader() {
209
210
headers . push ( `// @resource ${ resource } ` ) ;
210
211
}
211
212
}
213
+ // Add userscript header's resources.
214
+ // Some of the resources should contain a specified name, for which userscripts can get value from it
215
+ // eg. // @resource mycss http://link.to/some.css
216
+ // Userscripts have the ability to apply css with `GM_addStyle(GM_getResourceText('mycss'))`
217
+ if ( userscript . keyedResources ) {
218
+ for ( const dependencyName in userscript . keyedResources ) {
219
+ headers . push ( `// @resource ${ dependencyName } ${ userscript . keyedResources [ dependencyName ] } ` ) ;
220
+ }
221
+ }
212
222
// Add userscript header's connects.
213
223
if ( userscript . connect && userscript . connect instanceof Array ) {
214
224
for ( const connect of userscript . connect ) {
You can’t perform that action at this time.
0 commit comments