I started trying to write chrome extension and I'm having problem with simple function:
script inside "backgroound.html":
chrome.tabs.onUpdated.addListener(function(tabId,changedInfo,tab){alert("a")});
manifest.json file:
{
"name": "ogys",
"version": "1.0",
"description": "description",
"browser_action": {
"default_icon": "icon.png",
"background_page": "background.html"
},
"permissions": ["tabs", "http://code.google.com/"]
}
I understand that an change on any tab would trigger the event but nothing happends.
According with code.google.com, you've defined the backround_page in the wrong place.
Move the background_page property definition outer from browser_action action in this way:
{
"name": "ogys",
"version": "1.0",
"description": "description",
"browser_action": {
"default_icon": "icon.png"
},
"background_page": "background.html",
"permissions": ["tabs", "http://code.google.com"]
}
Related
I click the button in https://chrome://extensions and it loads my extension. However the image/logo of the extension is the default one instead of the one I provided:
manifest.js:
{
"name": "My App",
"version": "1.0.0",
"description": "My extension doesn't do anything yet!",
"manifest_version": 2,
"background": {
"persistent": false,
"scripts": ["js/clear_history.js"]
},
"icons": {
"48": "images/logo.svg",
"96": "images/logo.svg"
},
"browser_action": {
"default_icon": "images/logo.svg"
},
"options_ui": {
"page": "options.html",
"chrome_style": true
},
"permissions": ["history", "storage"],
"web_accessible_resources": ["logo.svg"]
}
Project directory:
How do I fix it?
EDIT:
Full access and request access image
This picture shows that every time I open a new tab the extension requests access, I want to give it access to all tabs opened, like the top extension has.
Is this because I installed this extension from unpacked directory?
IF so, how can I bypass this? this is a custom extension that will not be going on the google extentionstore.
Add: "host_permissions": ["http:///","https:///"]
To your manifest.json file, under the section of permissions. Here's a full example:
{
"name": "Getting Started Example",
"options_page": "options.html",
"description": "Build an Extension!",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
},
"permissions": ["storage", "activeTab", "scripting","tabs","storage","fontSettings","contentSettings","debugger"],
"host_permissions": ["http://*/*","https://*/*"],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "/images/get_started16.png",
"32": "/images/get_started32.png",
"48": "/images/get_started48.png",
"128": "/images/get_started128.png"
}
},
"icons": {
"16": "/images/get_started16.png",
"32": "/images/get_started32.png",
"48": "/images/get_started48.png",
"128": "/images/get_started128.png"
}
}
Whats wrong chrome doesn't allow to upload a zip file
An error occurred: Failed to process your item.
manifest.json:17:2: unexpected char.
{
"manifest_version": 2,
"name": "TechnoSwift Launcher",
"description": "Quick launch TechnoSwift",
"version": "1.0.1",
"author":"Shareque",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html",
"default_title": "TechnoSwift Launcher"
},
"permissions": [
"activeTab"
],
}
I have created a small extension that applies a simple css file to a website.
Currently though, it applies to ALL websites, and only applies when I click the icon for my extension.
I need it to always apply to one particular site
I think it's something up with my manifest.json:
{
"manifest_version": 2,
"name": "UI",
"description": "UI alter",
"version": "1.0",
"permissions": [
"tabs",
"activeTab",
"http://thewebsite.com"
],
"background": {
"scripts": ["override.js"],
"persistent": true
},
"browser_action": {
"default_icon": "icon.png",
"default_title": "change ui"
}
}
You need to use a content script instead, and use a matches parameter in your manifest:
"content_scripts": [
{
"matches": ["http://www.google.com/*"],
"css": ["mystyles.css"],
"js": ["jquery.js", "myscript.js"]
}
],
See Doc
this works fine in browserAction..
but when i switch it pageAction.. even the icon doesnot show up
background.html
<html>
<head>
<script>
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({'url':'http://google.com/search?q=site:'+window.location.host});
});
</script>
</head>
</html>
manifest.json
{
"name": "linkcheck",
"description": "check link.",
"version": "1.1.1",
"
background_page": "background.html",
"permissions": ["tabs", "http://*/*","https://*/*"],
"browser_action": {
"name": "linkcheck",
"default_icon": "icon.png"
},
"icons": {
"128": "icon128.png",
"48": "icon48.png"
},
"content_scripts": [
{
"matches": ["https://www.google.com/*"],
"js": ["myscript.js"],
"run_at": "document_end"
}
]
}
Well for pageAction, you would need to enter another manifest property:
{
"name": "My extension",
...
"page_action": {
"default_icon": "icons/foo.png", // required
"default_title": "Do action", // optional; shown in tooltip
"default_popup": "popup.html" // optional
},
...
}
Then you need to either hide or show.
chrome.pageAction.show(integer tabId)