11import { AttachedScope , attachScopes } from '@rollup/pluginutils' ;
2- import type { AstNode } from 'rollup' ;
3- import { walk , Node } from 'estree-walker' ;
2+ import { Node , walk } from 'estree-walker' ;
43import isReference from 'is-reference' ;
4+ import type { AstNode } from 'rollup' ;
55
66const gmAPIs = [
77 'GM_info' ,
88 'GM_getValue' ,
9+ 'GM_getValues' ,
910 'GM_setValue' ,
11+ 'GM_setValues' ,
1012 'GM_deleteValue' ,
13+ 'GM_deleteValues' ,
1114 'GM_listValues' ,
1215 'GM_addValueChangeListener' ,
1316 'GM_removeValueChangeListener' ,
1417 'GM_getResourceText' ,
1518 'GM_getResourceURL' ,
19+ 'GM_addElement' ,
1620 'GM_addStyle' ,
1721 'GM_openInTab' ,
1822 'GM_registerMenuCommand' ,
@@ -31,7 +35,11 @@ export function collectGmApi(ast: AstNode) {
3135 walk ( ast as Node , {
3236 enter ( node : Node & { scope : AttachedScope } , parent ) {
3337 if ( node . scope ) scope = node . scope ;
34- if ( node . type === 'Identifier' && isReference ( node , parent ) && ! scope . contains ( node . name ) ) {
38+ if (
39+ node . type === 'Identifier' &&
40+ isReference ( node , parent ) &&
41+ ! scope . contains ( node . name )
42+ ) {
3543 if ( gmAPIs . includes ( node . name ) ) {
3644 grantSetPerFile . add ( node . name ) ;
3745 }
@@ -44,16 +52,22 @@ export function collectGmApi(ast: AstNode) {
4452 return grantSetPerFile ;
4553}
4654
47- export function getMetadata ( metaFileContent : string , additionalGrantList : Set < string > ) {
48- const lines = metaFileContent . split ( '\n' ) . map ( line => line . trim ( ) ) ;
55+ export function getMetadata (
56+ metaFileContent : string ,
57+ additionalGrantList : Set < string > ,
58+ ) {
59+ const lines = metaFileContent . split ( '\n' ) . map ( ( line ) => line . trim ( ) ) ;
4960 const start = lines . indexOf ( META_START ) ;
5061 const end = lines . indexOf ( META_END ) ;
5162 if ( start < 0 || end < 0 ) {
52- throw new Error ( 'Invalid metadata block. For more details see https://violentmonkey.github.io/api/metadata-block/' ) ;
63+ throw new Error (
64+ 'Invalid metadata block. For more details see https://violentmonkey.github.io/api/metadata-block/' ,
65+ ) ;
5366 }
5467 const grantSet = new Set < string > ( ) ;
55- const entries = lines . slice ( start + 1 , end )
56- . map ( line => {
68+ const entries = lines
69+ . slice ( start + 1 , end )
70+ . map ( ( line ) => {
5771 if ( ! line . startsWith ( '// ' ) ) return ;
5872 line = line . slice ( 3 ) . trim ( ) ;
5973 const matches = line . match ( / ^ ( \S + ) ( \s .* ) ? $ / ) ;
0 commit comments