How to grant permissions of geolocation from devtools protocol monitor - devtools

I try to set permission but nothing happends. I insert this code to devtools protocol monitor
{
"command":"Browser.grantPermissions",
"parameters":
{
"permissions": ["geolocation"]
}
}

I experienced the same issue using Selenium + Python. Here is my setting:
chrome_driver.execute_cdp_cmd(
cmd="Browser.grantPermissions",
cmd_args={
"permissions": ["geolocation"]
}
)
chrome_driver.execute_cdp_cmd(
cmd="Emulation.setGeolocationOverride",
cmd_args={
"latitude": 37.7749,
"longitude": 122.4194,
"accuracy": 1000
}
)
I've used https://browserleaks.com/geo to test if geolocation identified or not.
After several tries and guesses I've found out that I never granted global MacOS permission to Chrome:
Go to MacOS -> System Preferences... -> Security & Privacy -> Location Services and enable location services for Chrome.
After this, the geolocation worked fine.

Related

VS Code Extension Settings

I have created a working VS Code extension. The extension allows someone teaching code to provide students with real-time access to the teacher's code.
I want to add one more feature to the extension to allow the teacher to connect the VS Code extension to an account form a separate web application. The teacher would login to their account on the web application, generate a token, and place that token in the VS Code extension settings.
I have spent hours looking for documentation or examples on how to add settings to a VS Code extension but can't find anything.
Is this possible? Does anyone know how to do this? Or aware of any good documentation/examples?
Yes a little tricky as what you are looking for are configurations - which can be created by an extension and set by a user.
Configuration docs (settings)
Contribute configuration keys that will be exposed to the user. The
user will be able to set these configuration options as User Settings
or as Workspace Settings, either by using the Settings editor or by
editing the JSON settings file directly.
There are examples and extensive docs at that link above.
Here is sample code from an extension I wrote which creates 2 settings:
"configuration": [
{
"title": "Find and Transform",
"properties": {
"find-and-transform.enableContextMenus": {
"type": "boolean",
"scope": "machine",
"default": true,
"markdownDescription": "Show `Search in this File`, `Search in this Folder` and `Search in the Results Files` in the context menus."
},
"find-and-transform.enableWarningDialog": {
"type": "boolean",
"scope": "machine",
"default": true,
"markdownDescription": "Enable a warning dialog if there are bad argument keys or values in settings and keybindings."
}
}
}
]
Maybe you looking for that extension :
https://code.visualstudio.com/learn/collaboration/live-share,
it acts like google docs, with live share.

How do I create Google Extension Apps, just like those in the chrome://apps/?

I have created some Chrome extensions for fun but later I found some app in the chrome://apps/ tab.
I tried to open their manifest.json and find this segment:
"app": {
"launch": {
"web_url": "https://www.***.com/"
},
"urls": [ "https://www.***.com/" ]
},
But I couldn't find any related documentation online.
Is there any reference for this?
Thanks
Yes, it's here. https://developer.chrome.com/apps/about_apps
But you should carefully consider to use this because:
Important: Chrome will be removing support for Chrome Apps on Windows, Mac, and Linux.

Chrome extensions (and/or tampermonkey scripts) not running on certain websites (like gmail)

