Last active
April 28, 2017 11:27
-
-
Save unarist/bf89a5f054fb1d58a39067f61626b9c2 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.1 | |
| // @description 何も入力せずにうにー!を押すとうにー!ってうにー!します。 | |
| // @author unarist | |
| // @match https://yuruyuri.family/ | |
| // @match https://yuruyuri.family/web/* | |
| // @downloadURL https://gist.github.com/unarist/bf89a5f054fb1d58a39067f61626b9c2/raw/mastodon-default-toot.user.js | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| document.addEventListener('click', e => { | |
| const btn = $(e.target).closest('button')[0]; | |
| if (btn && btn.textContent.match(/うにー/)) { | |
| const textarea = document.querySelector('textarea[placeholder="今なにしてる?"]'); | |
| if (textarea.value.length === 0) { | |
| textarea.value = 'うにー!'; | |
| // Simulate React's "change" event | |
| // https://github.com/vitalyq/react-trigger-change/blob/v1.0.2/lib/change.js#L135-L140 | |
| const event = document.createEvent('HTMLEvents'); | |
| event.initEvent('input', true, false); | |
| textarea.dispatchEvent(event); | |
| } | |
| } | |
| }, true); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment