Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我可以创建一个网站';我可以访问Chrome扩展添加的全局变量吗?_Javascript_Google Chrome_Google Chrome Extension - Fatal编程技术网

Javascript 我可以创建一个网站';我可以访问Chrome扩展添加的全局变量吗?

Javascript 我可以创建一个网站';我可以访问Chrome扩展添加的全局变量吗?,javascript,google-chrome,google-chrome-extension,Javascript,Google Chrome,Google Chrome Extension,假设我有一个Chrome扩展,在每个访问的页面中添加了一些JS代码(这在内容脚本中非常常见): 假设run.js有一个全局templates变量: var templates = {0: 'hello world', 1: 'bye bye'}; // default templates chrome.storage.sync.get("templates", function(obj) { templates = obj.templates; }); document.addEve

假设我有一个Chrome扩展,在每个访问的页面中添加了一些JS代码(这在
内容脚本中非常常见):

假设
run.js
有一个全局
templates
变量:

var templates = {0: 'hello world', 1: 'bye bye'}; // default templates

chrome.storage.sync.get("templates", function(obj) {
    templates = obj.templates;
});

document.addEventListener("keydown", function(e) {
    // add template to textarea if a specific key is pressed
}
问题:我访问的网站能否将我存储在模板中的所有个人数据(因为它位于全局变量
templates
)通过AJAX发送到他们的服务器?
如果是,如何


还是因为Chrome扩展内容脚本变量和页面变量之间存在隔离墙而无法实现?

注意:我已经读过了:但不清楚在我描述的特定情况下会发生什么。注意:我已经读过了:但不清楚在我描述的特定情况下会发生什么。@Basj抱歉,我从文档中复制了错误的文本。请现在看一看。我还添加了一个实际示例,说明当上下文脚本或注入的页面试图从另一个页面访问内容时会发生什么情况。@Basj对不起,我从文档中复制了错误的文本。请现在看一看。我还添加了一个实际的例子,说明当上下文脚本或注入的页面试图从另一个页面访问内容时会发生什么。
var templates = {0: 'hello world', 1: 'bye bye'}; // default templates

chrome.storage.sync.get("templates", function(obj) {
    templates = obj.templates;
});

document.addEventListener("keydown", function(e) {
    // add template to textarea if a specific key is pressed
}