Firefox 浏览器附加组件
  • 扩展
  • 主题
    • 适用于 Firefox
    • 字典和语言包
    • 其他浏览器网站
    • 适用于 Android 的附加组件
登录
Look up dictionary by using dict:/// 预览

Look up dictionary by using dict:/// 作者: Harpseal

Call any dictionary app by using Uri scheme.

3.8 (9 reviews)3.8 (9 reviews)
154 个用户154 个用户
您需要 Firefox 来使用此扩展
下载 Firefox 并安装扩展
下载文件

扩展元数据

屏幕截图
Right click on the text and the 'Look up "Some Keyword" in Dictionary' will appear in the context menu right away.If the "Launch Application" doesn't open automatically, please check the how-to-use to resolve this issue.Permission dialog (after firefox 84+)Option page screenshot.
关于此扩展
Kindly reminded if your OS is not macOS, this addon can't work without a wrapper script to call the external dictionary software for safety reasons. The following guide require a little programming skills. Please check How-to-use for detail.

This addon is forked from another Firefox addon https://addons.mozilla.org/en-US/firefox/addon/mactionary

For more detailed description with pictures, please check the github repo of this addon. https://github.com/Harpseal/LookUp-Dictionary-By-dict-URI-Scheme


Update for firefox 84+ users

There is a new permission dialog to approve after firefox 84+.
Please open the Options page of this addon, check the checkbox, press the save button and try to look up some word. The temporary tab for dict scheme will not be closed and leave the permission dialog for user to approve.
After the permission is approved, please uncheck this checkbox in the Option page for normal use.
For more detail pleace check the How-to-use step4.


* How-to-use

