Chrome extension placeholder value for manifest field - google-chrome

I was wondering if it was possible to set a 'placeholder' value for a field in the manifest.json file of a Chrome extension. For example, I just started a new extension and my manifest looks like this :
{
"manifest_version": 2,
"author" : "My Name",
"name": "Extension Name",
"version": "0.0.1",
"description": "Desc",
"icons": { "16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png" },
"browser_action" : {
"default_title" : "Extension",
"default_icon" : {
"16": "icon32.png",
"48": "icon48.png",
"128": "icon128.png"
},
"default_popup" : "dropdown.html",
"js" : ["dropdown.js"]
},
"content_scripts" : [ {
"matches" : ["http://*/*, https://*/*"],
"js" : ["some_script.js"]
} ]
}
However, I have not yet made the icno*.png files so, obviously, whenever trying to load the extension, chrome says that it can't find the icon files.
Can I do something like :
//[...]
"default_icon" : {
//Will be added later
},
//[...]
or do I have to just delete the "browser_icon" and "icons" fields and add them later?
I found nothing in the Official Google Documentation.

In general, placeholder values are not permitted in the manifest.json. Many of the fields are checked for validity and/or that the resource is available when the manifest.json is loaded. This is necessary because these values are immediately used. Thus, they must be valid. The checking includes verifying the icon files for the browser_action and page_action keys. These files must exist for the extension to be loaded. Overall, what is required to be resolved, in order for the manifest.json to load, is explicitly stated in the error displayed when you attempt to load the unpacked extension from chrome://extensions/. You will need to resolve all errors in order for the extension to be loaded.
For icon files, you can usually delete the reference, or provide a placeholder icon file that contains an actual graphic. Personally, I just copy one of an assortment of icons I generally use, which are in the public domain, into a generically named icon file (e.g. icon.png, or myIcon.png, etc.). If you want, you could do a search for public domain icons which you could use for this purpose. There are a lot of choices.

Related

Static Tab with placeholder values not displayed

I am currently getting into Microsoft Team Apps and am trying to create a very simple tool.
All it should be is a static tab, that when visited embeds a certain website, that's given the groupId as a parameter. This is the format, that I have in mind for the contentUrl: https://foo.bar?groupId=\{groupId\}
The app consists only of two images, that are PNGs in 20x20px (transparent) and 96x96px (with background color) and the manifest (version 1.2).
The manifest contains all required fields:
$schema, manifestVersion, version, id, packageName, developer {name, websiteUrl, privacyUrl, termsOfUseUrl}, icons {color, outline}, description {short, full}, accentColor, permissions, validDomains, staticTabs [{entityId, name, contentUrl, scopes}]
An Id for the app has been generated at apps.dev.microsoft.com.
The upload of the custom app as zip file causes no error and I can see the app in the list of the installed applications. If I switch to a channel I can't see the tab which should be there without being explicitly added because it's a static tab. Adding it manually isn't possible because it's not shown in the list of "addable apps".
I tried some of the example apps from GitHub, but they seem outdated and at least partly can't be even read (Error while reading manifest.json).
Is this sufficient information to help me?
Edit: (anonymized manifest.json)
{
"$schema":
"https://statics.teams.microsoft.com/sdk/v1.2/manifest/MicrosoftTeams.schema.json",
"manifestVersion": "1.2",
"version": "1.0.0",
"id": "12345678-abcd-efgh-1234-123456789012",
"packageName": "com.microsoft.teams.bar",
"developer": {
"name": "Foo Corp",
"websiteUrl": "https://foo.com",
"privacyUrl": "https://foo.com/privacy",
"termsOfUseUrl": "https://foo.com/termsofuse"
},
"icons": {
"color": "src/images/waldo-96x96.png",
"outline": "src/images/waldo-20x20.png"
},
"name": {
"short": "bar",
"full": "bar"
},
"description": {
"short": "Opens baz and does qux.",
"full": "Opens baz and does qux."
},
"accentColor": "#FFFFFF",
"permissions": ["identity", "messageTeamMembers"],
"validDomains": ["*.baz.com", "*.foo.com"],
"staticTabs": [
{
"entityId": "tabId",
"name": "example tab",
"contentUrl":
"https://foo.com/?teamId={teamId}&teamName={teamName}&channelId={channelId}&channelName={channelName}&locale={locale}&theme={theme}&entityId={entityId}&subEntityId={subEntityId}&upn={upn}&tid={tid}&groupId={groupId}&theme={theme}&isFullScreen={isFullScreen}",
"scopes": ["personal"]
}
]
}
I could see two issues in your manifest code:
Invalid GUID: 12345678-abcd-efgh-1234-123456789012 is not valid GUID.
Icons must be included in the package and referenced via relative paths in the manifest.
ex. waldo-96x96.png - Please place them inside zip file.
Please feel free to use Teams App Studio to create the manifest file. You can also use the existing form the sample code.

I'm having an issue with my google chrome extension, new to code so be basic please

I'm trying to make a google chrome extension, but I'm having a problem. Please answer as basic as possible as I'm really bad at code. Whenever I upload something as a zip file, it says
"An error occurred: Failed to process your item. manifest.json:5:26:
unexpected char."
This is my code :
{
"name": "ROBLOX Character Asset ID",
"version": "1.9.0", // version
"manifest_version": 2,
"description": "This extension is for GFX artists who need their customer's character asset ID",
"browser_action": {
"default_icon": "icon.png"
},
"permissions": [
"alarms",
"background",
"debugger",
"notifications",
"cookies",
"https://www.roblox.com/"
],
"background": {
"scripts": ["bgWork.js", "jQuery-ver3.js"]
},
"icons": { "16": "icon.png",
"48": "icon.png",
"128": "icon.png" }
}
This has to do with the content in your scripts and when you load the extension it not being able to be processed as I loaded your manifest.json just fine (though with blank js files). So don't look towards your manifest.json, you must have an illegal character in your js file.

