Code Monkey home page Code Monkey logo

extension-manifest-converter's Introduction

Extension Manifest Converter

Extension Manifest Converter is an open source tool that helps convert existing Chrome extensions to Manifest V3. Use it to convert:

  • an entire unpacked directory
  • an extension zip file
  • just a manifest.json file.

After using the tool, complete the conversion using instructions in the Migrate to Manifest V3 guide. This tool makes the conversions listed below. To make completion of the upgrading easier, the titles and bullets below roughly correspond to the wording of the headings and items in the migration guide's checklist.

Updates to the manifest

  • Changes the manifest version number.
  • Updates the host permissions.

Updates that migrate to a service worker

  • Upgrades the "background" field in the manifest.

Updates to API calls

  • Replaces tabs.executeScript() with scripting.executeScript(). (If necessary, also adds scripting to the permissions array in the manifest.json.)
  • Replaces tabs.insertCSS() with scripting.insertCSS(). You will still need to [replace tabs.removeCSS() with scripting.removeCSS()](https://developer.chrome.com/docs/extensions/migrating/api-calls/#replace-insertcss-removecss). (If necessary, also adds scripting to the permissions array in manifest.json.)
  • Replaces Browser Actions and Page Actions with Actions and makes related changes to the manifest.

Improvement to extension security

  • Updates the content security policy.

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 the DOM.

Installation

To use this tool, follow the steps below.

  1. Make sure Python 3 is installed.

    python3 --version

    If you don't see a version number, follow your OS's guidance to install Python 3 or visit https://www.python.org/downloads/ to download a recent release.

  2. Clone this repo using the below command.

    git clone https://github.com/GoogleChromeLabs/extension-manifest-converter
  3. cd into the cloned project directory.

  4. Execute the test command.

    python3 emc.py

    The tool logs basic usage information to the console.

Usage

  • Convert a directory

    python3 emc.py dir/path/
  • Convert a manifest file

    python3 emc.py manifest.json
  • Convert a .zip file

    python3 emc.py extension.zip

License

Apache 2.0

This is not an official Google product.

extension-manifest-converter's People

Contributors

jpmedley avatar solomonkinard avatar tyraeldlee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

extension-manifest-converter's Issues

conver v2 to v3 have problem

image

I want to convert a gitub project to v3 from v2: bypass-paywalls-chrome

and I do with cmd:

(base) โžœ  extension-manifest-converter git:(main) python emc.py ../bypass-paywalls-chrome/
../bypass-paywalls-chrome/
Changing manifest_version to 3
Changing to background.service_worker in manifest.json
Changed to chrome.action in manifest.json
Changing CSP (content_security_policy) in manifest.json
Valid CSP directives for {script,object,worker}-src are {self,none,localhost,127.0.0.1}.
Converted extension into: ../bypass-paywalls-chrome/_delete

seem the results are not ok right now.

image

Error with content_security_policy

I converted content_security_policy and met issue :

'content_security_policy.extension_pages': Insecure CSP value "https://www.google-analytics.com" in directive 'script-src'. Could not load manifest.

What can I do to bypass the issue ?

'HELP' me to convert my manifest file from version 2 to 3, this converter is not working, the file still throwing errors

{
  "name": "LeetAssist",
  "version": "1.0",
  "manifest_version": 2,
  "description": "Provides hints/prerequisites for problems, can add your own & vote on others. Collaborative problem-solving for coding challenges.",
  "content_scripts": [
    {
      "matches": ["https://leetcode.com/problems/*"],
      "js": ["popup.js"],
      "run_at": "document_end"
    }
  ],
  "browser_action": {
    "default_popup": "popup.html"
  },
  "icons": {
    "128": "./logo.png"
  },

  "web_accessible_resources": ["firebase-app.js", "firebase-firestore.js"],
  "permissions": ["activeTab", "storage", "https://www.googleapis.com/"],
  "content_security_policy": " script-src 'self' https://cdn.firebase.com https://apis.google.com https://www.gstatic.com object-src 'self'"
} ``` 

this is the code of my manifest.json please convert it into version 3, i tried but it is showing errors related to content_security_policy

'utf-8' codec can't decode byte 0xfc

Hello, I get the following error:

File "C:\Users\XX\Desktop\extension-manifest-converter-main\src\modifiers\ExecuteScriptModifier.py", line 56, in _mv3
    data = file.read()
  File "C:\Users\XX\AppData\Local\Programs\Python\Python39\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 219: invalid start byte

Would appreciate help :) Thanks!

Add a readme with basic docs

At the moment it's not clear how to get started. The repo should contain a README.md file that provides some basic information on how to use this tool & the operations it supports.

Mv3 to Mv2

Any chance someone can either fork this or add the option to convert mv3 to mv2 for cross platform use?

Tool should about unsupported APIs

Since we have a known list of APIs that aren't supported in MV3, it would be nice of the converter could flag calls to those APIs print a console warning stating what should be used instead and maybe providing a link to documentation for the preferred APIs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.