简体   繁体   English

如何将文本从一个标签复制到另一个标签?

[英]How to copy text from one tab to another?

I am working on an extension that allows me to copy data from a website on one tab to another open on a different tab. 我正在开发一个扩展程序,该扩展程序使我可以将数据从一个选项卡上的网站复制到另一个选项卡上的另一个网站。 The two websites have different origins. 这两个网站的来源不同。 I tried browser.storage.local but it doesn't seem to be working: 我尝试了browser.storage.local但似乎无法正常工作:

Storing data: 存储数据:

browser.storage.local.set({
  'title': 'some title',
  'date': 'some date'
});

Retreiving data: 检索数据:

let promise = browser.storage.local.get(['title', 'date']);
promise.then(function(item) {
  console.log ('promise success');
  console.log('title: ', item.title);
}, function(error) {
  console.log('error', error);
});

Why is it not working and how do I fix it. 为什么它不起作用以及如何解决。 Thanks in advance. 提前致谢。

I just figured it out, it requires a storage permission. 我只是想通了,它需要存储权限。 I added the following line to my Manifest.json file and it worked: 我将以下行添加到Manifest.json文件中,它可以正常工作:

"permissions": ["storage"],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM