HackBrowserData icon indicating copy to clipboard operation
HackBrowserData copied to clipboard

Feature Request: Optimize the logic of obtaining browser data.

Open moonD4rk opened this issue 5 months ago • 2 comments

Feature Description

The current way of obtaining browser data is to traverse the folder through filepath.walk, obtain the entire directory, and finally return the corresponding browser data type (item) and corresponding file path. This method has low efficiency and the data structure is not intuitive. This part needs to be optimized.

func chromiumWalkFunc(items []item.Item, multiItemPaths map[string]map[item.Item]string) filepath.WalkFunc {
	return func(path string, info fs.FileInfo, err error) error {
		for _, v := range items {
			if info.Name() != v.Filename() {
				continue
			}
			if strings.Contains(path, "System Profile") {
				continue
			}
			profileFolder := fileutil.ParentBaseDir(path)
			if strings.Contains(filepath.ToSlash(path), "/Network/Cookies") {
				profileFolder = fileutil.BaseDir(strings.ReplaceAll(filepath.ToSlash(path), "/Network/Cookies", ""))
			}
			if _, exist := multiItemPaths[profileFolder]; exist {
				multiItemPaths[profileFolder][v] = path
			} else {
				multiItemPaths[profileFolder] = map[item.Item]string{v: path}
			}
		}
		return err
	}
}

Why is this feature needed?

Improve code readability and increase file retrieval efficiency.

Checklist

Screenshots/Videos

If applicable, add screenshots or videos to help explain your proposal.

Additional Context

Add any other context or screenshots about the feature request here.

moonD4rk avatar Jan 30 '24 09:01 moonD4rk