Last active
May 23, 2017 12:54
-
-
Save unarist/89a640badf8b340db29c5f72fcaceb54 to your computer and use it in GitHub Desktop.
Mastodon - 確認ダイアログのボタンに自動でフォーカス移動する
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 Mastodon - 確認ダイアログのボタンに自動でフォーカス移動する | |
| // @namespace https://github.com/unarist/ | |
| // @version 0.3 | |
| // @author unarist | |
| // @match https://*/web/* | |
| // @grant none | |
| // @downloadURL https://gist.github.com/unarist/89a640badf8b340db29c5f72fcaceb54/raw/mastodon-autofocus.user.js | |
| // ==/UserScript== | |
| (function() { | |
| // 多分Mastodon1.4では標準機能になってる(#3253)ので、1.3向けの検知ロジックだけにする | |
| if (!document.querySelector('.app-holder[data-react-class="Mastodon"]')) { | |
| if (document.querySelector('#mastodon')) | |
| console.log('mastodon-autofocus.user.js: Mastodon1.4では標準搭載(のはず)なので終了します。'); | |
| return; | |
| } | |
| new MutationObserver(([{target}]) => (target.querySelector('.button') || target).focus()) | |
| .observe(document.querySelector('.modal-root'), {childList: true}); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment