Google Chrome Extension error - Access-Control-Allow-Origin - google-chrome

XMLHttpRequest cannot load http://localhost:4567/save. Origin chrome-extension://cbemaelkkmebiohhjgmlclegalijdbbh is not allowed by Access-Control-Allow-Origin.
Even thought I'm getting this error the extension seems to be calling the URL. The message passing from contentscript.js to background.html took me a few minutes to wire up, but seems ok. I'm confused.
Here is my manifest.
{
"name": "FirstExt",
"version": "1.0",
"description": "My First Extension",
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
},
"content_scripts": [
{
"matches": ["http://*"],
"js": ["jquery.min.js", "contentscript.js"]
}
],
"background_page": "background.html",
"permissions": [ "http://*",
"http://localhost:4567/*" ]
}

Try changing http://* to http://*/ (and removing the localhost entry).
If you're trying to access a https page, you will need that too.

Replace "http://*" with "<all_urls>".

Related

Error processing manifest in firefox

I have developed a extension primarily focused on chrome which works but now i need that extension to work in firefox either so I checked by loading the extension by going to about:debugging page and loading temporary addons. Currently, I go an error. I got error something like this
Reading manifest: Error processing options_page: An unexpected
property was found in the WebExtension manifest.
Reading manifest: Error processing oauth2: An unexpected property
was found in the WebExtension manifest.
Reading manifest: Error processing key: An unexpected property was
found in the WebExtension manifest.
Here is what my manifest file looks like(I removed options_page)
manifest.json
{
"version": "1.0",
"name": "Browser Extension",
"manifest_version": 2,
"description":
"This extension allow the user to select the text and redirect to the application",
"page_action": {
"default_title": "Select Text",
"default_popup": "index.html"
},
"icons": {
"16": "img/browser16.png",
"48": "img/browser48.png",
"128": "img/browser128.png"
},
"background": {
"scripts": ["extension/js/background.js"],
"persistent": true
},
"content_scripts": [
{
"matches": [
"https://mail.google.com/mail/*/*",
"http://mail.google.com/mail/*/*"
],
"js": ["extension/js/jquery.min.js", "extension/js/content.js"],
"css": ["extension/css/main.css"],
"run_at": "document_end"
}
],
"permissions": [
"contextMenus",
"tabs",
"storage",
"webNavigation",
"notifications",
"cookies",
"identity",
"*://mail.google.com/mail/*/*",
"https://www.googleapis.com/*",
"https://*.googleusercontent.com/*"
],
"web_accessible_resources": ["img/browser128.png", "img/ios-link.svg"],
"oauth2": {
"client_id":
"114446495690-8ejpdgvmn8vc9pblteupetas.apps.googleusercontent.com",
"scopes": ["profile", "https://www.googleapis.com/auth/gmail.readonly"]
},
"key":
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnqFjzbt+LtejD1JhOyMUbejOHdLoemzryr+ZQHK2CEKuI0yVVYToFs7eNusH/hfxhnyF27G4BU8apsTc695EpVQGD0ANKdt6BjubRnA/4VcdkmfdD3D9nsdCc+fHkINRU5e05grfs/BETWW/JAUULduaNWGfhT7"
}
How do i resolve above issues to make it firefox compatible as well?

Chrome extension is corrupted

I have problem with my extension. It is working for me unpacked and when I download it from Chrome store.
However, some users reported that after update extension is corrupted. That's happen after they update it to newer version.
Difference between old and new version is background page and some logic.
I was able to replicate that issue, by packing extension and than drop it into extensions tab. After that I saw the same message as extension users. I also tried that with another extensions and everything worked fine, so maybe there is some issue in manifest file.
{
"manifest_version": 2,
"name": "Cryptocurrency Price Tracker",
"description": "This simple extension allows you to track price changes of Bitcoin and other cryptocurrencies.",
"version": "2.5",
"icons": {
"16":"icon16.png",
"48":"icon48.png",
"128":"icon128.png"
},
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"options_ui": {
"page": "options.html",
"chrome_style": true
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"storage",
"notifications",
"https://api.coinmarketcap.com/v1/*"
]
}
I use background page, not event page. So maybe I should add something in the manifest...
P.S. Packaging doesn't work for older version of extension... One more important thing. Users reported that after clicking on options page they saw that error. It didnt happend in my case, when I drag and drop extension file, I saw error immediately.
You need to put in a link to an update url in the manifest. The problem was mentioned in this forum:
https://productforums.google.com/forum/?hl=en#!topic/chrome/kGgLwnrDKpQ;context-place=forum/chrome
So you add update_url into your manifest. It can be any valid url if you are not making use of the feature. So like this:
"name": "Cryptocurrency Price Tracker",
"description": "This simple extension allows you to track price changes of Bitcoin and other cryptocurrencies.",
"version": "2.5",
"icons": {
"16":"icon16.png",
"48":"icon48.png",
"128":"icon128.png"
},
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"options_ui": {
"page": "options.html",
"chrome_style": true
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"storage",
"notifications",
"https://api.coinmarketcap.com/v1/*"
],
"update_url": "http://www.example.com/update.xml"

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.

Matching content script with last keyword match

I have a page in block.html in extension directory. I want match content script with the page name.
Check my manifest file below, there is content_script match:
{
"manifest_version": 2,
"name": "Cobra Security ATD",
"version": "1.0",
"description": "Cobra Security Advance Threat Defence.",
"icons": {
"48": "img/48-48.png",
"128": "img/128-128.png"
},
"browser_action": {
"default_icon": "img/16-16.png",
"default_title": "Cobra Security Advance Threat Defence",
"default_popup": "popup.html"
},
"background": {
"scripts": ["js/jquery-1.11.1.js","js/event.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["http://*/*block.html"],
"js": ["js/jquery-1.11.1.js","js/block.js"]
}
],
"permissions": [
"<all_urls>",
"tabs",
"webNavigation"
]
}
One does not inject content scripts into chrome-extension:// pages. You cannot indicate this schema in the manifest, and you can't indicate a host permission that would allow you to inject it.
Since it's an extension that you control, you don't need to inject scripts for anything!
If you want to put code in it, you.. put code in it, in a <script
src="..."> fashion.
If you want to inform the page of some event, you use Messaging.
If you want to pass some information when you open the page, you can
use this trick, sending a request back for data.

`Manifest file is invalid` when uploading my chrome extension to the Chrome Web Store

I have been developing a chrome extension locally. I just finished it and wanted to upload it to the Chrome Web Store. When I uploaded it and it told me:
An error occurred: Invalid manifest. If your manifest includes comments, please remove them as our gallery does not support them yet.
I checked the JSON to make sure it it was valid and as far as I can tell it is fully valid. I tried naming it differently and uploading it and it still didn't work. I also tried changing the encoding and that did not work. The Manifest is below
{
"name": "Name",
"version": "0.0.0.0.1",
"manifest_version": 2,
"description": "Description",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"icons": { "128": "icon.png"},
"permissions": [
"tabs",
"http://*/*",
"webNavigation",
"history",
"storage"
],
"content_scripts": [{
"matches": ["http://*/*", "https://*/*"],
"js": ["js/jquery.min.js", "js/tab.js"]
}],
"background": {
"page": "background.html"
}
}
Does any one have any clue what the problem is? It is really frustrating to get this after finally finishing the extension.
Used your manifest.json, got this error.
Could not load extension from '/Users/jjperezaguinaga/samples/ext'. Required value 'version' is missing or invalid. It must be between 1-4 dot-separated integers each between 0 and 65536.
I removed some 0's from your version and I was able to load it.
replace
"version": "0.0.0.0.1"
with
"version": "1.0"