Read content of a local file with chrome extension - javascript

I am developing an extension for the chrome browser. I use the KangoExtensions framework. The extension is written in JavaScript. I want to read the content of a file, which is located on the local filesystem. What is the easiest way to implement this?

If you already know the file's path in the filesystem you just need to add a permission to file://*in your manifest file and make a GET XMLHttpRequest to the url file://{filepath}.

Related

How do I use local json in my browser extension?

I'm incredibly lost and new to browser extensions. I am making one related to dragons. Normally I would just use fs but this isn't an option since it's not node.
My browser extension folder has only three files: manifest.json, content-script.js, and dragons.json. I am making the extension in content-script.js and it's going swimmingly, but now I would like to read from and write to dragons.json. My extension will not be published or used for any other users, only me. How can I access this file? I am not trying to read the USER'S files, nor any external online files, just the files that are stored in the extension's folder.

Can JavaScript read files on the hard drive?

Here I have learned that it is possible with JavaScript in HTML to create files offline and save them on the hard disk.
But what about reading files? Can JavaScript access, say one of my .txt files on my self phone and display the read data (or at least place it in the local storage)?
I know that it is possible with PHP, but there is no PHP on my cellphone, while HTML is always there.
You can use <input type="file"> and FileReader to read files stored at local filesystem, see File API; also How FileReader.readAsText in HTML5 File API works?.
If trying at Chromium or Chrome to read file: protocol launch the browser with --allow-file-access-from-files flag, without other Chrome instances running, or use a different --user-data-dir, see Read local XML with JS.

Access Chrome extension from another computer

I coded a little app for Chrome, it's a privacy extension and I want to be able to access it from outside my computer. I read a lot of thing about contents scripts but I don't know if is the way to go. In my extension I have a option.html file and I want to be able to access it if I'm not at home. The file is actually stored on Chrome tabs when I open it. I want to access it but only from my domain, all request must be not executed. Do I have to make a websocket on my extension? Or can I put an iframe into my option.html and read it from a server side with php script?
You need to convert the folder into a .crx type.Visit https://developer.chrome.com/extensions/hosting for more info

Programatically save files to user specified location in firefox extension

I'm writing a firefox extension that writes files to a directory structure at a specified location by the user but can't seem to find documentation on how to include that in the permissions of the extension or how to access this facet in the API. I was initially trying to use a greasemonkey script to accomplish this but ran into the javascript limitation of not being able to access the user's local storage and had read I needed to write it as an extension. Any link or help on how to write a function for a mozilla extension that will save a file to a local disk location? Thanks in advance for any help!

Access local files from HTML5 Desktop Application in html folder

HTML5 is great and I can replace my existing desktop application with it, but just a little security restriction prevents me to complete my job. I plan to create a simple desktop application completely with HTML5 so it can run on any mobile and desktop devices that support HTML-5.
I know about the browser security on local file and the reason behind it, but I don’t know why I couldn’t find a way to grant read-only access to a folder as sandbox. My application does not need to write a file or even does not need to read a file outside of It main html folder. It needs to read the local file just in same folder same as it do on domain.
So please let me know:
Can run browser with specific command to force it grant access to local file that exists in same folder of HTML? It should not disable all local security restriction just grant HTML access to file in same folder or subfolder.
Is it cross platform method to map a local folder as local host that work on mobile platforms?
Is there any manifest file exists to put in folder to grant read access in same HTML folder?
Is there any way to grant read-only access to a folder as sandbox?
Note: I don't want use third party solution such as XULRunner, Mozilla Prism, Adobe Air or any other third party, I need HTML-5 solution to be cross platform if there is any.
Any idea is welcome.
If you need that file so much, why not just load it dynamically inside a JS script as a json object.
So, in other words, put the contents of the file into a js script, and strucutre the file contents into JSON format, then load that script on load or when you require it.
Alternately if you need file IO use localstorage.
according to this site, launching chrome from the cmd with the parameter --allow-file-access-from-files will disable this security feature

Categories

Resources