开发者

Access Google Chrome's cache

开发者 https://www.devze.com 2022-12-28 16:58 出处:网络
Is it possible to access Google Chrome\'s cache from within an extension? I\'d like to write an extension that loads a cached version of a page when the online one can\'t be accessed (e.g. Internet c

Is it possible to access Google Chrome's cache from within an extension?

I'd like to write an extension that loads a cached version of a page when the online one can't be accessed (e.g. Internet connectivity issue).

Updated: I know I could write an NPAPI plugin accessible through an extension to accomplish this but I'd rather not suffer writing one... I am after a solution without resorting to NPAPI, please.

Note: as far as I can tell, Google Chrome doesn't support this functionality (at least not out-o开发者_运维知识库f-the-box): I just had an episode of "no Internet access" and I was stranded...


Unfortunately, I'm 99% sure that this is impossible without using an NPAPI in your extension.

Chrome extensions are sandboxed to their own process, and can only access files within the extension's folder.

There is some support for things like chrome://favicon/. But that's about it, at least for now.

Source (Google Chrome Extensions Reference)


P.S. I just had a crazy idea. Extensions only have access to files in their folder... but Chrome stores it's cache in the Cache folder. What you might try is, copy (or move) the Cache folder into a subfolder within the extension. The extension should now be able to access the cache.

Whether this is enough to actually enable offline mode... I don't know. I do see some HTML files (and obviously a lot of images) within my Cache folder, though.

In fact, even without using an extension, I can open up the HTML files in Chrome. And because they're stored on your computer, you should be able to access them even without internet.

P.S. the Cache folder is stored at PATH-TO-CHROME/Default/Cache

P.P.S. there is a way to store an entire webpage and archive it for later use. Check out this extension:

https://chrome.google.com/extensions/detail/mpiodijhokgodhhofbcjdecpffjipkle


Just make a simple plugin manifest that calls an AJAX page which loads jQuery from CDN, and then uses it to parse all the <a> elements on the page and alter the href values to have this prefix: http://webcache.googleusercontent.com/search?q=cache:

So <a href="http://stackoverflow.com/questions/blah"> becomes:

<a href="http://webcache.googleusercontent.com/search?q=cache:http://stackoverflow.com/questions/blah">

Voilà, you are cache surfing, but you still need to get to Google. I understand this answer is a bit outside the scope of the question but still solves a lot of web connectivity issues.

I'm tempted to just go write this plugin but I bet it'd be taboo in Google's eyes, so it'd get blocked or removed rather quickly. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消