Last active
April 27, 2019 12:44
-
-
Save Getaji/1c7535023345fb3b8f23218e3156d6af to your computer and use it in GitHub Desktop.
[TweetDeck]指定されたアカウント以外でのRT時に確認ダイアログを表示するスクリプト
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
| // TweetDeckの読み込み後に一度だけ実行してください。 | |
| // 実行のトリガは手動で開発者ツールやアドレスバーに突っ込んだりBTDを改造したり色々やってください。 | |
| // 動作不良による損害には一切責任を負いません。 | |
| const USERNAME_NOT_CONFIRM_RT = 'USERNAME'; | |
| new MutationObserver(mutations => { | |
| mutations.forEach(mutation => { | |
| Array.prototype.some.call(mutation.addedNodes, node => { | |
| if (!(node instanceof Element)) return false; | |
| const modal = node; | |
| const btnRt = modal.querySelector('.js-retweet-button'); | |
| const buttons = btnRt ? btnRt.parentNode : null; | |
| if (buttons) { | |
| buttons.addEventListener('click', ev => { | |
| if (ev.target !== btnRt) return; | |
| const account = modal.querySelector('.js-account-item.is-selected'); | |
| const username = account.dataset.originalTitle || account.getAttribute('title'); | |
| if (username && username.substr(1) !== '_backalley_') { | |
| if (!confirm('本当にこのツイートを' + username + 'でRTしますか?')) { | |
| ev.stopImmediatePropagation(); | |
| ev.stopPropagation(); | |
| } | |
| } | |
| }, true) | |
| return true; | |
| } | |
| return false; | |
| }); | |
| }); | |
| }).observe(document.getElementById('actions-modal'), { childList: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment