Chrome extension: CSS file won't get injected - google-chrome

I'm trying to write a chrome extension that uses a CSS file, but it just does not get injected. The manifest file is pretty straight forward
{
"manifest_version": 2,
"name": "Youtube Embed Performance",
"description": "",
"version": "1.0",
"permissions": ["https://redcursor.net/channels/18181"],
"content_scripts": [
{
"matches" : ["https://redcursor.net/channels/18181"],
"css" : ["youtube.css"],
"js" : ["youtube.js"],
"run_at" : "document_start"
}
]
}
The script appears in the Sources tab as part of my extension (and gets executed). The CSS won't appear there.

Related

Error loading extension

I got this extension for google chrome and it won't load when I try to load unpacked extension. Where is the problem?
{
"manifest_version": 2,
"name": "HTML",
"description": "HTML change",
"version": "1",
"background": {
"page": "background.html"
},
"content_scripts": [
{
"matches": ["https://ocjene.skole.hr/pocetna/prijava/*"],
}
],
}
Trailing commas mean invalid json - try this change first:
{
"manifest_version": 2,
"name": "HTML",
"description": "HTML change",
"version": "1",
"background": {
"page": "background.html"
},
"content_scripts": [
{
"matches": ["https://ocjene.skole.hr/pocetna/prijava/*"]
}
]
}
You may refer with this Can't load unpacked extension? forum.
I'm going to recommend that you start with a powerwash. This will wipe your device and return it to factory settings (and also put you back to the stable channel). Full instructions can be found in this help center article.
After the powerwash, I would suggest that you test whether or not the extension will load while still running a stable build. If it does, and then it stops working when you switch o the dev channel, that helps to narrow down the issue.
Additional references:
Load Unpacked Extension
Unable to load unpacked extensions

Chrome extension REJECT when inline installation checked

I made custom chrome extension which loads external javascript file (file is hosted on amazon s3) using XMLHttpRequest. Code snippet which calls this XMLHttpRequest is in separate file, and included in manifest.json under content_scripts:
{
"background": {
"scripts": [ "background.js" ]
},
"content_scripts": [ {
"js": [ "content.js" ],
"matches": [ "http://*/*", "https://*/*" ]
} ],
"manifest_version": 2,
"name": "Name",
"short_name": "shortname",
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "1.0"
}
If I don't check inline install, it is accepted and published in few minutes.
But when I check inline install and choose site, review process takes a long time and extension becomes rejected. Domain is secured (https). And tag containing info about extension is added to site's head tag.
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/itemID">
So, the rejection reason is probably related to inline installation method, and there should be some trick? Anyone for help? Is there something wrong I did?

Why does chrome not recognize this manifest.json file?

Here is my manifest.json file
{
"name":"Name",
"version": "1.0",
"description":"This is the description",
"manifest-version": 2
}
Chrome says
manifest file is missing or unreadable
The file is indeed a .json file, rather than a .txt file. What is wrong with my manifest.json file?
manifest file is missing or unreadable
You have manifest-json instead of manifest_json in the code snippet.
If you follow this tutorial then it lists the simple manifest.json for chrome extension. In below snippet replace name, description, icon, url with your own and give it a try.
{
"name": "Great App Name",
"description": "Pithy description (132 characters or less, no HTML)",
"version": "0.0.0.1",
"manifest_version": 2,
"icons": {
"128": "icon_128.png"
},
"app": {
"urls": [
"http://mysubdomain.example.com/"
],
"launch": {
"web_url": "http://mysubdomain.example.com/"
}
}
}
Let us know, if you have any difficulty in following the tutorial.

Chromium extension: javascript not executed

Making a simple plugin , which executes javascript when a page is loaded , and I want to execute different javascript on different page
But the following code wasn't working as expected , no "alert" was triggered:
background.html:
<html><body>
<script>
chrome.webRequest.onCompleted.addListener(
function(details) {
alert (details.url);
},
{
urls: ["*"],
types: ["main_frame"]
},
[]
);
</script>
</body></html>
manifest.json:
{
"name": "JS",
"background_page": "background.html",
"permissions": [
"webRequest",
"*"
],
"version":"0.10"
}
Alerts and console.log made from the background page of an extension simply aren't visible on the general pages.
If you want to see them, you have to open the background page : Go to the extensions settings page (menu tools/extensions) and click the "background.html" link below the name of your extension.
In your case it may be better, during development phase, to simply add the console.log and alerts in the content scripts (i.e. not the background page). So you can read them without opening the background page.
EDIT : as requested, an extension that will simply alert the location :
main.js :
alert(document.location.href);
manifest.json :
{
"name": "Any name",
"version": "3.3",
"background_page": "background.html",
"content_scripts": [
{
"matches": ["http://*/*"],
"all_frames" : true,
"run_at" : "document_end",
"js": [
"main.js"
]
}
]
}
Yes I tested it. And yes it's as painful as it sounds. You should use console.log instead of alert during your dev.

Google Chrome extension dev, json manifest issue

I'm learning to write extensions for Chrome. In their tutorial on Hello World, I copied their manifest.json file and followed instructions to the letter, but when I go into the extensions panel and try to load an unpacked extension, I get an error that says the manifest file is missing or unreadable. I'm not well-versed in json, but I cut and pasted their code, and it still isn't working. Has anyone else had this problem? How do I fix it?
You have a semi-colon after the permissions array that should not be there:
Change this from:
{
"name": "My First Extension",
"version": "1.0",
"description": "The first extension that I made.",
"browser_action": { "default_icon": "icon.png" },
"permissions": [ "api.flickr.com/"; ]
}
To:
{
"name": "My First Extension",
"version": "1.0",
"description": "The first extension that I made.",
"browser_action": { "default_icon": "icon.png" },
"permissions": [ "api.flickr.com/" ]
}
Also, if you do not have an image with the name icon.png in the root folder of your extension then you will either need to create one of remove the reference to the image.