Skip to content

Chrome browser extension tools. Provides a set of tools packing, unpacking, zip, unzip, download, etc.

License

Notifications You must be signed in to change notification settings

mmadfox/go-crx3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-crx3

Coverage Status Documentation Go Report Card Actions

Provides a sets of tools packing, unpacking, zip, unzip, download, gen id, etc...

Table of contents

Installation

go get -u github.com/mediabuyerbot/go-crx3/crx3
go install github.com/mediabuyerbot/go-crx3/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/mediabuyerbot/go-crx3"

if err := crx3.Extension("/path/to/file.zip").Pack(nil); err != nil {
    panic(err)
}
import crx3 "github.com/mediabuyerbot/go-crx3"

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/mediabuyerbot/go-crx3"

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/mediabuyerbot/go-crx3"

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/mediabuyerbot/go-crx3"
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] 

Retriveres public key from extension

import crx3 "github.com/mediabuyerbot/go-crx3"

pubkey, signature, err := crx3.Extension("/path/to/ext.crx").PublicKey()
$ crx3 pubkey /path/to/ext.crx [-o /path/to/file]  

Download

Download a chrome extension from the web store
import crx3 "github.com/mediabuyerbot/go-crx3"

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/mediabuyerbot/go-crx3"

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/mediabuyerbot/go-crx3"

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/mediabuyerbot/go-crx3"

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/mediabuyerbot/go-crx3"

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/mediabuyerbot/go-crx3"

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

About

Chrome browser extension tools. Provides a set of tools packing, unpacking, zip, unzip, download, etc.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages