Skip to content

meowabyte/pak-patcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pak-patcher

Note

This tool only supports .pak version 5. (Most recent by the time of writing this) Support for lower versions is not expected in near future unless requested.

Pak Patcher is an utility tool allowing you to easily manipulate .pak format files through CLI menu or using arguments. (when automating)

I created this tool since I wanted to edit style of Brave's New Tab page while also preserving it's Brave Stats feature. (which wouldn't be possible through simple extension or would take too long when modifying source code.)

The tool preserves 99% of the same pak structure while packing as before extraction making it prone to breaking.

Caution

Before modifying .pak files you stumble upon please take a solid note that careless modifying of .pak files in your apps might potentially break your app and render it unusable! Please do not edit or add IDs of any resource you extracted as the change most likely won't get updated in app! (editing it's content should be fine though)

Features

  • Extract .pak file
  • Pack .pak file
  • Patch resources in .pak file using JavaScript modules.

Pak Patcher also includes example patch module that modifies Brave's internal new tab page. It uses plugin made by me that under the hood replaces CSS imports into LightningCSS optimized style that later is added to new tab page.

Requirements

  • Bun Runtime
    The code will NOT work with basic Node.js runtime as the code specifically uses optimized APIs that are Bun exclusive.

...that's it.

Preparation

# Install dependencies
$ bun install --frozen-lockfile

# Run the app
$ bun start

Note

You can also use bun debug which will enable additional debug messages when doing operations with pak such as Metadata logging.

CLI Usage

The tool uses fairly simple CLI structure where --action=N stands for action number from menu and each --arg stands for appropriate prompt that you can stumble upon in selected action.

Example from included patch_newtab.sh script for Brave:

# Action=2 stands for Patch Action
# Arg=1 stands for Patch #1
$ bun run . --action=2 --arg=$RESOURCES_FILENAME --arg=$PATCHED_RESOURCES_PATH --arg=1

Credits

Found a bug?

If you found a bug in a tool please report it to me on the issues page.

Preview

Console with modified message Modified source code

TODO:

  • Full internal chrome typings for patching purposes. (Current state)
  • Ability to preserve patches between updates (Chromium browsers)
    Currently if there's an update that adds new resources, your patches will be discarded. Repatching fixes this.
  • v4 support (V4 PAK NEEDED)

About

Utility tool for manipulating files with .pak format.

Topics

Resources

License

Stars

Watchers

Forks