/** * UserScript APIs */ declare const GM: { /** https://www.tampermonkey.net/documentation.php#GM_info */ info: Record; /** https://www.tampermonkey.net/documentation.php#GM_registerMenuCommand */ registerMenuCommand (name: string, fn: () => any, accessKey?: string): Promise; /** https://github.com/Tampermonkey/tampermonkey/issues/881#issuecomment-639705679 */ addElement (tagName: K, properties: Record): Promise; } export const _GM = (typeof GM === 'object' ? GM : undefined) as GM type GM = typeof GM export const isGmAvailable = (requiredMethod: keyof GM = 'info'): boolean => { return typeof GM !== 'undefined' && typeof GM[requiredMethod] !== 'undefined' }