How to run chrome extension in specific domain

Is there a way to limit a Chrome extension to only run on certain urls?

I build an extension that I won't to run only inside specific facebook app. https://apps.facebook.com/appname/*

The extension add option to 'Right click menu' when clicking on image

How can I do that ?

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"
    }

}

Thanks in advance!


To add a menu option that shows only for images on a specific domain you can do the following:

On your manifest:

"permissions": [
    "contextMenus"
],

On your background script:

chrome.contextMenus.create( { 
    title: 'My Menu Item',
    contexts: ['image'],
    documentUrlPatterns: ['https://apps.facebook.com/appname/*'],
    onClick: function( info, tab ) {
    ...
    }
});
链接地址: http://www.djcxy.com/p/66580.html

上一篇: Chrome扩展程序如何将许多文件保存到用户

下一篇: 如何在特定的域中运行chrome扩展