I have a very simple chrome extension that refuses to run on some sites like https://mail.google.com. It runs fine on other sites which makes me think something is limiting extensions/scripts from running on some sites. The sample case is quite simple and listed below.
With this sample case I see "Hello world" in the developer console when I navigate to https://about.me. I also see the extension in the Developer Console's Execution Context Selector. However, when I navigate to https://mail.google.com I don't see the log entry or the extension in the Execution Context Selector.
I have tried something similar with tampermonkey and am not seeing that script run on gmail either. Thanks!
manifest.json:
{
"manifest_version": 2,
"name": "Gmail extension test",
"version": "0.1.9",
"description": "Try running inside gmail page",
"content_scripts": [{
"all_frames": true,
"js": ["content.js"],
"matches": [
"https://mail.google.com/*",
"https://about.me/*",
"http://*/*",
"https://*/*"
]
}]
}
content.js:
console.warn("Hello world");
Environment:
Chrome 66.0.3359.117
macOS 10.13.3 (17D102)
As #wOxxOm suggested. I tracked down the problem to the fact that my company has a Chrome policy set against running extensions on the google.com domain. I had no warning entries in the Developer Console or the macOS Console, I just tracked down other folks complaining about in an internal forum.
The policy that applies in this case is ExtensionSettings which is set in a OS/device specific way. To help diagnose this restriction, you can view your active polices in Chrome under chrome://policy/. In my case I had something like the following in my chrome://policy:
{
"*": {
...
"runtime_blocked_hosts": [ "*://*.google.com", ....]
},
I'm not aware of a generic workaround for this at the extension level. Instead I had to work with my company IT department to whitelist the extension.

Chrome extension bug that could be related to cross-origin permissions

We run an extension that requires fetching and searching for data on multiple websites.
We have been using cross-origin XMLHttpRequests using Jquery, and have not faced an issue until now.
The asynchronous requests are being executed successfully. This has been the case even though we have not explicitly requested cross-origin permissions as suggested here: https://developer.chrome.com/extensions/xhr
This is what the relevant portions of our manifest currently look like:
{
"background" : {
"scripts": ["background.js"]
},
"permissions" : ["storage" ],
"content_scripts" : [
{
"matches" : ["<all_urls>"],
"js" : [ "jquery-2.0.0.min.js","jquery-ui-1.10.3.custom.min.js","date.js",
"file1.js","file2.js",
"fileN.js"],
"run_at" : "document_idle",
"all_frames" : false
},
],
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",
"web_accessible_resources" : [ "icona.png" , "iconb.png","iconc.png"],
"manifest_version": 2
}
Even though the permissions do not explicitly request access to urls from which data is asynchronously fetched, the extension has worked fine.
Off late, we have had a few complaints from users that the extension no longer works and no data is being displayed. We have not been able to replicate this issue in Chrome on Linux (Version 34.0.1847.132). The users who seem to be facing this issue seem to be using Mac OS X or, less frequently, Windows.
We cannot figure out why this issue is OS specific, or if that's a curious correlation.
If the problem is indeed one of wrong permissions, can we set the permission to
["http://*/","https://*/"]
without having the extension disabled automatically for manual re-enabling by the user?
We already require permissions for all urls through "matches" : ["<all_urls>"] Does this ensure that the addition of permissions as above will not trigger automatic disabling of the extension?
Chrome extensions allow for cross-origin requests, but you have to declare the hosts you want to access in the permissions section of your manifest. The matches section of content scripts shouldn't give you host permissions.
You should add host permissions to your manifest. I don't know what will happen on update. Considering that the user was already prompted to allow your extension access to all their web data, maybe your extension won't be disabled on update. You can simply test that by creating a testers only extension on the webstore with your original version, install it, update it, and see what happens.

Chrome extension doesn't work in Linux (works in windows)

Okay, this is weird.
This is my extension, and it works flawlessly in Windows (atleast on two win7 machines), but when I tested it on linux (CentOS6 and Fedora18) it failed to do anything when its icon was clicked (it should, at the very least, display an alert).
The options page still works, and saves data properly.
After enabling developer mode in chrome://extensions/ you can click _generated_background_page.html for the extension to see the JS console for the addon.
That's where I saw the following error:
Error during tabs.executeScript: Cannot access contents of url "https://www.google.com.au/". Extension manifest must request permission to access this host.
actual url in error is not relevant, does it to all sites
Thing is, the windows machines showed no such error, shouldn't this be platform independent?
The manifests are obviously the same, so how come the addon hasn't the required permissions only on linux machines?
Mac is untested, if someone could try that for me, it might be useful
FURTHER INFORMATION
The error message above was given with the following information;
Located in the function chromeHidden.handleResponse on line 22 of the script sendRequest
The "activeTab" permission was added in Chrome 26. Make sure that you've installed Chrome/Chromium 26+.
If you want to make your extension compatible with older browsers in the Chrome Web Store, add host permissions to the manifest file, plus the minimum_chrome_version key:
First upload an extension with the following manifest file:
{
"name": "Name of extension",
"version": "1.0",
"manifest_version": 2,
"permissions": [
"<all_urls>"
]
}
Then bump the version, change "<all_urls>" to "activeTab", add the "minimum_chrome_version" field and upload it again to the Chrome Web Store:
{
"name": "Name of extension",
"version": "1.0.1",
"manifest_version": 2,
"permissions": [
"activeTab"
],
"minimum_chrome_version": "26.0.0.0"
}

Resources