I'm developing Chrome Extension that runs on my_webpage.com and request user to log in to see the web page. So I need to store password somewhere locally, first I used local storage but the problem is that it won't load data on my_webpage.com when data is saved localy in settings. Is there any other option to read/write data locay with Chrome Extension?
chrome.storage API was created specifically for that purpose.
It's available both to extension scripts (e.g. background) and content scripts.
Note though that this storage is not considered secure (not that there are alternatives that are secure, besides using chrome.identity to store OAuth tokens)
for saving the username or password two things can help u
create database and save values in tables.
write data to file in json format and read from file to load data
Related
I am new to web development. I am writing google chrome extension that connects to some API. I have one page for user's settings with fields like API key, and more stuff that user want's to configure.
My question as a developer where and how should I save this settings, I thought creating a json file that it would be possible to export the file and import settings file.
Should the server save this settings? should I save it on user's machine? any suggestions?
I think it will be better if you allow user to save on their machine, it's safer and your users have to take all responsibility to keep it safe.
You can use Extension Options to provide a UI for your users to save their credentials. And in that option page, you should use chrome.storage API to store the credentials so that whenever user access to option page, their credentials still there. Later on, when you want to use user credentials to send API, just use chrome.storage API to query the credential.
I'm looking for the best client side storage for my chrome extension. Local storage isn't suitable as it can be erased by the user deleting their cookies (which is a common occurrence).
What storage can I use for permanent storage in a Chrome Extension (excluding WebSQL - deprecated)?
Try the Chrome storage API.
This API has been optimized to meet the specific storage needs of
extensions. It provides the same storage capabilities as the
localStorage API with the following key differences:
User data can be automatically synced with Chrome sync (using storage.sync).
Your extension's content scripts can directly access user data without the need for a background page.
A user's extension settings can be persisted even when using split incognito behavior.
It's asynchronous with bulk read and write operations, and therefore faster than the blocking and serial localStorage API.
User data can be stored as objects (the localStorage API stores data in strings).
Enterprise policies configured by the administrator for the extension can be read (using storage.managed with a schema).
I want to execute queries against a local SQLite file, from JavaScript. How can this be done?
By local, I mean a .sqlite file on the user's computer. I do not need storage for an application, so suggestions about WebSQL are not helpful.
The use-case is, I have many local SQLite files that I use as a database for other applications. I am trying to build a Chrome Extension that lets me query the SQLite files so I can see data contents without having to use my SQLlite workbench app, which sucks.
An extension would not be able to do that. While you can "upload" a file to an extension, it would not retain access to the file on disk; it would be just a snapshot at the moment of an upload.
An app, however, can. With chrome.filesystem API, you can request read or read/write access to a file, and retain the resulting entry to query it again later without dialogs to the user.
Of course, it's up to your JS code to actually read the database. There is no API for that, you need to use a library.
I've started developing mobile website using jquery mobile. Since I have to carry accross multiple pages some json data I wonder what would be a better approach, storing that json data inside cookie or using html5 local storage. Both approaches would use jquery.
Scenario would be following:
Home controller returns some initial data as json
User selects some from that initial list
User selection should be stored immediatly on local storage
When navigate further on different page those data should be available (retrieving from local storage)
Either approach will work. The decision on which to use comes down to a handful of points:
Do you need access to the JSON data on the server? If so, it's simpler to use cookies (otherwise you'll have to script the page to manually send the JSON when the server needs it). Or if you rarely/never need the JSON data on the server, you'll save some bandwidth by using local storage.
Do you need to store large amounts of data? With cookies you're limited to 4K per cookie. With local storage you have access to 5 MB of space.
Are you concerned about supporting older browser versions, or some esoteric/less popular browsers that don't have HTML5 support? Cookies will work with a broader range of browsers than local storage.
Further discussion here: Local Storage vs Cookies
localStorage would be better option for your need than cookie.
Cookie send the request to HTTP during every page is loaded.
I am trying to build a web application to replace the functionality of an older desktop economics program. That program is essentially a calculation engine built on top of a Microsoft access database. The inputs and results are all stored on a series of tables. To offer compatibility to the legacy users, I want to have the ability for users to connect to their older, local access databases and upload them into the web app.
The approach I was contemplating was to have a page that allowed the user to select the database they wanted from their local machine and then have the schema and the data for each table sent to the web application. I don't really want to upload the whole file -- I just want to extract the relevant data.
I have done some research and I have looked into the HTML File API. One shortcoming is that the API does not expose the file path of a selected file so there does not seem to be a way to pass that to the connection string necessary to connect to the database using ODBC or ADO.
In summary my basic question is: How can I get the contents of a user's local database into a web application only using the browser?
You will have to upload the whole file to the server first. You can do your manipulations on the server to save only the relevant part and delete the rest... For security reasons Javascript is not able to read file's content from the local user's machine.
A suggestion - you can upload the file to server, read and print the relevant data as JSON or XML format, then delete the file and use all the data in your ajax response on the client's browser.