Is there a way to use a downloaded (xml-esque) file in an extension? - google-chrome-extension

I'm attempting to write an emusic download manager extension for Chrome. This would essentially involve parsing the .emx file (xml-esque) downloaded from the site to get the temporary music file URL.
I've gone through everything I can find online about extensions working with downloads, but the problem comes in that the .emx file isn't directly accessible from the web. The link to download it seems to pass through a counter for your account so that it can deduct the cost, and then it pushes a file 0.emx to be downloaded. It doesn't seem to work with any hotlinking, even copying and pasting the button's destination URL into the same browser tab.
I think the only way to get the file is to wait for the 0.emx file to be pushed. Is there any way I can use an extension to intercept that file before it goes to the downloads folder or use it after it's already downloaded?
Thanks!

Related

Joomla 3 problems using Akeeba Release system with zip

I'm trying to use the Joomla ARS. I've set it up and it seems to work for everything except the download of zip files.
I've set it up so that you can see the file in the front end but when you click on it a:
The requested document was not found on this server
error is thrown.
I've tried directly linking the file and it downloads fine. I've also set up an article to check that it'll download and again it works fine. So I don't think there are any permission issues since the zip file can be downloaded just not by using ARS.
Finally I've also tried different file types in ARS and if I swap the zip file for an xml file or a pdf file they both download fine.
Any ideas about how to debug?
I figured it out :)
The site had add a suffix to url switched on which was stopping it getting the correct route. Changed that and it worked as expected.

How do I test file download using intern framework?

I have a requirement where I need to write functional test for download a file and testing its contents.
So i can say there are two parts.
1) Ensure clicking on a link downloads a file
2) Reading the file an checking its contents. Its a csv file, so I Can possibly do some manipulation with the content.
There are several issues with doing this. One is that if you're running a browser on a remote system, you'll need a way to get the file back to the system running Intern. The second issue is that you'll need to know where the downloaded file ended up when it was downloaded. A third issue is that some browsers (FF and IE) pop open OS-level dialogs that Selenium can't deal with.
The first question is: do you really need to download a file in the browser? It sounds like you may be testing a service rather than the browser, in which case you may be able to just download the file using Intern and inspect it there.
Assuming you do need to download a file via the browser, you should be able to configure a browser to not open a confirm dialog and to download the file to a known location, which at least handles 2 of the 3 issues mentioned above. Note that I haven't actually tested this.
In Firefox you can setup a test profile and use it when running tests. You'll likely need to configure the following properties:
browser.download.dir: 'path to download folder'
browser.download.folderList: 2
browser.helperApps.neverAsk.saveToDisk: 'text/csv'
browser.download.manager.showWhenStarting: false
For Chrome you'll pass options through the environment descriptor. The specific options should be:
'profile.default_content_settings.popups': 0
'download.default_directory': 'path to download folder'
Once you've setup the browser, your test code would need to click the link, then wait for some indeterminate amount of time (Selenium doesn't provide any sort of download progress data), then grab the file from the Intern test itself (using a network request or local file operation) to inspect it.

How chrome extension download images to extension root directory

I'm making a chrome extension for the first time.
For my extension, I want it can automatically download images to its extension folder. For example, if the extension folder is /xxxx/abc/, I want it can download images to /xxxx/abc/image/.
To make it, I don't know how to write file/ download image to this directory. I don't want users notice this.
I found an extension can make it. It's called Momentum. It can download images to /xxxx/<extension root dir>/backgrounds/.
Can anybody tell me what technique do I need? Thanks a lot!
No, you can't. An extension has only read-only access to own files.
Instead, you can download to a virtual HTML5 filesystem and use files from it. See this tutorial - the big red warning means no other browser uses this technology, but Chrome does.
You may want to declare "unlimitedStorage" permission to make sure you have the space to store the files.
This being a virtual filesystem, those won't actually be files you can open on your disk. If you need to give files to the user afterward, you can use chrome.downloads to write them to the downloads folder, but that's "write-only", you can't access the contents afterwards.

Website loading deleted file

Working on this website I was going to add a simple .hide(); and onclick animate(); functions to a menu, but the menu div wasn't closed (stupid mistake). When I upload the file to the live website it hides everything in the website cause of the open div tag, obviously I fix it and also delete the jQuery function but when I upload the file to the FTP the website is still showing the old file for some reason.
More info: I already deleted the cache/cookies/history off this computer and reloaded the page and re uploaded the file. Also tried in 4 different computers with 3 different IPs I did a search of all the files and the code is not there anymore. Deleted the directory and it still shows up.
As i can suggest from your question, i can say its a stupid mistake. Happened to me a few times.
I would try the following:
Make a working folder of your "new" website - locally
Delete EVERY file and folder from your server (of course only your whole website)
Get sure that nothing is displayed when you open it at the browser, should be fail
Now load your local folder completely to the new, empty space at your FTP
Rather than re uploading the file. Delete it, visit it in your browser and verify you get a 404 and then upload it again.
I have had this problem before when re-uploading a file in some FTP clients.

How can I open a local file with a local program through my browser?

On my webpage, I have placed a link to a local file (e.g. "text.docx" on my local HD). I would like to double click on this link, and have a third party software which is installed locally on my PC (e.g. Microsoft Word) open it.
I would like to be able to do this with Firefox and Google Chrome. Obviously, I am a newbie to web programming.. can somebody show me the way? I have looked around and had the impression that I need to write and add an extension, maybe?
Thanks for your time. Jakob
This is only possible if you know either the absolute path to the file or the relative path from whatever working directory your browser runs from. You the create a link with
href="file://relative/path/to/file/text.docx"
or
href="file:///absolute/path/to/file/text.docx"
and any modern browser will query the system database for the mimetype of the file depending on its extension, thus prompting to open the correct application.
EDIT
I inawarently introduced a unixism in the previous code: Distinction bewteen absolute and realtive paths as above works well on current *nix desktops, but in Windows an absolute path will most likely look like
href="file://C:/drive/absolute/path/to/test.docx"
Mind the 2 (not 3) slashes a the beginning, and the forward (not backward) slashes.
As far as I know, you can't link to local files from a website. If you upload it to where your files are, you could then be able to download it.
I was able to execute code locally, using Firefox, by adding an extension which used the XPCOM interface. One such extension was "commandrun", and may be found here: https://github.com/aabeling/commandrun .

Resources