将Chrome扩展程序权限限制为某些域 [英] Limit Chrome Extension Permissions to Certain Domain

查看:106
本文介绍了将Chrome扩展程序权限限制为某些域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个chrome扩展程序,仅在manifest.json中使用"matches":[]在某个域上运行.但是,由于我需要"webNavigation"权限才能运行下面的侦听器脚本,因此会告诉用户我的扩展程序能够在安装时读取其浏览历史记录.由于上述匹配",我认为情况并非如此.

I have a chrome extension that I have running only on a certain domain using "matches":[] in my manifest.json. However, because I need the "webNavigation" permission to run the listener script below, users are told that my extension is able to read their browsing history upon installing. I don't think this is the case, because of the aforementioned "matches."

下面是当扩展程序进入某个页面时用于运行扩展程序代码的侦听器脚本.

Below is the listener script I use to run my extension's code when they get on a certain page.

chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) {
    chrome.tabs.executeScript(null,{file:"content.js"});
});

是否可以在不告知用户扩展程序正在监听所有浏览历史记录的情况下执行此操作?

Is there a way to do this without telling the user that the extension is listening to all browsing history?

推荐答案

尝试一下

chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) {
    chrome.tabs.executeScript(null,{file:"content.js"});
} ,{
url: {
    hostContains: 'foo.com'
  }
});

这篇关于将Chrome扩展程序权限限制为某些域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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