Last active
April 4, 2022 07:45
-
-
Save pacochi/3b963faddcb3a8973107ed93b4cf38a9 to your computer and use it in GitHub Desktop.
Gyakubenile、逆紅クイズのリザルトを他の SNS に投稿しやすくします。
This file contains hidden or 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
// ==UserScript== | |
// @name Gyakubenile と逆紅クイズにコピーボタン追加 | |
// @namespace hen.acho.co | |
// @include https://pitto.exout.net/QuizInvisible/* | |
// @version 1.220404 | |
// @description Gyakubenile、逆紅クイズのリザルトを他の SNS に投稿しやすくします。 | |
// @downloadURL https://gist.github.com/pacochi/3b963faddcb3a8973107ed93b4cf38a9/raw/gyakubenile_copy.user.js | |
// @run-at document-idle | |
// @grant none | |
// ==/UserScript== | |
(() => { | |
const tweetButton = document.getElementById('b'); | |
if (!tweetButton) return; | |
const copyResult = e => { | |
const params = (new URL(tweetButton.href)).searchParams; | |
const result = params.get('text') ?? ''; | |
const hash = params.get('hashtags') ? '\n#' + params.get('hashtags').replace(/,/, ' #') : ''; | |
const url = params.get('url') ? '\n' + params.get('url') : ''; | |
navigator.clipboard.writeText(result + url + hash); | |
e.target.innerText = 'コピー🆗'; | |
}; | |
tweetButton.after(Object.assign(document.createElement('button'), { | |
id: 'copyButton', | |
style: 'margin-left: 1em', | |
onclick: copyResult, | |
innerText: 'コピー!' | |
})); | |
// おまけの textarea 自動伸ばし、縮みはしない | |
document.querySelector('textarea.note')?.addEventListener('input', | |
({ target }) => target.style.height = Math.max(target.scrollHeight, target.offsetHeight) + 'px' | |
); | |
// おまけのスペースを最初から四角にするやつ | |
document.getElementById('countable')?.click(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment