Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome extension: Could not load javascript file

I have posted another question regarding my Chrome extension here.
But I have one more question about extensions themselves. I only need a content script for the modification of the Tumblr-Dashboard, no background page or something else, right?

Here is the manifest.json file:

{
    "name": "Tumblr - Tiled Dashboard",
    "version": "0.0.54",
    "manifest_version": 2,
    "description": "This extension modifies the look of your Tumblr dashboard.",
    "icons": {
        "16": "images/icon_16.png",
        "48": "images/icon_48.png",
        "128": "images/icon_128.png"
    },
    "content_scripts": [
        {
            "matches": [ "*://*.tumblr.com/dashboard" ],
            "css": [ "styles.css" ],
            "js": [ "jquery-2.1.3.min.js", "masonry.min.js", "code.js" ]
        }
    ],
    "homepage_url": "mypage",
    "author":  "myname"
}

To start, I ask if this is alright? I have read a lot about the manifest.json file and everything seems to work fine when I try out the extension locally. But when I pack the extension and upload it, there are two problems:

  1. I cannot find the extension when I search for it
  2. When I use the link to find the extension, and I want to install it (tried that on 2 different PCs), I get an error, telling me that the jquery-2.1.3.min.js file could not be loaded. I therefore changed the order of my JavaScript files to test if it was a problem related to the jQuery file, but having masonry.min.js as the first file in the array resulted in the same error.

Why does this happen? Is the manifest.json file ok? Do I need some special permissions?

Edit: This is a screenshot of when I try to install the extension from the Chrome Web Store (where I also can't find it by search).

Screenshot of when I try to install the package from the Web Store

like image 824
Eru Iluvatar Avatar asked Feb 04 '15 10:02

Eru Iluvatar


1 Answers

I took a look inside your extension's ZIP file before downloading it, and the result was the following:

zip

*Inspected using Chrome extension source viewer by Rob Wu

The problem here, is that you've uploaded a packed CRX file inside of your ZIP file, instead of your extension source code. You should instead upload a ZIP file containing your extension's root. Since that you're including the manifest.json file, the Web Store doesn't notice anything wrong until you try to install the extension, because the manifest is well written, but when Chromes tries to access the files declared, it fails and returns an error, because those files do not exist.

Quoting from the upload page of the Chrome Web Store Developer Dashboard:

Uploading an item:

  • Upload a ZIP file of your item directory, not a packaged CRX file.
  • Include a well-designed product icon in your manifest (more info).
  • Read the documentation about creating and packaging apps.
  • Need more help? Check out the Chrome Web Store developer documentation.

So, you should create a ZIP file of your extension's root directory, containing all the files of your extension. Your ZIP file should then look like the following:

enter image description here

like image 200
Marco Bonelli Avatar answered Sep 17 '22 20:09

Marco Bonelli