When user right-click on any word on any website, the "Look up in dictionary" will appear in the context menu right away. Please select it, and this addon will send the clicked text or selected texts to the dictionary software which supports dict Uri scheme. (ex. dict:///keyword)

The dict:/// Uri scheme is supported by the build-in dictionary software in macOS. If your OS is Windows or Linux, please take the following steps:

  1. Prepare the "wrapper script" before installing this addon. (require programming skills)

  2. Prepare the "wrapper script" before installing this addon, because this script is the connection to the outside of the Firefox. There are some example scripts written in Python (for Linux users) and Autohotkey (for Windows users) in the end of this guide, and one more Copy/Paste Autohotkey example in the this addon's github page. The example scripts still need some customization. Please trace the scripts and customize for your system.

    Python installed by default on Linux. If your OS is Windows, Autohotkey is recommended. Because Firefox only support to call EXE application on windows, you need to compiler the ahk script to EXE by using the Autohotkey compiler. Please download Autohotkey .zip from its website (https://autohotkey.com/download/) and unzip it, the compiler named Ahk2Exe.exe is in the "Complier" folder.

    Before taking the next step, you should check the script is work properly. To test the script, you can execute in the terminal with with uri scheme as the only one parameter. Make sure the dictionary is showed with the word after the dict:/// correctly ("test" for example). ex:
    C:\Tools> look_up_dict.exe dict:///test
  3. Add dict:/// Uri scheme handler
  4. After some version of Firefox 57+, Firefox ignores all unknown URI scheme (ex.dict:/// on Win/Linux) and doesn't show the "Launch Application" window as before, so we have to add it by ourselves. In order to know how to deal with different types of files and URI schemes, Firefox have a internal list to save the action for each content type. The list is showed in Options->Applications. Unfortunately, even if user can change the actions in Options, Firefox doesn't support add or remove file types. We have to edit the list manually. Please take the following steps:

    2.1. Open your Firefox profile folder
    Click the firefox menu button, click Help and select Troubleshooting Information. The Troubleshooting Information tab will open.
    Under the Application Basics section, click on Open Folder. Your profile folder will open.

    2.2. Close firefox

    2.3. Edit "handlers.json"
    Please copy a backup before editing.
    Add "dict":{"action":4,"ask":true} in the end of json. Please check there are only three } in the end of file. ex.
    ...,"itmss":{"action":4,"ask":true},"gameon":{"action":4,"ask":true},"dict":{"action":4,"ask":true}}}[End-of-file]
  5. Install this addon.

  6. After installation, your can try to right click on any text, the "Look up in dictionary" will appear in the context menu. If this is the first time you try to use this addon, a window named "Launch Application" (showed as the second screenshot) should open, please choose the script/exe which you make in the first step.

    If the "Launch Application" is not showed (firefox's rule is changed again...), please open the firefox's Options and scroll down to "Applications" section (or search). The dict is should in the list with question mark. Open the dropdown menu and click Use other... to select your wrapper script.
  7. Approve permission to run the wrapper script.
  8. (only for firefox 84+)

    Look up a keyword at the first time, the temporary tab for dict scheme will not be closed and leave the permission dialog for user to approve which is a new feature after firefox 84+.

    If no temporary tab are shown and the wrapper script is not triggered, please open the Options page of this addon and check the checkbox to keep the temporary tab open.

    After approving the permission, please uncheck the checkbox and click the save buttom in the Option page of this addon for normal use.


    Kindly reminded that all add-ons will be disable in mozilla's add-ons website (https://addons.mozilla.org) and please try this addon on the other website after the installation is completed.


For more wrapper script examples, please check the github repo of this addon. https://github.com/Harpseal/LookUp-Dictionary-By-dict-URI-Scheme


* Linux (python + GoldenDict)
Please replace the fullwidth space to halfwidth space before using the following python code.
#!/usr/bin/python
import sys
import urllib
from subprocess import call

if len(sys.argv)>=2:
 text = sys.argv[1]
 if text.startswith("dict:///"):
  text = urllib.unquote(urllib.unquote(text[8:]))
 call(["/usr/bin/goldendict",text])

* Windows (Autohotkey + GoldenDict)
dict_path := "C:\Software\GoldenDict\GoldenDict.exe"
uriDecode(Str)
{
Static doc := ComObjCreate("HTMLfile")
Try
{
doc.write("<body><script>document.body.innerText = decodeURIComponent(""" . Str . """);</script>")
Return, doc.body.innerText, doc.body.innerText := ""
}
}

if %0% < 1 ; The left side of a non-expression if-statement is always the name of a variable.
{
ExitApp
}

Loop, 1 ; For each parameter:
{
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.

StringLeft, url_scheme, param, 8
if (url_scheme = "dict:///")
param := SubStr(param, 9)

param := uriDecode(param)
Run %dict_path% %param%
}
开发者留言
This addon is forked from another firefox addon https://addons.mozilla.org/en-US/firefox/addon/mactionary

The github repository of this addon:
https://github.com/Harpseal/LookUp-Dictionary-By-dict-URI-Scheme
评分 3.8(1 位用户)
登录以评价此扩展
目前尚无评分

已保存星级评分

5
6
4
0
3
0
2
1
1
2
阅读全部 9 条评价
权限与数据详细了解

必要权限:

  • 访问您在所有网站的数据
更多信息
附加组件链接
  • 主页
  • 用户支持网站
  • 支持邮箱
版本
0.6.3
大小
42.5 KB
上次更新
3 年前 (2022年9月25日)
相关分类
  • 搜索工具
  • 语言工具
  • 其他
许可证
MIT 许可证
版本历史
  • 查看所有版本
添加到收藏集
举报此附加组件
0.6.3 的发布说明
Fix bug to detect the current browser.
Harpseal 制作的更多扩展
  • 目前尚无评分

  • 目前尚无评分

  • 目前尚无评分

  • 目前尚无评分

  • 目前尚无评分

  • 目前尚无评分

转至 Mozilla 主页

附加组件

  • 关于
  • Firefox 附加组件博客
  • 扩展工坊
  • 开发者中心
  • 开发者政策
  • 社区博客
  • 论坛
  • 报告缺陷
  • 评价指南

浏览器

  • Desktop
  • Mobile
  • Enterprise

产品

  • Browsers
  • VPN
  • Relay
  • Monitor
  • Pocket
  • Bluesky (@firefox.com)
  • Instagram (Firefox)
  • YouTube (firefoxchannel)
  • 隐私
  • Cookie
  • 法律

除非另有注明,否则本网站上的内容可按知识共享 署名-相同方式共享 3.0 或更新版本使用。