Detect operating system from Google Chrome Extension - javascript

I am developing a Chrome extension, and I need to detect which operating system Chrome is running on but i can't seem to find any info on how to do it. Please Help.
Thank You.

Recently added, you can use the getPlatformInfo method in Chrome's own API:
chrome.runtime.getPlatformInfo(function(info) {
// Display host OS in the console
console.log(info.os);
});

You would need to search for OS name and version inside window.navigator.appVersion.
If you just want to know a platform, see this answer. You can enhance the code by searching for other user agents.
Here is a detailed list of Chrome user agent strings (click on links to see what they mean).

Related

Launch Windows 10 Settings using JavaScript?

Using chrome, I tried going to Microsoft Store and when I click the button GET to install an app, a dialog shows up and asks to open Microsoft Store, of course after clicking it I'm redirected to Microsoft Store App.
I wanted to do the same by launching Windows Settings and if possible I wanted to redirect the client specifically to Settings > Update & Security > Check for Updates.
I have a thought that it can be done using JavaScript but I'm not sure. I found the same question but I think it is specifically to Firefox and it confused me.
It appears that it is possible, but I'm not sure though if this is part of JavasScript, the list of commands can be found in Microsoft docs, there are multiple options and not just for Windows Settings.
What I am looking for is ms-settings:windowsupdate.
Example of usage
Check for updates

gmail add-on detect if mobile device being used

I have an add-on working in my computers browser and mobile device for gmail.
I need to know when the add-on is being rendered in the mobile device.
The reason being I already have an extension that does all I need in the browser and the add-on really is only needed for the mobile device (as I can't run the extension in the gmail app).
Any suggestions appreciated
This can be checked using clientPlatform property in action event object. Check this for details.

Reenabling document.execCommand("cut") in Google Chrome

Is there a way to re-enable the document.execCommand("cut") Javascript method call in Google Chrome? Palm's WebOS Enyo framework uses this is a few places, which means when I'm working on applications locally I can't access every API of the framework.
Insight from all platforms welcome, but I'm working on OS X so those answers are preferred.
You are going to have to use the emulator for some functionality.
I dont know if other WebKit browsers like Safari have this ability enabled however.
Chrome does not support execCommand or clipboard interaction, which is considered a security threat.
For example, Google docs on chrome shows a "Please use CTRL+X or use your browser's edit menu" dialog when a user tries to execute cut from google docs' UI.
An experimental clipboard API is available for chrome extensions: http://code.google.com/chrome/extensions/experimental.clipboard.html#method-executeCut

Debugging Web-Applications on Android [duplicate]

I'm developing a JavaScript application that needs to run on the Google Android Phone OS. Is there a way to enable the JavaScript Error/Debug console within Safari on either the Android Emulator or an actual device? If so any instructions on how to do so would be appreciated.
It looks like, with the Android 2.0.1 SDK you'll need to filter on "browser" instead of "WebCore"
A quick Google turns up this blog post (posted after you asked your question), that should at least let you see any Javascript errors via the Android Debug Bridge using the command:
adb logcat WebCore:V *:S
Not quite the same as a full debug console though.
On Android write about:debug on the address line when the current page is the page you want to debug. you will get access to the console.
I know your question is about Safari, but you might want to look into using Chrome instead. You can now use Chrome's desktop developer tools to debug and profile apps on your Android device.
Here's how:
On Android Chrome, go to settings -> Developer tools and check "Enable USB Web debugging"
On the desktop, run adb forward tcp:9222 localabstract:chrome_devtools_remote
Now on Desktop Chrome, navigate to localhost:9222.
You should see a list of the pages you have open on your phone. Click the one you want to debug/profile.
Detailed instructions are here
I have discovered that you can get this debugging information on the phone itself, without needingn to use adb or plug it into a computer, just download a log viewer.
Check the link for more info.
You can view the log and much more with weinre
From the Weinre docs
weinre is a debugger for web pages, like FireBug (for FireFox) and Web Inspector (for WebKit-based browsers), except it's designed to work remotely, and in particular, to allow you debug web pages on a mobile device such as a phone.

how to delete cookies in firefox 3.5+ using an extension?

i've got a problem:
i need my extension for firefox 3.5+ to delete cookies. all cookies of my firefox.
example: i've serfed net, got some cookies installed on my pc by the sites i've visited. and i want my extension for ff to delete all these cookies.
could u please show me the direction where i can find an answer for my question? (or and it'll be the best, give a link to a code sample)
and one more: can i do this in javascript or i must use c/c++ and napi?
p.s.\i do not need an extension like close'forget, i want my own extension been able to do this work.
thanx for u'r future answers and sorry for my bad english...got no speach practice for a long time=(
From https://developer.mozilla.org/en/Code_snippets/Cookies , you just need to do the following in privileged javascript (i.e., inside a Firefox extension):
Components.classes["#mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager).removeAll();
If you want to do this without writing an extension, just go to options (Tools->Options on Windows, Edit->Preferences on Linux, Firefox->Preferences on Mac) and see the "Privacy" tab.

Categories