`chrome.tabs.group` is undefined - google-chrome

I want to fiddle with chrome tabs, in particular, I want to group them using chrome.tabs.group
https://developer.chrome.com/docs/extensions/reference/tabs/#method-group
However, this function is undefined
Here is my manifest.json
{
"name": "Test",
"version": "1.0",
"description": "Test",
"manifest_version": 2,
"permissions": ["tabs"],
"page_action": {
"default_popup": "popup.html"
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"commands": {
"toggle-pin": {
"suggested_key": { "default": "Ctrl+Shift+P" },
"description": "Test Action"
}
}
}
This is my background.js script
chrome.commands.onCommand.addListener(function (command) {
if (command == "toggle-pin") {
chrome.tabs.query({ currentWindow: true }, function (tabs) {
// Here i want to use the chrome.tabs.group method, but
// it is not defined
})
}
})
What do I miss?

As #wOxxOm pointed out, this feature is only available in Chrome 88 (which is in beta right now 12 Dec 2020)

Related

Invalid value for 'background.service_worker'. Could not load manifest

I am trying to migrate/update a manifest 2 file to manifest 3. But I am getting the following error Invalid value for 'background.service_worker'. Could not load manifest.
From the original maifest 2 file I removed "persistent": true and changed "background": {"scripts": ["background.js", "worker.js"], to be "background": {"service_worker":["background.js", "worker.js"],
My full code for v3 can be seen below:
{
"manifest_version": 3,
"name": "Chrome ext",
"description": "This is an extension ",
"version": "1.1.1",
"icons": {
"128":"icon.png"
},
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html",
"default_title": "Open ext"
},
"options_page": "options.html",
"background": {
"service_worker": ["background.js", "worker.js"]
},
"permissions": [
"tabCapture",
"downloads",
"storage"
],
"commands": {
"start": {
"suggested_key": {
"default": "Ctrl+Shift+S",
"mac": "Command+Shift+U"
},
"description": "Start"
},
"stop": {
"suggested_key": {
"default": "Ctrl+Shift+X",
"mac": "MacCtrl+Shift+X"
},
"description": "Stop"
}
}
}

Trying to disable extension from web page

Here I have taken permission for all the needed thing, if something missing here please let me know.
Manifest.json
{
"manifest_version": 2,
"name": "SearchMood",
"description": "This extension shows Google Web Search and Google Image
Search result.",
"version": "1.4",
"author":"Searchmood",
"browser_action": {
"default_icon": {
"128": "icon-128.png",
"16": "icon-16.png",
"48": "icon-48.png"
},
"default_title": "SearchMood",
"default_popup": "background.html"
},
"chrome_url_overrides" : {
"newtab": "popup.html"
},
"icons": {
"128": "icon-128.png",
"16": "icon-16.png",
"48": "icon-48.png"
},
"background": {
"scripts": [ "background.js","popup.js" ]
},
"permissions": [
"activeTab","management","https://ajax.googleapis.com/"
],
"content_scripts": [
{
"matches": [ "http://search.searchmood.com/*" ],
"js": [ "js/restoremodal.js" ],
"all_frames": true,
"run_at": "document_start"
}
],
"externally_connectable": {
"matches": ["http://*.searchmood.com/*"]
}
}
Script on my web page I have:
<div class="links">
<ul>
<li>Terms&Conditions</li> |
<li>Privacy policy</li>|
<li>Contact US</li>
<li><span id="restoreLink" onclick="adi();">Reset Chrome</span></li>
</ul>
</div>
<script type="text/javascript">
function adi(){
var editorExtensionId = "pokioadkjpcbalcpfidmlebofahebkhb";
// Make a simple request:
chrome.runtime.sendMessage(editorExtensionId, {request: "uninstall"});
}
</script>
And this is the code in my extension to listen To this message I have put this code in popup.js. Please guide me where to put that also.
chrome.runtime.onMessageExternal.addListener(
function(request, sender, sendResponse) {
if (request == "uninstall") {
var id = chrome.app.getDetails().id;
chrome.management.setEnabled(id, false);
}
});
This the script I have written. I have some other codes also but that is also not working.
Yes I got the answer In the content Script File We can write code for taking the element from Website And their we will use SendMessage function Make sure You have taken permission for "Management" in manifest.json And persistent in Menifest.json should be "false".
Then you can use onmessage function and disable your extension Codes for your reference:
**HTML**`<span id="restorelink"> disable chrome extension</span>`
**menifest.json**
{
"manifest_version": 2,
"name": "name",
"description": "describe about you extension",
"version": "1",
"browser_action": {
"default_icon": {
"128": "icon-128.png",
"16": "icon-16.png",
"48": "icon-48.png"
},
"background": {
"scripts": [ "background.js"],
"persistent": false
},
"permissions": [
"management"
],
"content_scripts": [
{
"matches": [ "http://your site url where you want to apply the change, you can use more than one seperating with "," ],
"js": [ "restoremodal.js" ],
"all_frames": true
}
]
}
**restoremodal.js**
document.getElementById("restoreLink").addEventListener("click", adi);
function adi(){
chrome.runtime.sendMessage({ value: "anything"});
}
**Background.js**
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.value=="anything") {
var id = chrome.app.getDetails().id;
chrome.management.setEnabled(id, false);
}
});

"Cannot access contents of url" Chrome extension error in background.js

I am trying to invoke a current_script from a background script, but I receive the following error:
Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url "chrome-devtools://devtools/bundled/inspector.html?
I understand I need to send also tab.id in executeScript function, I also tried that but with no luck.
UPDATE: I changed background.js to the following but content_script.js is still not working:
chrome.commands.onCommand.addListener(function(command) {
if (command === "toggle-feature") {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
for(var i = 0; i<tabs.length;i++) {
alert(tabs.length);
chrome.tabs.executeScript(tabs[i].id, {"file": "content_script.js"});
alert("h");
}
});
}
});
Here is all my code:
Manifest.nmf
{ "manifest_version": 2,
"name": "Extractor",
"version": "1",
"description": "Extract from 144",
"icons": {
"16": "logo16.png",
"48": "logo48.png",
"128": "logo128.png"
},
"page_action": {
"default_icon": {
"16": "logo16.png",
"48": "logo48.png",
"128": "logo128.png"
},
"default_title": "Extractor"
},
"background": {
"scripts": [ "background.js" ],
"persistent": true
},
"content_scripts": [ {
"matches": [ "https://www.msn.com/*" ],
"js": [ "content_script.js" ]
} ],
"permissions": [
"tabs",
"https://www.msn.com/*",
"activeTab",
"*://*/*"
],
"commands": {
"toggle-feature": {
"suggested_key": {
"default": "Ctrl+Shift+1",
"windows": "Ctrl+Shift+2"
},
"description": "Extract now"
}
}
}
Background.js
chrome.commands.onCommand.addListener(function(command) {
if (command === "toggle-feature") {
chrome.tabs.executeScript(null, {file: "content_script.js"} );
}
});
content_script.js
alert("success");
As you see I have also tried to add all links combinations in permissions but with no luck!
How can I solve this problem and get current_script working when pressing a hot key in a tab?

