-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage.go
31 lines (25 loc) · 862 Bytes
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package chrome
import (
"context"
"github.com/chromedp/cdproto/domstorage"
"github.com/chromedp/chromedp"
)
func SetStorageItem(ctx context.Context, storageID *domstorage.StorageID, key, value string) error {
return chromedp.Run(ctx, domstorage.SetDOMStorageItem(storageID, key, value))
}
func StorageItems(ctx context.Context, storageID *domstorage.StorageID) (res []domstorage.Item, err error) {
err = chromedp.Run(
ctx,
chromedp.ActionFunc(func(ctx context.Context) (err error) {
res, err = domstorage.GetDOMStorageItems(storageID).Do(ctx)
return
}),
)
return
}
func (c *Chrome) SetStorageItem(storageID *domstorage.StorageID, key, value string) error {
return SetStorageItem(c, storageID, key, value)
}
func (c *Chrome) StorageItems(storageID *domstorage.StorageID) ([]domstorage.Item, error) {
return StorageItems(c, storageID)
}