从扩展内获取localStorage而不加载页面 [英] Get localStorage from within extension without loading a page
问题描述
我知道如何使用内容脚本从任何打开的wep页面获取localStorage
.因此,我基本上可以使用自己的网页打开一个新标签,并使用内容脚本读取存储数据并将其发送到后台页面.
I know how to get the localStorage
from any open wep page by using content scripts. So I'm basically able to open a new tab with my own web page and read the storage data with a content script and message it to the background page.
但是现在我想这样做,而不必每次都加载外部页面.有没有一种方法可以直接从扩展名内访问页面的localStorage
?也许直接查询chrome.
But now I'd like to do this without loading an external page every time. Is there a way to access the localStorage
of a page directly from within the extension? Maybe some query to chrome directly.
推荐答案
我看不到任何API .
您的选择是:
-
制作一个本机消息主机应用程序,该应用程序将直接从<浏览器用户配置文件中的c2>目录.例如:使用Javascript在浏览器中直接读取Sqlite3的最佳方法是什么?
Make a native messaging host application that would read database files directly from
Local Storage
directory in the browser user profile. An example: What's the best way to read Sqlite3 directly in Browser using Javascript?
将其他页面放入iframe:是否可以使用HTML5本地存储在不同站点的页面之间共享数据?
Put the other page into an iframe: Is it possible to use HTML5 local storage to share data between pages from different sites?
P.S.引用自 Nicholas C. Zakas的跨域localStorage 文章.
P.S. "Ironic side note" quoted from Cross-domain localStorage article by Nicholas C. Zakas.
谁知道跨域客户端数据存储将很有用?实际上,WHAT-WG做到了.在Web存储规范的初稿(当时是HTML5的一部分)中,有一个名为
globalStorage
的对象,该对象使您可以指定哪些域可以访问某些数据. [...] 由于规范仍在不断发展,因此在Firefox 2中过早实现了globalStorage接口.出于安全方面的考虑,globalStorage已从规范中删除,并替换为特定于起源的localStorage.
Who knew cross-domain client-side data storage would be useful? Actually, the WHAT-WG did. In the first draft of the Web Storage specification (at that time, part of HTML5), there was an object called
globalStorage
that allowed you to specify which domains could access certain data. [...] The globalStorage interface was implemented in Firefox 2 prematurely as the specification was still evolving. Due to security concerns, globalStorage was removed from the spec and replaced with the origin-specific localStorage.
这篇关于从扩展内获取localStorage而不加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!