Can a greasemonkey-type userscript be packaged as a Chrome extension?

跟風遠走 提交于 2019-11-28 17:54:38
Brock Adams

Two things first:

  1. This new behavior of Chrome seems too restricting and draconian for userscripts. If you agree, please make your displeasure known to Google. (Userscripts are not quite as dangerous, or powerful, as full-fledged extensions.)

  2. Rather than trying to package extensions (which seems like a low benefit-to-hassle activity), Chrome provides two mechanisms to (selectively) disable this new annoyance:

    1. Configure Chrome to start with the --enable-easy-off-store-extension-install parameter.

    2. Add configuration keys to allow installations from specific sites:
      For example, add this entry to the Windows registry:

      Software\Policies\Google\Chrome\ExtensionInstallSources\1 = "http://userscripts.org/*"
      

      To allow easy installation from that useful script clearinghouse.



Packaging a userscript as an extension (Verified on the latest release, version 20.0.1132.57 and subject to change):

  1. Create a script folder and a manifest for your userscript, as in the "Controlling the Script and name" section of this answer.

  2. From the Chrome Extensions page, activate Developer mode:

  3. Click Pack Extension.

  4. Enter the folder path, created in step 1, and click Pack Extension:

  5. Note that the new extension file (HelloWorld.crx) and key file (HelloWorld.pem) are created in the parent directory (C:\MyChromeScripts\).

  6. Now the extension can be installed like any other, or uploaded to the Chrome Web Store.

You could use a Chrome extension like Tampermonkey to run/manage your userscripts without having to install them as extensions themselves.

(I've never used it so I can't say if it's any good, it's reviewed well though)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!