You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chrome或Firefox浏览器扩展/自定义方案需求:实现按键跳转至文本中的***通配符位置

Chrome或Firefox浏览器扩展/自定义方案需求:实现按键跳转至文本中的***通配符位置

Hey there! I totally get wanting that seamless wildcard-jumping functionality like EPIC's F2 shortcut for your new EMR—super handy for speeding up note-taking. Since the EMR doesn’t have built-in support and you couldn’t find a ready-made extension, here’s a flexible custom solution using a user script (works for both Chrome and Firefox):

Option 1: Custom User Script with Tampermonkey

Tampermonkey is a popular browser extension that lets you run custom JavaScript on specific websites, perfect for adding this exact functionality.

  1. Install Tampermonkey

    • For Chrome: Search for "Tampermonkey" in the Chrome Web Store and install it.
    • For Firefox: Grab it from Firefox Add-ons.
  2. Create a New Script

    • Click the Tampermonkey icon in your browser toolbar, then select "Create a new script".
    • Replace the default template with the code below, and make sure to update the @match line to your EMR’s actual domain (e.g., *://your-emr-website.com/*):
// ==UserScript==
// @name         EMR Wildcard Jumper
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Jump between *** wildcards in EMR notes using F2
// @author       Your Name
// @match        *://your-emr-domain.com/*  // Replace with your EMR's URL
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let currentWildcardIndex = 0;

    document.addEventListener('keydown', function(e) {
        // Trigger on F2 press
        if (e.key === 'F2') {
            e.preventDefault();
            const activeElement = document.activeElement;

            // Only target editable areas (textarea or contenteditable elements)
            if ((activeElement.tagName === 'TEXTAREA' || activeElement.isContentEditable)) {
                const content = activeElement.textContent || activeElement.value;
                const wildcardRegex = /\*\*\*/g;
                const matches = [];
                let match;

                // Collect all positions of *** in the content
                while ((match = wildcardRegex.exec(content)) !== null) {
                    matches.push(match.index);
                }

                if (matches.length === 0) return;

                // Cycle through each wildcard position
                currentWildcardIndex = (currentWildcardIndex + 1) % matches.length;
                const targetPos = matches[currentWildcardIndex];

                // Focus and select the wildcard to make replacing easy
                if (activeElement.tagName === 'TEXTAREA') {
                    activeElement.focus();
                    activeElement.setSelectionRange(targetPos, targetPos + 3);
                } else if (activeElement.isContentEditable) {
                    const range = document.createRange();
                    const selection = window.getSelection();
                    range.setStart(activeElement.firstChild, targetPos);
                    range.setEnd(activeElement.firstChild, targetPos + 3);
                    selection.removeAllRanges();
                    selection.addRange(range);
                    activeElement.focus();
                }
            }
        }
    });
})();
  1. Save and Test
    • Save the script (Ctrl+S or Cmd+S), then navigate to your EMR. Open a note template with *** wildcards, click into the text area, and press F2—you should jump directly to the next wildcard, with it selected ready for your input.

Quick Notes for Troubleshooting

  • If your EMR uses iframes for note-taking, you’ll need to update the @match line to include the iframe’s domain too.
  • If your wildcards use a different pattern (e.g., ___ or [wildcard]), just adjust the wildcardRegex line to match (e.g., /___/g).
  • If the cursor doesn’t position correctly in contenteditable areas, some EMRs use nested elements—you might need to tweak the range selection logic a bit, but this basic script works for most standard setups.

Let me know if you hit any snags getting this up and running—I’m happy to help refine it for your specific EMR!

备注:内容来源于stack exchange,提问作者MoJamesM

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 16:04:31