I've created a tool in JavaScript that determines the current UTC time and checks if another predetermined date has passed yet.
I'd like to change my browser to another timezone and see if the tests still pass but I'm having trouble finding a way to do this.
Is there a way to do this in Chrome dev tools? If not, do any other suggestions come to mind?
To do this in Chrome Dev tools you can use the Geolocation sensor emulation.
Go to the 3 dotted menu, More Tools and Sensors.
There's a Geolocation dropdown with some common locations but you can change your preferred one as well. To do that you can choose Other... in that dropdown and enter a custom Timezone ID
Here's a demo page to test it: https://mathiasbynens.be/demo/timezone
and a video that shows the procedure: https://www.youtube.com/watch?v=pIpN_AuV4AI
2020 update: see the other answer, which shows the result of a feature request I filed with Chromium to implement a way to override the timezone.
Note that the technique only works to change the location (including timezone) in that tab. Other tabs will still use the system's timezone. DevTools isn't a reliable way to spoof your timezone.
To change the timezone for all tabs in the browser (Chrome or Firefox or whatever), on Linux/MacOS, you can launch the browser with the TZ environment variable set to the desired timezone name:
TZ=America/New_York chromium-browser
You can also do this with the Vytal extension which uses the devtool location sensor emulation. It can spoof your timezone, locale, geolocation and user agent. You can also automatically set your location data to match your ip address.
https://chrome.google.com/webstore/detail/vytal-spoof-timezone-loca/ncbknoohfjmcfneopnfkapmkblaenokb?utm_source=4
Related
I need to capture the following user activity in the browser (it can be Chrome or Firefox):
What page he/she is seeing: the url and the time stamps of start and end of the focus on that page
And I need to capture it from an Electron application, or at least send the captured data (using another app / extension) to this application.
I think that I might be able to use the Chrome Reporting Extension to obtain this data in JSON, but I'm not sure if it will work, so I wanted gather more ideas for that, while I search for other possible solutions. It could be something to Firefox too.
Thanks!
Lets say, one visited a Website, which loaded a js-module.
This module loaded some information into a form and the chrome browser displayed it.
Is it anyhow possible to restore this information (i.e. via the browser cache) and view it?
What I've tried so far:
View Source of Web-Page in Chrome, but i did not record the communication, so no data here
installed "ChromeCacheView v2.21 - Cache viewer for Google Chrome Web browser" and viewed the Files with Dates which correspond to the concerning session time
Regarding the second point: I can only view the js-files unfortunately.
Yes, but it depends on what device you are on. If you are on the computer, go into your google history and find the website you need. Then, you can copy the link and save it somewhere else.
Also, if you don't know how to get into your history, click control h.
Please I developed my mobile app and is primarily using localStorage for storing account info and some other info. The app has mobile and browser version.
For the browser version, I expect a user that is logged in to not be redirected to an auth page on browser restart. This works fine as my info are stored in localStorage. On the other hand, my mobile doesn't. User have to log in whenever he restart the app.
Please what option do I have? What option do developers use for the mobile storage? Do I have to use database? If so which one should use and where can I find a better documentation on this topic?
Note: I am using Cordova for my mobile app development framework.
For some reason, localStorage is tied to browser history. Some mobile browsers have an option to erase browser history on exit. If that box has a checkmark in it, then localStorage gets purged along with browser history everytime the browser is closed! So, you can ask the user to go into Settings and uncheck that box. Note: localStorage is not supported by older IE browsers, Opera Mini, and some Blackberry devices.
If cookies are enabled, you could use a one-time cookie code to log the user in automatically, but that cookie must expire after first use. Once the user is logged in, the server must issue a new cookie code to the client. And the client can use that new cookie to log in once again or keep alive the session. Using the same cookie twice should not work for security reasons. And the server must make sure never to issue the same code to two different users!
I remember, about 10 yrs ago, I went online to check my emails, and immediately the site had me logged into another user's account! I could have read that person's private emails and stuff, but I decided not to. I reported the incident to the admin. The problem was probably their server issued a random quick-login access code to me, and another user somehow got the same access code that I got. And when I opened the website, it thought that I was that other person. If your site deals with money and credit cards, you should avoid this technique! Any kind of auto login is a bad idea for a bank!
There is a plug-in to store data in an SQLite database using Cordova in this link
. You can find more details about storage with Cordova in the doc.
Save your data by using the following:
localStorage.setItem("variable", value);
Retrieve it from localstorage by using the following:
localStorage.getItem("variable");
It is as simple as it is.
Reference here.
This is the screenshot of network conditions tab in google chrome. It allows you to set browser specs.
I am wondering, how is this done? It surely doesn't change navigator object directly, since it is read-only.
It uses the setUserAgentOverride method of the debugging protocol. Chrome then handles that value internally.
I have several accounts for a website and currently I want to write an extension that I can open all the accounts simultaneously in chrome, each tab for one account.
So that means I want each tab with a separate cookie system, is it doable? If so please suggest the API I should use, thanks!
Go to Chrome Preferences. There is a Users section where you can add users. Each new user will have its own cookie jar, so you can log in to a site as many different users at once. It makes new chrome windows, but it seems you cannot drag a tab onto a window of another user.
According to Chrome documentation, you can modify HTTP headers (including cookies) in the onBeforeSendHeaders event handler. So, you need to store new cookies for every account by means of the onHeadersReceived event handler, and then substitute them for every tab in outgoing requests.
There even exists an extension which seems doing almost the thing you want - Chrome Cookie Switcher.
Also I have found an answer that may be helpful for your task: Associate a custom user agent to a specific Google Chrome page/tab.
I really don't think Chrome allows extensions to do this. If I recall correctly, extensions can inspect and block requests, but they can't modify them, such as changing cookies on the fly for each tab.
I suggest you use the --user-data-dir command-line option of Chrome. It allows you to keep several separate profiles, each in its own directory, and then you only need to start chrome with the proper option:
# run this command to use the first profile
google-chrome --user-data-dir=/home/binchen/my_chrome_profiles/my_profile_1
# run this command to use the second profile
google-chrome --user-data-dir=/home/binchen/my_chrome_profiles/my_profile_2
...
Each profile will be in its own Chrome window, with its own cookie store, instead of its own tab, but it's easier than writing an extension.
Lastly, if the website you're mentioning is Google, you can keep several Google accounts open at the same time.