How to compile a Google Chrome extension out of code I found at userscripts.org?

前端 未结 1 721
有刺的猬
有刺的猬 2021-01-05 17:32

I came across this userscript which works in Google Chrome.

I want to use it as Google Chrome extension as this will give me experience to convert many other codes f

相关标签:
1条回答
  • 2021-01-05 18:08

    In Google Chrome, userscripts are extensions. The script gets packaged as a content script, and the extension manifest.json gets automatically generated.

    To move towards a "full fledged" extension:

    1. First organize your script, source file(s) and explicitly create the manifest.json as shown in this answer.

    2. You do not need to alter that userscript's code, at this point, but you will want to transfer the values of the @include and @run-at directives to the manifest.json file you will generate. Refer to the example in that linked answer.

    3. Read the Content Scripts page and note how the manifest can be used to easily add CSS, jQuery, your userscript (AKA content script), etc.

    4. Content scripts are 1 of the 3 main tools available to Chrome extensions. The other 2 are the background page and UI pages. Learn more about those starting with the extension-development Overview.

    5. Finally, you can package your extension as explained in this answer.

    0 讨论(0)
提交回复
热议问题