/*
* @title Tangolf の結果コピー
* @description ツイートボタンをコピーボタンにします。
* @include https://tangolf.hatelabo.jp/
* @license MIT License
* @javascript_url
*/
// https://gist.github.com/pacochi/0568e742d53902f99f533aa1b4ed51e2 のおすそわけ
((
D = document,
B = t => `[class^="_${t}Button_"]`,
T = (n = D) => n?.querySelector?.(B('share')),
O = e => new MutationObserver((l, o) =>
(l.reduce((n, m) => n.concat([...m.addedNodes]), []).find(n => T(n)) && o.disconnect(R()))
).observe(D.body, { childList: 1, subtree: 1 }),
R = (c = 'スコアをコピー') => Object.assign(T(), {
_: D.querySelector(B('reset')).addEventListener('click', O, { once: 1 }),
innerText: c + '!',
onclick: (e, t = e.target) => e.preventDefault(
t.innerText = c + '🆗',
navigator.clipboard.writeText([...(new URL(t.href)).searchParams.values()].join('\n#'))
)
})
) => { T() ? R() : O(); })();