You've already forked brave-origin-unlocker
mirror of
https://github.com/ObjectAscended/brave-origin-unlocker.git
synced 2026-06-21 12:42:34 +00:00
refactor macos support into single file
This commit is contained in:
@@ -11,8 +11,8 @@ This tool modifies the Brave Origin browser's local state configuration to unloc
|
|||||||
- ✅ Unlocks Brave Origin features
|
- ✅ Unlocks Brave Origin features
|
||||||
- ✅ Modifies purchase validation state
|
- ✅ Modifies purchase validation state
|
||||||
- ✅ Updates SKU credentials
|
- ✅ Updates SKU credentials
|
||||||
- ✅ Windows and macOS path compatibility
|
- ✅ Windows and macOS auto-detection & compatibility
|
||||||
- ✅ Easy execution via Deno tasks
|
- ✅ Easy execution and cross-compilation via Deno tasks
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -32,18 +32,35 @@ This tool modifies the Brave Origin browser's local state configuration to unloc
|
|||||||
|
|
||||||
## How to Run 🚀
|
## How to Run 🚀
|
||||||
|
|
||||||
You can run the unlocker directly using the pre-configured Deno tasks:
|
The script automatically detects whether you are running on Windows or macOS. You can run the unlocker directly with:
|
||||||
|
|
||||||
### For Windows 🪟
|
|
||||||
```bash
|
```bash
|
||||||
deno task unlock-win
|
deno task unlock
|
||||||
```
|
```
|
||||||
|
|
||||||
### For macOS 🍎
|
---
|
||||||
|
|
||||||
|
## How to Compile / Cross-Compile 📦
|
||||||
|
|
||||||
|
You can build standalone binaries for different operating systems and architectures using the pre-configured compilation tasks:
|
||||||
|
|
||||||
|
### Compile for Windows (x64)
|
||||||
```bash
|
```bash
|
||||||
deno task unlock-mac
|
deno task compile-win
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Compile for macOS Apple Silicon (ARM64)
|
||||||
|
```bash
|
||||||
|
deno task compile-mac-arm
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compile for macOS Intel (x64)
|
||||||
|
```bash
|
||||||
|
deno task compile-mac-x64
|
||||||
|
```
|
||||||
|
|
||||||
|
These tasks will output the built binaries into the `dist/` directory.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Pre-Bundled Deno Binaries 🎉
|
## Pre-Bundled Deno Binaries 🎉
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"unlock-win": "deno run --allow-env --allow-read --allow-write unlock.ts",
|
"unlock": "deno run --allow-env --allow-read --allow-write unlock.ts",
|
||||||
"unlock-mac": "deno run --allow-env --allow-read --allow-write unlock-mac.ts",
|
"compile-win": "deno compile --allow-env --allow-read --allow-write --target x86_64-pc-windows-msvc --output dist/unlock-win.exe unlock.ts",
|
||||||
"compile-win": "deno compile --allow-env --allow-read --allow-write --output dist/unlock-win.exe unlock.ts",
|
"compile-mac-arm": "deno compile --allow-env --allow-read --allow-write --target aarch64-apple-darwin --output dist/unlock-mac-arm unlock.ts",
|
||||||
"compile-mac": "deno compile --allow-env --allow-read --allow-write --output dist/unlock-mac unlock-mac.ts"
|
"compile-mac-x64": "deno compile --allow-env --allow-read --allow-write --target x86_64-apple-darwin --output dist/unlock-mac-x64 unlock.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
const homeDir = Deno.env.get("HOME");
|
|
||||||
const versions = ["Brave-Origin", "Brave-Origin-Beta", "Brave-Origin-Nightly"];
|
|
||||||
let foundAny = false;
|
|
||||||
|
|
||||||
for (const version of versions) {
|
|
||||||
const localStatePath = `${homeDir}/Library/Application Support/BraveSoftware/${version}/Local State`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const localState = JSON.parse(await Deno.readTextFile(localStatePath));
|
|
||||||
|
|
||||||
localState.brave = localState.brave || {};
|
|
||||||
localState.brave.origin = { purchase_validated: true };
|
|
||||||
|
|
||||||
localState.skus = {
|
|
||||||
state: {
|
|
||||||
"67": JSON.stringify({
|
|
||||||
credentials: {
|
|
||||||
items: { "6": "7" },
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
await Deno.writeTextFile(localStatePath, JSON.stringify(localState));
|
|
||||||
console.log(version.replace(/-/g, " ") + " unlocked successfully!");
|
|
||||||
foundAny = true;
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof Deno.errors.NotFound) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundAny) {
|
|
||||||
console.log("Brave Origin not found.");
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,38 @@
|
|||||||
const localAppData = Deno.env.get("LOCALAPPDATA");
|
const os = Deno.build.os;
|
||||||
|
|
||||||
|
let localStatePathPattern: (version: string) => string;
|
||||||
|
|
||||||
|
if (os === "windows") {
|
||||||
|
const localAppData = Deno.env.get("LOCALAPPDATA");
|
||||||
|
if (!localAppData) {
|
||||||
|
console.error("Error: LOCALAPPDATA environment variable not found.");
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
localStatePathPattern = (version) =>
|
||||||
|
`${localAppData}\\BraveSoftware\\${version}\\User Data\\Local State`;
|
||||||
|
} else if (os === "darwin") {
|
||||||
|
const homeDir = Deno.env.get("HOME");
|
||||||
|
if (!homeDir) {
|
||||||
|
console.error("Error: HOME environment variable not found.");
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
localStatePathPattern = (version) =>
|
||||||
|
`${homeDir}/Library/Application Support/BraveSoftware/${version}/Local State`;
|
||||||
|
} else {
|
||||||
|
console.error(`Error: Unsupported operating system: ${os}`);
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const versions = ["Brave-Origin", "Brave-Origin-Beta", "Brave-Origin-Nightly"];
|
const versions = ["Brave-Origin", "Brave-Origin-Beta", "Brave-Origin-Nightly"];
|
||||||
let foundAny = false;
|
let foundAny = false;
|
||||||
|
|
||||||
for (const version of versions) {
|
for (const version of versions) {
|
||||||
const localStatePath =
|
const localStatePath = localStatePathPattern(version);
|
||||||
`${localAppData}\\BraveSoftware\\${version}\\User Data\\Local State`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const localState = JSON.parse(await Deno.readTextFile(localStatePath));
|
const localState = JSON.parse(await Deno.readTextFile(localStatePath));
|
||||||
|
|
||||||
|
localState.brave = localState.brave || {};
|
||||||
localState.brave.origin = { purchase_validated: true };
|
localState.brave.origin = { purchase_validated: true };
|
||||||
|
|
||||||
localState.skus = {
|
localState.skus = {
|
||||||
|
|||||||
Reference in New Issue
Block a user