WorkFlowy - Focus Fix

Fix WorkFlowy lost focus

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

作者のサイトでサポートを受ける。または、このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         WorkFlowy - Focus Fix
// @description  Fix WorkFlowy lost focus
// @author       rawbytz and Gavin Elster
// @version      2026.04.12
// @license      MIT
//
// @namespace    https://github.com/elstgav
// @homepageURL  https://github.com/elstgav/workflowy
// @supportURL   https://github.com/elstgav/workflowy/issues
//
//
// @match        https://workflowy.com/*
//
// @grant        none
// @run-at       document-end
// ==/UserScript==

//#region src/scripts/focus-fix/focus-fix.ts
const fixFocus = () => {
  const active = document.activeElement?.className
  if (!active || active.includes('searchBoxInput') || active.includes('content')) return
  const matches = document.querySelectorAll(
    '.name.matches .content, .notes.matches .content, .metaMatches .name .content',
  )
  if (matches[0] instanceof HTMLElement) return matches[0].focus()
  const index = WF.currentItem().isMainDocumentRoot() && !WF.currentSearchQuery() ? 2 : 0
  const content = document.getElementsByClassName('content')
  if (content[index] instanceof HTMLElement) content[index].focus()
}
const otherListeners = WFEventListener
window.WFEventListener = (event) => {
  if (event !== 'locationChanged') return
  requestAnimationFrame(fixFocus)
  otherListeners?.(event)
}
const appObserver = new MutationObserver(() => {
  if (!document.querySelector('.page.active')) return
  appObserver.disconnect()
  fixFocus()
})
appObserver.observe(document.body, {
  subtree: true,
  childList: true,
})
//#endregion