Created
February 4, 2023 05:17
-
-
Save ThinaticSystem/f84e9788649f48ca0bb9a50c6f26e218 to your computer and use it in GitHub Desktop.
Misskey招待コード生やしブックマークレット
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async() => { | |
const MISSKEY_NAME = 'ほにクラブ'; | |
const MISSKEY_HOST = 'https://honi.club'; | |
const MISSKEY_ADMIN_API_TOKEN = 'とーくん'; | |
const fn_copyToClipboard = (text) => { | |
const textarea = document.createElement('textarea'); | |
textarea.textContent = text; | |
document.body.appendChild(textarea); | |
textarea.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(textarea); | |
}; | |
const reqUri = `${MISSKEY_HOST}/api/invite`; | |
const reqData = { | |
i: MISSKEY_ADMIN_API_TOKEN, | |
}; | |
const response = await fetch(reqUri, { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Cache-Control': 'no-cache', | |
'Pragma': 'no-cache', | |
}, | |
body: JSON.stringify(reqData), | |
}); | |
const resData = await response.json(); | |
const code = resData.code; | |
const text = `${MISSKEY_NAME}へ登録をお申込みいただきありがとうございます🐾\n` + | |
`招待コードは ${code} になります。\n` + | |
'下記リンクから新規登録にお進みいただければ幸いです🌵\n' + | |
`${MISSKEY_HOST}`; | |
fn_copyToClipboard(text); | |
alert( | |
'↓クリップボドにコピーしました\n' + | |
text | |
); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment