mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
Later layers speak categories and records, and export needs nothing else. Ordering rows once in the exporter fixes Firefox history, written least visited first.
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package export
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/internal/record"
|
|
)
|
|
|
|
var sameSiteNone = "no_restriction"
|
|
|
|
func cookieEditorValue(r record.Record) any {
|
|
c, ok := r.(*record.Cookie)
|
|
if !ok {
|
|
return r
|
|
}
|
|
var expDate float64
|
|
if !c.ExpireAt.IsZero() {
|
|
expDate = float64(c.ExpireAt.Unix())
|
|
}
|
|
sameSite := &c.SameSite
|
|
switch c.SameSite {
|
|
case "none":
|
|
sameSite = &sameSiteNone
|
|
case "", "unspecified":
|
|
sameSite = nil
|
|
}
|
|
return cookieEditorEntry{
|
|
Domain: c.Host,
|
|
ExpirationDate: expDate,
|
|
HTTPOnly: c.IsHTTPOnly,
|
|
Name: c.Name,
|
|
Path: c.Path,
|
|
Secure: c.IsSecure,
|
|
Value: c.Value,
|
|
SameSite: sameSite,
|
|
Session: expDate == 0.,
|
|
HostOnly: !strings.HasPrefix(c.Host, "."),
|
|
}
|
|
}
|
|
|
|
// cookieEditorEntry matches the CookieEditor browser extension's import format.
|
|
type cookieEditorEntry struct {
|
|
Domain string `json:"domain"`
|
|
ExpirationDate float64 `json:"expirationDate,omitempty"`
|
|
HTTPOnly bool `json:"httpOnly"`
|
|
Name string `json:"name"`
|
|
Path string `json:"path"`
|
|
Secure bool `json:"secure"`
|
|
Value string `json:"value"`
|
|
SameSite *string `json:"sameSite"`
|
|
Session bool `json:"session"`
|
|
HostOnly bool `json:"hostOnly"`
|
|
}
|