【问题标题】:How to run chrome extension in specific domain如何在特定域中运行 chrome 扩展
【发布时间】:2013-10-25 17:51:54
【问题描述】:

有没有办法将 Chrome 扩展程序限制为仅在某些 url 上运行?

我构建了一个扩展,我不会只在特定的 facebook 应用程序中运行。 https://apps.facebook.com/appname/*

点击图片时,扩展添加了“右键菜单”选项

我该怎么做?

manifest.json

{
  "name": "profiler",
  "description": "Show user profile page",
  "version": "0.2",

  "background": {
    "scripts": ["dating.js"]
  },
  "manifest_version": 2,
  "icons": {
    "16": "icon.png",
    "48": "icon.png",
    "128": "icon.png"
    }

}

提前致谢!

【问题讨论】:

    标签: facebook google-chrome google-chrome-extension manifest


    【解决方案1】:

    要添加仅显示特定域上的图像的菜单选项,您可以执行以下操作:

    在您的清单上:

    "permissions": [
        "contextMenus"
    ],
    

    在你的后台脚本上:

    chrome.contextMenus.create( { 
        title: 'My Menu Item',
        contexts: ['image'],
        documentUrlPatterns: ['https://apps.facebook.com/appname/*'],
        onClick: function( info, tab ) {
        ...
        }
    });
    

    【讨论】:

    • 投反对票的人是否关心解释投反对票的评论?
    猜你喜欢
    • 2018-12-02
    • 2021-05-05
    • 1970-01-01
    • 1970-01-01
    • 2022-11-18
    • 2016-08-28
    • 1970-01-01
    • 2021-09-15
    • 1970-01-01
    相关资源
    最近更新 更多