mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-10-13 03:37:12 +02:00
feat: add CountEntries to skip decryption for list --detail (#562)
* 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
This commit is contained in:
1 parent
5f42d4fe5f
commit
b3bbc0dadf
40 files changed
+1009
-101
No files matched your search
@@ -51,3 +51,32 @@ func walkBookmarks(node gjson.Result, folder string, out *[]types.BookmarkEntry)
|
||||
walkBookmarks(child, currentFolder, out)
|
||||
}
|
||||
}
|
||||
|
||||
func countBookmarks(path string) (int, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var count int
|
||||
roots := gjson.GetBytes(data, "roots")
|
||||
roots.ForEach(func(_, value gjson.Result) bool {
|
||||
count += walkCountBookmarks(value)
|
||||
return true
|
||||
})
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// walkCountBookmarks recursively counts URL nodes in the bookmark tree.
|
||||
func walkCountBookmarks(node gjson.Result) int {
|
||||
count := 0
|
||||
if node.Get("type").String() == "url" {
|
||||
count++
|
||||
}
|
||||
children := node.Get("children")
|
||||
if children.Exists() && children.IsArray() {
|
||||
for _, child := range children.Array() {
|
||||
count += walkCountBookmarks(child)
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
Reference in new issue
Block a user