(grant: string)
| 67 | }); |
| 68 | const grantedAPIs: { [key: string]: any } = Object.create(null); |
| 69 | const __methodInject__ = (grant: string): boolean => { |
| 70 | const grantSet: Set<string> = context.grantSet; |
| 71 | const s = GMContextApiGet(grant); |
| 72 | if (!s) return false; // @grant 的定义未实现,略过 (返回 false 表示 @grant 不存在) |
| 73 | if (grantSet.has(grant)) return true; // 重复的@grant,略过 (返回 true 表示 @grant 存在) |
| 74 | grantSet.add(grant); |
| 75 | for (const { fnKey, api, param } of s) { |
| 76 | grantedAPIs[fnKey] = api.bind(context); |
| 77 | const depend = param?.depend; |
| 78 | if (depend) { |
| 79 | for (const grant of depend) { |
| 80 | __methodInject__(grant); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | return true; |
| 85 | }; |
| 86 | for (const grant of scriptGrants) { |
| 87 | // GM. 与 GM_ 都需要注入 |
| 88 | __methodInject__(grant); |
no test coverage detected