如何使用 Safari 扩展将链接附加到文本块

发布于 2024-09-18 03:19:43 字数 387 浏览 4 评论 0原文

我正在尝试创建一个 safari 扩展程序,它将在任何看起来像 BibText 的文本后面放置一个“添加到 BibDesk”链接 条目。 BibText 条目看起来像这个

@string{
    foo  = "bar",
    foo2 = "bar2"
} 

我知道如何构建必要的正则表达式,但我的问题是使用 javascript 在页面上的所有文本中搜索特定文本的最佳方法是什么?

I'm trying to create a safari extension that will place an "Add to BibDesk" link after any text that looks like a BibText entry. BibText entries look like this:

@string{
    foo  = "bar",
    foo2 = "bar2"
} 

I know how to construct the necessary regex, but my question is what's the best way, using javascript, to search all the text on a page for a particular bit of text?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人海汹涌 2024-09-25 03:19:43

使用选择器获取可以包含文本节点(div、p 等)的任何元素,然后为每个元素搜索任何 BibText 条目并用其自身替换匹配的文本以及附加到末尾的执行工作的链接。

Get any elements that can contain text nodes (div, p, etc.) using a selector, then for each element search for any BibText entries and replace the matched text with itself PLUS the link that does the work appended to the end.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文