Ammending Google Managed Preferences via the master_preferences JSON file

I am trying to set up an environment where the first time a user logs into chrome they have a list of pre-determined bookmarks and extensions installed. I have followed Chromiums guide to this as much as possible however seem to be failing when it comes to the granted_permissions section, in an ideal world the user would open Chrome and not be prompted with "This extension requires new permissions". From what i can gather this is through the granted_permissions entry however these do not appear to be parsing through to chrome, ive included a snapshot of the code below:
{
"homepage": "MY_URL",
"homepage_is_newtabpage": false,
"extensions": {
"settings": {
"hdokiejnpimakedhajhdlcegeplioahd": {
"location": 1,
"manifest": {
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCiL9y2jziKp5kjb13uYG1bAXsuemUKAYUAwR/N9qTuhMIuly02Ecm63dOkn+M2r26IGfDE/lbPv/dB/W+d34pqGo5uJJY+Omt9t3xsIuz7mQwuvF1H5ozj0OHok5XDFRaBIfPa06RhQw3M7sSZJvQ+qqD3+dr0aLX+mvi0LQ11uQIDAQAB",
"name": "LastPass",
"update_url": "http://clients2.google.com/service/update2/crx",
"granted_permissions": {
"api": [ "contextMenus", "idle", "notifications", "tabs", "unlimitedStorage", "webRequest", "webRequestBlocking" ],
"explicit_host": [ "http://*/*", "https://*/*" ],
"scriptable_host": [ "file:///*", "http://*/*", "https://*/*", "https://1min-ui-prod.service.lastpass.com/*" ]
},
"version": "0.0"
},
"path": "hdokiejnpimakedhajhdlcegeplioahd\\0.0",
"state": 1
},
"cjpalhdlnbpafiamejdnhcphjbkeiagm": {
"location": 1,
"manifest": {
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmJNzUNVjS6Q1qe0NRqpmfX/oSJdgauSZNdfeb5RV1Hji21vX0TivpP5gq0fadwmvmVCtUpOaNUopgejiUFm/iKHPs0o3x7hyKk/eX0t2QT3OZGdXkPiYpTEC0f0p86SQaLoA2eHaOG4uCGi7sxLJmAXc6IsxGKVklh7cCoLUgWEMnj8ZNG2Y8UKG3gBdrpES5hk7QyFDMraO79NmSlWRNgoJHX6XRoY66oYThFQad8KL8q3pf3Oe8uBLKywohU0ZrDPViWHIszXoE9HEvPTFAbHZ1umINni4W/YVs+fhqHtzRJcaKJtsTaYy+cholu5mAYeTZqtHf6bcwJ8t9i2afwIDAQAB",
"name": "uBlock Origin",
"update_url": "http://clients2.google.com/service/update2/crx",
"version": "0.0"
},
"path": "cjpalhdlnbpafiamejdnhcphjbkeiagm\\0.0",
"state": 1
}
}
},
"session": {
"restore_on_startup": 1,
"startup_urls": [
"MY_URL/"
]
},
"browser": {
"show_home_button": true,
"check_default_browser": false
},
"bookmark_bar": {
"show_on_all_tabs": true
},
"distribution": {
"show_welcome_page": false,
"skip_first_run_ui": true,
"import_history": false,
"import_bookmarks_from_file": "/Library/Google/bookmarks.html",
"import_bookmarks": false,
"import_home_page": false,
"import_search_engine": false
},
"sync_promo": {
"user_skipped": true
}
}
After opening chrome even with those permissions in place it still disables the extensions pending further permissions however im not really sure what else its after.
Wrong structure. If you look at the docs, it should be as follows:
{
"extensions": {
"settings": {
"mihcahmgecmbnbcchbopgniflfhgnkff": {
"location": 1,
"manifest": {
...
},
"granted_permissions": {
"api": [ "tabs" ],
"explicit_host": [ "http://*.google.com/*", "https://*.google.com/" ],
"scriptable_host": [ "http://example.com/" ]
},
...
},
...
}
}
}
However, you have put the "granted_permissions" key inside, and not on the same level as the "manifest" key.

alert/confirm doesn't work in chrome app - missing config?

I made a chrome app to display my web by webview tag, but the js API alert()/confirm() doesn't work. That made me wondering. Chrome app needs to config something to support confirm?
this is my manifest.json:
{
"app": {
"background": {
"scripts": ["background.js"]
}
},
"manifest_version": 2,
"name": "Performance Monitor",
"version": "1.0",
"description": "A performance monitor to show cpu and memory status.",
"icons": {
"16": "img/ccloud.png",
"48": "img/ccloud.png",
"128": "img/ccloud.png"
},
"permissions": [
"webview"
],
"webview": {
"partitions": [
{
"name": "static",
"accessible_resources": ["header.html", "footer.html", "static.png"]
},
{
"name": "trusted*",
"accessible_resources": ["local_*.html", "*.png", "*.js"]
},
{
"name": "trusted-audio",
"accessible_resources": ["*.mp3"]
}
]
}
}