Does chrome extension api support downloads directly from browsing cache? - javascript

I'm implementing a simple web picture grabber, using chrome.downloads api.
I grab the image urls in content script, and then call chrome.downloads.download to download them in the background script. It works well, but I want it faster.
I find that if users click "save image as" in the context menu of <img> object, the downloading speed is very fast and almost seamless. I think it downloads directly from cache.
However, using chrome.downloads seems independent of the loading of <img> objects; even though pictures are already loaded on the webpage, chrome.downloads.download takes some time to download each image, not so fast as "save image as". So I think it download from the url, regardless of cache.
In fact, doing so has each picture downloaded twice: one to cache to browser display, the other to download folder. It's clearly a waste of time and net resource.
So... back to the topic: is there any api supporting downloading directly from the chrome's browsing page? Just like "save image as".

I have asked the same question before. Chrome APIs for the public is really backward. They don't really have most features the browser offers.
In short, no, you cannot. "Save image as" is the only way you can access the cache and save them to another location on your disk.

Related

Download complete web page from Chrome extension

is it possible to programmatically download complete web page (like Chrome can when you hit Ctrl+S) from my web extension?
I need the HTML with accompanying resources (images etc), so pageCapture (MHTML) is not an option i guess (also downloading each resource with ajax separately is not an option here).
Not sure I understood your problem, are you writing your own extension or looking for one?
If you're looking for one I'd recommend Save All Resources extension.
Please note: ensure you are aware of the data that is shared by this extension with the developer (privacy).
Save All Resources collects the following:
Website content
For example: text, images, sounds, videos or hyperlinks
yes you can by using HTTrack software.
HTTrack allows you to download a World Wide Web site from the Internet to a local directory, building recursively all directories, getting HTML, images, and other files from the server to your computer. HTTrack arranges the original site's relative link-structure. Simply open a page of the "mirrored" website in your browser, and you can browse the site from link to link, as if you were viewing it online. HTTrack can also update an existing mirrored site, and resume interrupted downloads. HTTrack is fully configurable, and has an integrated help system.
download here.
https://www.httrack.com/page/2/en/index.html
so hope the answers.

Control a PPTX file with Javascript offline

This is an odd use-case and I've tried to steer the users away from this, but I have a request to load locally stored PPT files in an HTML environment.
The idea is to view the PPT in an iframe so that I can "decorate" all around it. Users will be creating playlists, of sorts, so I need to add "next" and "previous" presnetation buttons, etc.
I have an online version of this working using the Office webapp link that many other posts have shared, but there is a concern for poor connectivity so they want it to be available offline.
My instinct was to shape this up as a PWA. I can make them use Chrome, so I have the FileSystem API "caching" the PPT files from the online source. However, I have no way to render the saved files!
Because it's offline, I can't use googledocs or continue to MS web office.
I don't know the AppCache feature well enough, but wondered if I can preload all of the docs in an iframe, will it cache those. My thought is that it won't, because the content is on microsoft (or Google's) site.
All users will have a legal copy of PPT on the computer, if that helps at all.
So far I have tried storing the files using the filesystem API in combination with the Chrome offline viewer extension and alternatively the Native Docs extension. The Chrome one will allow me to open a doc, but directly in edit mode. I need to simulate the behavior of a ppsx file, but neither extension works with ppsx files and I don't see documentation for an API that will allow me to "auto-play" the presentations.
Thanks for any ideas!
Wayne

Downloading Silently by Chrome Extension

I need my extension to bulk download assess in a web page.
I set saveAs:false for chrome.downloads.download so that I do not get saveAs dialog. But when download starts, download bar at the bottom of the browser gets opened and all list of downloads puts into it. This clutters the download bar and Chrome interface.
Is it possible to prevent download bar from opening and not put the downloads that are started by an extension?
It's possible to hide the download bar (called shelf in Chrome UI lingo) completely, but not filter out specific downloads.
chrome.downloads.setShelfEnabled(false); // requires "downloads.shelf" permission
You can clear out your downloads from the download list with chrome.downloads.erase method.
Consider an alternative (if more technically challenging) approach of "downloading" through XHR to a temporary HTML5 FileSystem, forming an archive file, and then calling chrome.downloads on that. May not work if you need all the files immediately unpacked.

How to save indirectly loaded images from webpages

I know that most of the media in web pages are temporarily stored to a temp folder or browser cache. Some are directly embedded in web pages so that we can see the source and can save them. But how to save images loaded using any other method?
You can see what I am talking about here. Is there any solution to save images from this site's gallery?
Yes there is a way to save the images by using the followings
1) Mozilla Firefox
2) Firebug
open the net console in it and select the tab named images
in that u can see all the images and save the images
for your reference, I attached a image.
then copy the location by right click and paste the location
and get the image.
~~~~~~ Happy Coding ~~~~~~~~~~~
Generally, js can't hold the image itself. but the Attribute src, a string instead. And js cannot handle the file on client, you can't modify, move, or copy files. So if you want to keep the images, you can send a http header like if-Modified-Since on server side with php or java, then the browser will not load the image again.
May this will help you. Good Luck!
You could try to use a offline browser.
They save whole webpages and deeping on software they catch more or less.
Offline Browsers

Precache file with Javascript in the browser?

How can I do this:
the page loads
javascript loads a remote PDF file into local memory
the user clicks a button/link
the system launches the PDF reader or starts a download dialog with the PDF file already in memory
In other words, it's a regular file download in the browser EXCEPT that the file has already been loading in the background in order to speed up its receipt when/if the user decides to download the file.
You would have to encode the file (perhaps via a servlet), then you could get it through an XHR, and write it into a data uri, which you could then attach to a button or link.
This technique would probably only work on small files and very recent browsers.
StackOverflow won't let me post an example link as a link, so to test the concept, you'll have to copy the following line into an html file and see if you can load the link:
pdf link
This worked perfectly in Chrome when I tested it just now, and worked partially in Firefox. It didn't work at all in my version of IE.
Another potential solution is to make absolutely sure that the pdf is being cached, and then try to load it in a hidden iframe. Whether this works or not will depend on how the user has their browser set up.
You should consider not doing it at all, given the difficulties.

Categories