页面加载时显示Firefox WebExtension页面操作 [英] Display Firefox WebExtension Page Action when page loads

查看:78
本文介绍了页面加载时显示Firefox WebExtension页面操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试通过阅读以下文档来了解如何使用WebExtension页面操作:

I have been trying to read up on how to use WebExtension Page Actions by reading the following docs:

  • https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/page_action
  • https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/pageAction
  • https://developer.mozilla.org/en-US/Add-ons/WebExtensions/user_interface/Page_actions
  • https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/pageAction/show

我找不到加载example.com中的页面时如何配置扩展名以在URL栏中显示页面操作按钮.所有文档似乎都假定页面操作图标已经可见,并显示了如何处理对其的点击.

I am unable to find how I configure my extension to show the page action button in the URL bar when a page from example.com has loaded. All the docs seem to assume the page action icon is already visible and shows how to handle clicks on it.

首先,我想我可以通过清单配置它,但是似乎它与内容脚本的支持方式不同.然后,我试图找到要从background.js调用的API,但未找到任何API.

First I thought I could configure it through the manifest but it does not seem to be supported in the same way as content scripts. Then I tried to find an API to call from background.js but have not found any.

如何在example.com上显示我的页面操作图标?

How do I show my page action icon on example.com?

推荐答案

Starting with Firefox 59, there will be a much simpler solution. In manifest.json, just use the show_matches property of page_action:

"page_action": {
    "show_matches": ["*://*.example.com/*"],
    ...
}

这篇关于页面加载时显示Firefox WebExtension页面操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