mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
b3bbc0dadf
* feat: add CountEntries to skip decryption for list --detail (#549) * test: add CountEntries and countCategory tests at browser level * fix: address review feedback on CountRows and countLocalStorage * test: add CountRows unit tests
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package firefox
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/tidwall/gjson"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/types"
|
|
)
|
|
|
|
func extractExtensions(path string) ([]types.ExtensionEntry, error) {
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var extensions []types.ExtensionEntry
|
|
for _, v := range gjson.GetBytes(data, "addons").Array() {
|
|
// Only include user-installed extensions
|
|
// https://searchfox.org/mozilla-central/source/toolkit/mozapps/extensions/internal/XPIDatabase.jsm#157
|
|
if v.Get("location").String() != "app-profile" {
|
|
continue
|
|
}
|
|
|
|
extensions = append(extensions, types.ExtensionEntry{
|
|
Name: v.Get("defaultLocale.name").String(),
|
|
ID: v.Get("id").String(),
|
|
Description: v.Get("defaultLocale.description").String(),
|
|
Version: v.Get("version").String(),
|
|
HomepageURL: v.Get("defaultLocale.homepageURL").String(),
|
|
Enabled: v.Get("active").Bool(),
|
|
})
|
|
}
|
|
|
|
return extensions, nil
|
|
}
|
|
|
|
func countExtensions(path string) (int, error) {
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
var count int
|
|
for _, v := range gjson.GetBytes(data, "addons").Array() {
|
|
if v.Get("location").String() == "app-profile" {
|
|
count++
|
|
}
|
|
}
|
|
return count, nil
|
|
}
|