Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tosuke/b792424ddf645c040623b83338bd8c06 to your computer and use it in GitHub Desktop.
Save tosuke/b792424ddf645c040623b83338bd8c06 to your computer and use it in GitHub Desktop.
Firefox + SKK環境で発生する,Scrapboxの検索欄に文字入力ができなくなる問題を修正します.
// ==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