Simplify Costco browser header extraction
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import configparser
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import sqlite3
|
||||
@@ -104,6 +105,45 @@ def read_firefox_storage_entries(profile_dir, origin_filters):
|
||||
return deduped
|
||||
|
||||
|
||||
def storage_entries_for_origin(storage_entries, origin_filters):
|
||||
return [
|
||||
entry
|
||||
for entry in storage_entries
|
||||
if origin_matches(entry.origin, origin_filters)
|
||||
]
|
||||
|
||||
|
||||
def find_storage_value(storage_entries, origin_filters, key):
|
||||
for entry in storage_entries_for_origin(storage_entries, origin_filters):
|
||||
if entry.key == key:
|
||||
return entry.value
|
||||
return ""
|
||||
|
||||
|
||||
def find_json_storage_value(storage_entries, origin_filters, key, field):
|
||||
raw_value = find_storage_value(storage_entries, origin_filters, key)
|
||||
if not raw_value:
|
||||
return ""
|
||||
try:
|
||||
payload = json.loads(raw_value)
|
||||
except json.JSONDecodeError:
|
||||
return ""
|
||||
value = payload.get(field, "")
|
||||
if value is None:
|
||||
return ""
|
||||
return str(value)
|
||||
|
||||
|
||||
def list_storage_keys(storage_entries, origin_filters):
|
||||
return sorted(
|
||||
{
|
||||
entry.key
|
||||
for entry in storage_entries_for_origin(storage_entries, origin_filters)
|
||||
if entry.key
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def read_firefox_ls_entries(profile_dir, origin_filters):
|
||||
entries = []
|
||||
storage_root = profile_dir / "storage" / "default"
|
||||
|
||||
Reference in New Issue
Block a user