Last active
May 23, 2021 15:13
-
-
Save tosuke/b792424ddf645c040623b83338bd8c06 to your computer and use it in GitHub Desktop.
Firefox + SKK環境で発生する,Scrapboxの検索欄に文字入力ができなくなる問題を修正します.
This file contains 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 Scrapboxの検索欄に入力できるようにする | |
// @namespace https://tosuke.me | |
// @version 0.2 | |
// @description Firefox + SKK環境で発生する,Scrapboxの検索欄に文字入力ができなくなる問題を修正します. | |
// @author tosuke | |
// @match https://scrapbox.io/* | |
// @icon https://www.google.com/s2/favicons?domain=scrapbox.io | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
async function waitFor(selector) { | |
while(true) { | |
const el = document.querySelector(selector) | |
if(el != null) return el | |
await new Promise(r => requestAnimationFrame(r)) | |
} | |
} | |
waitFor('.navbar input.form-control').then(el => { | |
const seen = new Set() | |
el.addEventListener('compositionend', ev => { | |
if(seen.has(ev)) return | |
ev.stopPropagation() | |
seen.add(ev) | |
Promise.resolve().then(() => { | |
el.dispatchEvent(ev) | |
setTimeout(() => { | |
seen.delete(ev) | |
}, 1000) | |
}) | |
}, { capture: true }) | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment