Please I am new to building Chrome Extensions. After the user installs the extension, I want them to configure it by specifying a directory where the app can save files. I want to do this by opening a save file dialog so they can browse to the folder of their choice. How do I do this?
The answer is that there is no means in the Chrome Extension API to write files outside of the sandboxed file system provided by Chrome. This could theoretically be done by writing an interface in C and then call that, but so far I have not yet seen a successful implementation.
Related
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.
Google Chrome allows you to preview local PDF files in the browser like pictured below:
I am working on an extension that takes whatever PDF is in the browser preview and opens it in my custom editor/markup tool.
I have been successful in loading PDFs from remote URLs because I can just send the remote URL to my server, download it there, and open the PDF in my app using PDFjs.
How can I accomplish the same functionality for local PDF files?
I have looked into possibly using javascript to create a File object from local PDF files but Chrome doesn't allow access to the local file system.
I am hoping to accomplish this functionality by the user just clicking my extension icon, similar to the popular extension, Kami.
you need to add permissions to your extension:
"permissions": ["file://*/*"]
to ensure that you have permissions for local files, use:
chrome.extension.isAllowedFileSchemeAccess
P.S. have a good day and do not use upwork for these type of questions :-D
I need full path to file when file is opened. For example user open file.txt but it will be opened with notepad or other. But how to register "hook" from NPAPI plugin to get path to file and prevent opening in other program?
An NPAPI plugin doesn't sound like it's at all the right technology for what you want to do. Plugins are for running native in the context of a specific web page, whereas it sounds like you just want a local application that's registered with the OS as the handler of certain file types.
I want to provide some functionality through an extension. This requires (read and execute) access to some resource files (an mp3 file, a swf file and two js).
I know user scripts cannot access local files and I need an extension (add-on) to do that.
But can I start by writing a greasemonkey script and compiling it to a xpi?
How should I specify the path to the file for it to work when compiled into an xpi?
This question is close to what I'm trying to do, but does not say anything about the path.
Yet this other question discusses how to add resources to your xpi, but assumes you write the xpi from scratch not if you compile a greasmonkey user script to an xpi
I am not familiar with greasemonkey, however I have successfully written to files using a FireFox addon. Once you have a FireFox addon which you can modify, you can see the page here: File I/O - MDC for some help writing files via the API in FireFox. I use the nsiFilePicker service to select the file/path.
In my application I want to open some files with the correct default programmes, like .doc file should be open with WORD and .psd files should be opened with Photoshop if it is installed, and this should be done under html or java script.
Please tell me how to do it.
JavaScript cannot run programs, but if you have a file on your server you can simply link to it:
<a href='image.psd'>Download File</a>
Users will be promped to download the file or open it using the default program (for most files). Again - as others have said - this is determined by the browser. IE can open doc files on the browsers, and PDF documents can be opened that way too.
There is no way for you to choose which application will be used to open your files with javascript...It just doesn't have that power.
I don't think this is possible in JavaScript without using any activeX or something like that. Js has no access to locally installed applications.
Browsers typically don't have access to the computer's filesystem for security reasons. If you know the exact path to a file you can point the browser at it using a file: URI, e.g.
file:///C:/path/to/file.ext
You may also be able to do this with a plugin, eg ActiveX, however I am unsure as to what security measures that would have.
Invoke the system command 'open'. Works on Windows and Unix based clients.
Depending on where your script runs, you might not be able to invoke system commands though, for instance in a browser sandbox.
If you provide a link to a file on the local file system (eg: <a href="file:///C:/mydoc.doc">) then the browser will open it - however this is not a great way to do it since the browser will first show a dialog ("Do you wish to Save or Open") and then it will "download" it into temporary files as it would if the file were remote. In this case, if you edit and save the file, it'll be the version now in your temp folder. This might not be a problem if your files are read-only, but generally it's not a great user experience.
The only other method is to use ActiveX, which is actually rather easy (though I don't have the exact code on me now - write a comment if you're interested in a snippet and I'll update). Of course this comes with the giant flashing caveats of:
It only works in Internet Explorer.
You need the user to fiddle with their security settings for the ActiveX scripts to run.