diff --git a/src/main.ts b/src/main.ts index f29fddb..ba4bdc6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,15 +6,10 @@ import { downloadMscz } from './mscz' import { getFileUrl } from './file' import { WebMscore, loadSoundFont } from './mscore' import { getDownloadBtn, BtnList, BtnAction, BtnListMode } from './btn' -import * as recaptcha from './recaptcha' import scoreinfo from './scoreinfo' import i18n from './i18n' const main = (): void => { - // init recaptcha - // eslint-disable-next-line @typescript-eslint/no-floating-promises - recaptcha.init() - const btnList = new BtnList(getDownloadBtn) const filename = scoreinfo.fileName diff --git a/src/recaptcha.ts b/src/recaptcha.ts deleted file mode 100644 index f7e7446..0000000 --- a/src/recaptcha.ts +++ /dev/null @@ -1,48 +0,0 @@ - -/** - * the site key for Google reCAPTCHA v3 - */ -const SITE_KEY = '6Ldxtt8UAAAAALvcRqWTlVOVIB7MmEWwN-zw_9fM' - -type token = string; -interface GRecaptcha { - ready (cb: () => any): void; - execute (siteKey: string, opts: { action: string }): Promise; -} - -let gr: GRecaptcha | Promise - -/** - * load reCAPTCHA - */ -const load = (): Promise => { - // load script - const script = document.createElement('script') - script.src = `https://www.recaptcha.net/recaptcha/api.js?render=${SITE_KEY}` - script.async = true - document.body.appendChild(script) - - // add css - const style = document.createElement('style') - style.innerHTML = '.grecaptcha-badge { display: none !important; }' - document.head.appendChild(style) - - return new Promise((resolve) => { - script.onload = (): void => { - const grecaptcha: GRecaptcha = window['grecaptcha'] - grecaptcha.ready(() => resolve(grecaptcha)) - } - }) -} - -export const init = (): GRecaptcha | Promise => { - if (!gr) { - gr = load() - } - return gr -} - -export const execute = async (): Promise => { - const captcha = await init() - return captcha.execute(SITE_KEY, { action: 'downloadmscz' }) -}