Accessing a local directory from a Chrome App

I am working on a Chrome extension called Chrome Snippets that will allow you to inject snippets of JavaScript from files but I am having trouble accessing local directories on the user's computer. Anyone have an idea of how to accomplish this?
manifest.json:
{
"name": "Chrome Snippets",
"description": "Run JavaScript on the DOM of any web page from a library of recipes stored on your computer.",
"author": "Adam Fisher",
"version": "1.0",
"manifest_version": 2,
"default_locale": "en",
"permissions": [ "tabs", "webNavigation", "*://*/*", {"fileSystem": ["write", "retainEntries", "directory"]} ],
"app": {
"background": {
"scripts": ["js/background.js"],
"persistent": false
}
},
"icons": {
"16": "img/icon16.png",
"48": "img/icon48.png",
"128": "img/icon128.png"
},
"options_page": "html/options.html",
"homepage_url": "http://adamfisher.me"
}
background.js:
/*
** file: js/background.js
** description: Main functionality of the extension. Checks if a file exists
** for the given host name and loads it.
*/
chrome.webNavigation.onCompleted.addListener(function (details) {
var recipesDirectory = localStorage['Chrome_Snippets_Recipes_Directory'];
var host = "/^(?:ht|f)tps?:\/\/([^/]+)/".exec(details.url); // Get the host part of the URL.
chrome.tabs.executeScript(details.tabId, {
file: ''
});
});
You CAN'T make what you want in a single app/extension, that's what Paweł tries to tell you.
Compare Apps APIs and Extensions APIs
Apps can't use tabs (and in general can't interact with normal browser content), extensions can't use fileSystem (and in general can't access system resources).
You need to rethink your strategy OR use both an extension and an app that talk to each other.
Replace "app" in the manifest.json file with "background":
"background": {
"scripts": ["js/background.js"],
"persistent": false
},
Reference: https://developer.chrome.com/extensions/event_pages
The "app" entry is reserved for Chrome Apps which have different set of API's and permissions.
================================================
Edit
Forgot about what you really asking for.
Chrome extensions can't access user's filesystem. This API is only available for Chrome Apps.
So if you need to do it as an extension you can't save files on local file system.

Getting error: "This webpage is not available" for my chrome app's options page

My CRX had the proper html page options.html in it, the manifest declares it properly (it shows up as a link on the chrome://extensions page) but when I click that link, Chrome gives the error:
This webpage is not available
The webpage at chrome-extension://invalid/ might be temporarily down or it may have moved permanently to a new web address.
It says "invalid" but the app runs perfectly well (all the content scripts run, the background created a database and saved to it). Why would it show as invalid? Why doesn't it have the extensions' id?
Here's the manifest:
{
"manifest_version": 2,
"name": "MyAPP",
"description": "My App",
"version": "0.0.0.32",
"minimum_chrome_version": "27",
"offline_enabled": true,
"options_page": "options.html",
"icons":
{
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"app":
{
"background":
{
"scripts":
[
"scripts/background.js"
]
}
},
"permissions":
[
"unlimitedStorage",
"fullscreen",
{
"fileSystem":
[
"write"
]
},
"background",
"<all_urls>",
"tabs"
]
}
Does it need to be declared in "web_accessible_resources"? Any idea what's wrong?
Update
Adding to "web_accessible_resources" does not fix the issue. I added everything on that page too.
update 2
It looks like it might be a Chrome bug for packaged apps. When I remove the "app" section in the manifest, it works! This is a bug since the Chrome app documentation states that apps can have options pages: https://developer.chrome.com/apps/options.html
Options pages are only supported for extensions, you have indeed discovered a documentation bug (I've filed issue 255079).

Auto Refresh on load page failure

I'm trying to create an extension for chrome that auto refreshes the page when the page load is failed for any reason.
my manifest.json:
{ "browser_action" : { "default_icon" : "icon.png"
},
"description" : "Making your first Google Chrome extension.",
"icons" : { "128" : "icon.png" },
"name" : "Tutorialzine Extension",
"version" : "1.0",
"permissions": [
"webRequest",
"tabs",
"<all_urls>"
],
"content_scripts": [
{
"matches": ["<all_urls>","http://*/*","https://*/*","*://*/*"],
"js": ["myscript.js"],
"run_at": "document_end"
}
]
}
myscript.js :
chrome.webRequest.onErrorOccurred.addListener(function details){
chrome.tabs.reload(details.tabId);
}
What am I doing wrong? Thanks in advance!
Content scripts don't have access to most of chrome.* APIs. It's clearly stated in the docs:
However, content scripts have some limitations. They cannot:
- Use chrome.* APIs (except for parts of chrome.extension)
You should use a background page or event page instead.
Also chrome.webRequest.onErrorOccurred.addListener(function details) is not a valid JavaScript code. function keyword shouldn't be there. I believe you copied this code from docs, but in docs this type of pseudo-JavaScript is used only to describe function definition (what types of arguments it expects, what type of values does it return etc.).