从文本字符串中查找关键字列表并查找不匹配的匹配项(find a list of keywords from a text string and find inexact matches)
我有一个我想在文本字符串中找到的关键字列表。 完全匹配工作正常,但是任何人都知道库可以帮助进行近似匹配,例如,如果我提供的单词列表是
["hello", "bye"]
我想看看文本字符串是否有hlelo
到某种程度的“亲近”有什么建议吗?I have a list of keywords I'm trying to find in a text string. The exact matches works fine but is anyone aware of library that could help with approximate matches so for instance if the list of words I provide are
["hello", "bye"]
I'd like it to watch if the text string hashlelo
to a certain degree of "closeness" Any recommendations?
原文:https://stackoverflow.com/questions/8086779
最满意答案
您可以通过以下两种方式处理它:
您可以使用以下命令添加上下文菜单和侦听器:
chrome.runtime.onInstalled.addListener(function() { /* Add context menu and listener */ });
您可以删除上下文菜单和侦听器,然后在每次调用文件时重新添加它。
You can handle it one of two ways:
You can add the context menu and the listeners on install using:
chrome.runtime.onInstalled.addListener(function() { /* Add context menu and listener */ });
You can remove the context menu and listener, and then re-add it each time the file is called.
相关问答
更多-
请检查contextMenus ,您可以通过设置上下文"browser_action"来创建扩展上下文菜单 的manifest.json { "name": "36715370", "version": "0.1", "manifest_version": 2, "background": { "scripts": ["background.js"] }, "browser_action": { "default_title": ...
-
chrome.contextMenus.create({ title: "Addkill", contexts: ["link"], onclick: killAdd }); 我不得不承认我对javaScript或chrome扩展没有任何经验 老实说,我建议您先学习JavaScript然后开始创建Chrome扩展程序。 chrome.contextMenus.create({ title: "Addkill", contexts: ["link"], onclick: killAd ...
-
这里的问题是您尝试使用不同的值多次提交表单。 基于使用不同的值多次提交HTML表单 ,您所要做的就是在提交表单之前为表单的目标提供唯一值并打开新选项卡: rightclick.js var i = 0; function createDirectoryRequest(selectText) { var form = document.createElement("form"); form.setAttribute("method", "post"); form.setAttribu ...
-
您可以通过以下两种方式处理它: 您可以使用以下命令添加上下文菜单和侦听器: chrome.runtime.onInstalled.addListener(function() { /* Add context menu and listener */ }); 您可以删除上下文菜单和侦听器,然后在每次调用文件时重新添加它。 You can handle it one of two ways: You can add the context menu and the listeners on instal ...
-
函数不能在if块中声明。 此外, info可以传递给encodeURIComponent 。 以下代码有效: chrome.runtime.onInstalled.addListener(function() { chrome.contextMenus.create({ title: "Search Google for image", id: "gsearch", contexts: ["image"] }); }); chrome.cont ...
-
除了创建多个扩展外,没有其他解决方法。 Google Chrome开发者页面中明确指出,它不允许在主要上下文菜单中显示多个项目。 如果扩展程序尝试创建多个项目,则Chrome会将所有项目折叠为一个单项内容项目。 There's no workaround than creating multiple extensions. It's clearly stated in the Google Chrome Developer page that it doesn't allow more than one i ...
-
Chrome扩展程序 - 在上下文菜单中确定选择文本或页面(Chrome Extension - Determining selection text or page in Context Menu)[2023-04-25]
如果您想知道上下文是否为page ,则可以仅为页面上下文创建另一个上下文菜单: chrome.contextMenus.onClicked.addListener(getword); chrome.runtime.onInstalled.addListener(function() { var contexts = ["selection","link","editable"]; var title = "Chrome Extension"; chrome.contextM ... -
在您单击扩展程序的浏览器操作的同一刻,我会尝试使用LocalStorage来保存信息。 然后在content_script中,您可以在LocalStorage中检查该信息并显示菜单,而无需按下扩展按钮。 简而言之,我的意思是: manifest.js "background": { "scripts": ["background.js"], "persistent": true }, "content_scripts": [ { "matches": ["http://*/*"], ...
-
Chrome扩展程序,自定义上下文菜单项未显示[重复](Chrome extension, custom context menu item not showing [duplicate])[2022-04-13]
我仔细阅读了几个示例扩展的源代码 。 由于我将"persistent"设置为false ,因此扩展名正在使用Event Page运行。 因此,我的代码通过从chrome.contextMenus.create的参数对象中删除onclick来chrome.contextMenus.create : chrome.contextMenus.create({ "id": "qwertyuiop", "title": "Click Me", "contexts": ["page", "selection ... -
没有办法触发上下文菜单,可能永远不会。 上下文菜单是模态的,它们消除了用户的控制,因此可以用于垃圾邮件/骚扰用户。 我猜你需要在选择文本的上下文菜单中显示一些命令,所以我会尝试用HTML创建一个上下文菜单,并通过内容脚本而不是使用contextMenus API发送命令。 There is no way to trigger context menu and there probably never will be. Context menus are modal, they take away contr ...