lingua-libre / SignIt

๐ŸŒป Lingua Libre SignIt web-browser extension translates selected word in French Sign Language via an elegant pop up so you learn sign language while reading online.
https://addons.mozilla.org/en-US/firefox/addon/lingua-libre-signit/
MIT License
11 stars 13 forks source link

Manual installation error on Chrome and Edge #55

Closed LeoDupont closed 3 months ago

LeoDupont commented 4 months ago

When trying to manually install SignIt from chrome://extensions on Chrome (and from edge://extensions on Edge), with Developer Mode enabled, I get the following error message:

Failed to load extension
File 
~\Downloads\SignIt\SignIt-master
Error
'content_security_policy.extension_pages': Insecure CSP value "https://commons.wikimedia.org" in directive 'object-src'.
Could not load manifest.

Tested on Chrome latest version: 121.0.6167.185 Tested on Edge latest version: 121.0.2277.128

With SignIt latest commit on master: 75d09f3

hugolpz commented 3 months ago

@LeoDupont hello, I am primarily working on Firefox and migrating to Chrome in 2024. Did you test on Firefox and is it working ?

It can run on Chrome but the manifest.json needs few changes. From memory, this at least the following changes are required.

Background script working on FF and Chrome

"background": {
    "service_worker": "background.js",
    "scripts": ["background.js"]
},

Manifest.json valid on Chrome

You need to remove

    "applications": {
        "gecko": {
            "id": "signit@lingualibre.fr"
        }
    },

Then, on Chrome open chrome://extensions/ : click Load unpacked or "Pack extension". It could work.

kabir-afk commented 3 months ago

@LeoDupont cc @hugolpz did you try removing the content_security_policy.extension_pages script from manifest.json file ? If it works then well and good but apparently I faced some other errors like

Failed to load extension

File~\Desktop\Web-dev\SignIt

Error Could not load javascript 'lib/browser-polyfill.min.js' for script.
Could not load manifest.
Failed to load extension

File~\Desktop\Web-dev\SignIt

Error Could not load javascript 'lib/banana-i18n.js' for script.
Could not load manifest.

The reason why I faced these errors is because I am currently facing some issues with postinstall script in package.json due to which these files are not being imported in lib file dynamically and if you do too then you could try changing the paths in your manifest.json file. Apparently these files were to be made dynamically as mentioned in build.sh file present in the bin folder. But that didn't happen with me so I changed the scripts inside manifest.I guess my node doesn't fully recognize the bin folder maybe that's why.

IF YOU CAN HELP ME WITH THAT IT'LL BE HIGHLY APPRECIATED

Also it's not like these were not working to being with , I didnt face such error while running it in FF ,they were/are clearly working in firefox. They indeed are installed as dependencies which can be taken advantage of....new manifest.json would look something like

  "manifest_version": 3,
  "name": "Lingua Libre SignIt",
  "version": "1.0.20",
  "author": "Antoine '0x010C' Lamielle, Hugo Lopez",
  "description": "SignIt translate a selected word into Sign Language videos.",
  "homepage_url": "https://lingualibre.org",

  "icons": {
    "32": "icons/Lingualibre_SignIt-logo-no-text-square-32.png",
    "48": "icons/Lingualibre_SignIt-logo-no-text-square-48.png",
    "64": "icons/Lingualibre_SignIt-logo-no-text-square-64.png"
  },
  "permissions": [
    "scripting",
    "activeTab",
    "contextMenus",
    "storage",
    "webRequest",
    "webRequestBlocking",
    "offscreen",
    "<all_urls>"
  ],
  "content_scripts": [
    {
      "matches": [
        "<all_urls>"
      ],
      "css": [
        "node_modules/oojs-ui/dist/oojs-ui-wikimediaui.min.css",
        "content_scripts/signit.css"
      ],
      "js": [
        "node_modules/webextension-polyfill/dist/browser-polyfill.min.js",
        "node_modules/jquery/dist/jquery.min.js",
        "node_modules/banana-i18n/dist/banana-i18n.js",
        "node_modules/oojs-ui/dist/oojs-ui.min.js",
        "node_modules/oojs-ui/dist/oojs-ui-wikimediaui.min.js",
        "SignItVideosGallery.js",
        "SignItCoreContent.js",
        "content_scripts/signit.js"
      ]
    },
    {
      "matches": [
        "https://*.wikipedia.org/*"
      ],
      "css": [
        "node_modules/oojs-ui/dist/oojs-ui-wikimediaui.min.css",
        "content_scripts/wpintegration.css"
      ],
      "js": [
        "node_modules/webextension-polyfill/dist/browser-polyfill.min.js",
        "node_modules/jquery/dist/jquery.min.js",
        "node_modules/banana-i18n/dist/banana-i18n.js",
        "node_modules/oojs-ui/dist/oojs-ui.min.js",
        "node_modules/oojs-ui/dist/oojs-ui-wikimediaui.min.js",
        "SignItVideosGallery.js",
        "content_scripts/wpintegration.js"
      ],
      "run_at": "document_end"
    }
  ],
  "background": {
    "scripts": [
        "lib/browser-polyfill.min.js",
        "lib/jquery.min.js",
        "lib/banana-i18n.js",
        "background-script.js"
    ]
},
  "web_accessible_resources": [
    {
      "resources": [
        "icons/*"
      ],
      "matches": [
        "<all_urls>"
      ]
    }
  ],
  "commands": {
    "_execute_browser_action": {
      "suggested_key": {
        "default": "Ctrl+Shift+L"
      }
    }
  },

  "action": {
    "default_icon": "icons/Lingualibre_SignIt-logo-no-text-square-32.png",
    "default_title": "Lingua Libre SignIt",
    "default_popup": "popup/popup.html"
  }
}

Note

If your extension seems to be working completely fine in FF then no need to change the manifest. It may work in firefox as well since it is one and the same thing as they represent literallly the same absoulte path, nothing else , but again , why make unnecessary changes.

The oojs-ui package seems to have lot of issues inside it. Also it is not a safe practice to remove CSP scripts since they are responsible for preventing XSS attacks but apparently cant think of anything else to make this work in chrome's developer mode . . . but again we can work on those issue later. Upon clicking Load Unpacked in dev mode it might look something like this

Screenshot (29)

There might be some warnings regarding incompatibility of action and background scripts with V3 but they are being worked upon. Hopefully I was able to help if you tackled the same issues as well , do inform if only I was the one who faced it. . . also apologies for my lack of activity lately๐Ÿ˜…

kabir-afk commented 3 months ago

Regarding background-scripts then I used the old way we used to do in V2 , as it gives nothing more than a warning . . . also it has got something to do with service worker in V3 which I am trying to wrap my head around ๐Ÿ˜…๐Ÿ˜…

kabir-afk commented 3 months ago

I have updated the manifest file such that it wont show error for unsupported content security policies . . . you can ignore reading the above banter