# README
go-crx3
Provides a sets of tools packing, unpacking, zip, unzip, download, gen id, etc...
Table of Contents
- go-crx3
Installation
go get -u github.com/joelvaneenwyk/go-web-extensions/crx3
go install github.com/joelvaneenwyk/go-web-extensions/crx3@latest
OR download the binary from here
https://github.com/mmadfox/go-crx3/releases
Dev commands
make proto
make test/cover
Examples
Pack
Pack a zip file or unzipped directory into a crx extension
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
if err := crx3.Extension("/path/to/file.zip").Pack(nil); err != nil {
panic(err)
}
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
pk, err := crx3.LoadPrivateKey("/path/to/key.pem")
if err != nil {
panic(err)
}
if err := crx3.Extension("/path/to/file.zip").Pack(pk); err != nil {
panic(err)
}
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
pk, err := crx3.LoadPrivateKey("/path/to/key.pem")
if err != nil {
panic(err)
}
if err := crx3.Extension("/path/to/file.zip").PackTo("/path/to/ext.crx", pk); err != nil {
panic(err)
}
crx3 pack /path/to/file.zip
crx3 pack /path/to/file.zip -p /path/to/key.pem
crx3 pack /path/to/file.zip -p /path/to/key.pem -o /path/to/ext.crx
Unpack
Unpack chrome extension into current directory
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
if err := crx3.Extension("/path/to/ext.crx").Unpack(); err != nil {
panic(err)
}
crx3 unpack /path/to/ext.crx
Base64
Encode an extension file to a base64 string
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
import "fmt"
b, err := crx3.Extension("/path/to/ext.crx").Base64()
if err != nil {
panic(err)
}
fmt.Println(string(b))
crx3 base64 /path/to/ext.crx [-o /path/to/file]
Download
Download a chrome extension from the web store
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
extensionID := "blipmdconlkpinefehnmjammfjpmpbjk"
filepath := "/path/to/ext.crx"
if err := crx3.DownloadFromWebStore(extensionID,filepath); err != nil {
panic(err)
}
crx3 download blipmdconlkpinefehnmjammfjpmpbjk [-o /custom/path]
crx3 download https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk
Zip
Zip add an unpacked extension to the archive
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
if err := crx3.Extension("/path/to/unpacked").Zip(); err != nil {
panic(err)
}
crx3 zip /path/to/unpacked [-o /custom/path]
Unzip
Unzip an extension to the current directory
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
if err := crx3.Extension("/path/to/ext.zip").Unzip(); err != nil {
panic(err)
}
crx3 unzip /path/to/ext.zip [-o /custom/path]
Gen ID
Generate extension id (like dgmchnekcpklnjppdmmjlgpmpohmpmgp)
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
id, err := crx3.Extension("/path/to/ext.crx").ID()
if err != nil {
panic(err)
}
crx3 id /path/to/ext.crx
IsDir, IsZip, IsCRX3
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
crx3.Extension("/path/to/ext.zip").IsZip()
crx3.Extension("/path/to/ext").IsDir()
crx3.Extension("/path/to/ext.crx").IsCRX3()
NewPrivateKey, LoadPrivateKey, SavePrivateKey
import crx3 "github.com/joelvaneenwyk/go-web-extensions"
pk, err := crx3.NewPrivateKey()
if err != nil {
panic(err)
}
if err := crx3.SavePrivateKey("/path/to/key.pem", pk); err != nil {
panic(err)
}
pk, err = crx3.LoadPrivateKey("/path/to/key.pem")
Keygen
crx3 keygen /path/to/key.pem
License
go-crx3 is released under the Apache 2.0 license. See LICENSE.txt
# Functions
Base64 encodes an extension file to a base64 string.
CopyFile copies the contents of the source file 'src' to the destination file 'dst'.
DownloadFromWebStore downloads a Chrome extension from the web store.
ID returns the extension ID extracted from a CRX (Chrome Extension) file specified by 'filename'.
LoadPrivateKey loads the RSA private key from the specified 'filename' into memory.
NewPrivateKey returns a new RSA private key with a bit size of 2048.
Pack packs a zip file or unzipped directory into a crx extension.
SavePrivateKey saves the provided 'key' private key to the specified 'filename'.
SetWebStoreURL sets the web store url to download extensions.
Unpack unpacks a CRX (Chrome Extension) file specified by 'filename' to its original contents.
UnpackTo unpacks a CRX (Chrome Extension) file specified by 'filename' to the directory 'dirname'.
Unzip extracts all files and directories from the provided ZIP archive.
UnzipTo extracts the contents of a ZIP archive specified by 'filename' to the 'basepath' directory.
Zip creates a *.zip archive and adds all files from the specified directory to it.
ZipTo creates a ZIP archive with the specified filename and adds all files from the given directory to it.
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
Extension represents an extension for google chrome.