Chrome extension "version error" - google-chrome-extension

So I was testing out chrome extensions and learning how to use them but I get the same error when I upload my code... It says
Failed to load extension from: ~\Desktop\chromeExtension
The 'manifest_version' key must be present and set to 2 (without quotes). See developer.chrome.com/extensions/manifestVersion.html for details.
I have a manifest.json file and icon.png file
manifest.json:
{
"name": "Hello World!",
"version": 2,
"description": "My first Chrome extension.",
"browser_action": {
"default_icon": "icon.png"
}
}
icon.png:
Can anyone tell me what I did wrong? I uploaded my chrome extension at the chrome://extension page, hit the developer mode button, pressed load unpacked extension, and then opened a file called chromeExtension containing the manifest.json and icon.png. Any ideas on how to fix the error?

You need to set the manifest_version, not just the version. The version key is simply the version of your extension:
{
"name": "Hello World!",
"version": "1.0",
"manifest_version": 2,
"description": "My first Chrome extension.",
"browser_action": {
"default_icon": "icon.png"
}
}

Related

Migrating Extension to Manifest v3

I want to Migrate My Chrome extension from manifest version 2 to version 3 because in near future Google will remove MV2 extension from their store. For now My extension Manifest code is like this.
{
"browser_action": {
"default_icon": "img/icon_active.png",
"default_popup": "html/popup.html",
"default_title": "Title here"
},
"description": "description here",
"icons": {
"128": "img/icon_128.png",
"16": "img/icon_16.png"
},
"manifest_version": 2,
"name": "Title here",
"version": "1.0.1"
}
popup.js file look like this
$(document).on("click", ".copy-me", function(ev) {
var $body = document.getElementsByTagName('body')[0];
var rel = $(this).attr("rel");
var text = $("#"+rel).text();
var $tempInput = document.createElement("INPUT");
$body.appendChild($tempInput);
$tempInput.setAttribute("value", text)
$tempInput.select();
document.execCommand("copy");
$body.removeChild($tempInput);
});
Chrome Manifest v2 extensions deprecation timeline
On January 17, 2022: Chrome Web Store no longer accepts new Manifest V2 extensions, however, developers will be allowed to push updates to them.
In January 2023: Manifest V2 extensions will stop working and won’t run in Chrome, developers may not be able to push updates to them even with enterprise policy.
Offical Resource
I suggest you read the Google Chrome Offical Migration Article.
If you don't want to spend your time on this, I suggest Extension Manifest Converter which is a tool that open-source and developed by Google.
According to the README file, the tool has limitations:
This tool aims to simplify the MV3 conversion; it does not fully automate the process. Only search and replace changes are applied to .js files.
This tool does not:
update any service worker code that relies on a DOM
I tried the tool and it gives me the below output:
{
"description": "description here",
"icons": {
"128": "img/icon_128.png",
"16": "img/icon_16.png"
},
"manifest_version": 3,
"name": "Title here",
"version": "1.0.1",
"action": {
"default_icon": "img/icon_active.png",
"default_popup": "html/popup.html",
"default_title": "Title here"
},
"content_security_policy": {}
}
In your case manifest.json changed but nothing changed in popup.js.

Google extension not showing up when I try to load it

I tried to make an useless extension so I could map CTRL W to "open" this extension instead of closing the tab. When I click Load Unpacked the folder with the manifest.json it loads the extension without any errors but the extension doesnt show up at all... Did I do something wrong?
manifest.json:
{
"name": "CTRLW",
"manifest_version": 2,
"version": "1.0",
"icons": { "128": "128.png" }
}

How to Log to Console from Chrome Extension?

Given a Chrome extension that sets up a browser_action based on a default_icon click, how can that extension print to the console? For example, say my manifest.json includes this:
{
"name": "Testing",
"version": "1.0",
"browser_action": {
"default_popup": "testing.html",
"default_icon": "icon.png"
},
"manifest_version": 2
}
and my testing.html loads a <script> with some Javascript:
console.log("WHY DON'T I SEE THIS??");
Why doesn't this print anything to the console? And how might I go about getting something printed to the console?

How to open my Chrome Extension in new Tab?

Hi I have found other similiar questions on stackoverflow but none of them solved the purpose.
I want my chrome extension/app to be opened in a full tab like how POSTMAN extension is opened.
My manifest.json
{
"name": "Sample App",
"manifest_version": 2,
"version": "0.0.1",
"app": {
"background": {
"scripts": ["main.js"]
}
},
"icons": { "128": "icon.png" },
"permissions" : ["tabs" ]
}
My main.js (alias for background.js)
chrome.app.runtime.onLaunched.addListener(function() {
chrome.tabs.create({'url': chrome.extension.getURL('index.html')}, function(tab) {
alert("Hi");
});
});
index.html is the file i want to load on opening the new tab.
My first time responding here on stackoverflow, please be gentle...
I discovered that it's much easier to add "launch" : { "local_path" : "index.html" } within the manifest.json file. See my sample manifest file below.
{
"manifest_version" : 2,
"name": "Hello World!",
"description": "My first Chrome App.",
"version": "0.1",
"app": {
"launch" : {
"local_path" : "index.html"
}
},
"icons": { "16": "icon.png" }
}
Keep in mind that this example is very basic, it has been stripped of some unnecessary information such as a background script but it should accomplish what you want.
http://developer.chrome.com/apps/first_app.html
chrome.app.runtime.onLaunched is only for Chrome apps, not extensions. The code for your background page will automatically run when the Chrome browser starts, so you can start directly with chrome.tabs.create(...).
Also, you need to include index.html and any resource included in your extension that the page will use in a web_accesible_resources section in your manifest.

Not able to see the thumbnail for my extensions in "chrome://settings/extensions" when I load a unpacked extension

I am loading an unpacked extension but I am unable to see any thumbnails for my extension under chrome://settings/extensions?
Whether I should add anything in manifest file?
Here is my manifest file..
{
"name": "a1",
"version": "1.0",
"description": "a1",
"background_page": "background.html",
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
}
}
browser_action.default_icon is only the icon for the button next to the omnibar. If you want an icon in chrome://settings/extensions you need to set the icon value.

Resources