-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss-l.html
More file actions
115 lines (92 loc) · 2.48 KB
/
Copy pathcss-l.html
File metadata and controls
115 lines (92 loc) · 2.48 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>LocalStorage Viewer</title>
<style>
body { font-family: system-ui; margin: 24px; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ccc; padding: 8px; text-align: left; }
td { word-break: break-all; }
button { margin: 4px; padding: 6px 10px; }
input { padding: 8px; width: 300px; }
</style>
</head>
<body>
<h1>LocalStorage Viewer</h1>
<input id="filter" placeholder="Filter keys or values...">
<button onclick="loadStorage()">Refresh</button>
<button onclick="exportStorage()">Export JSON</button>
<p id="count"></p>
<table>
<thead>
<tr>
<th>#</th>
<th>Key</th>
<th>Value</th>
<th>Action</th>
</tr>
</thead>
<tbody id="storage"></tbody>
</table>
<script>
function loadStorage() {
const tbody = document.getElementById("storage");
const filter = document.getElementById("filter").value.toLowerCase();
tbody.innerHTML = "";
let shown = 0;
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
const value = localStorage.getItem(key);
if (
!key.toLowerCase().includes(filter) &&
!value.toLowerCase().includes(filter)
) continue;
shown++;
const row = document.createElement("tr");
row.innerHTML = `
<td>${shown}</td>
<td></td>
<td></td>
<td>
<button>Copy</button>
<button>Delete</button>
</td>
`;
row.children[1].textContent = key;
row.children[2].textContent = value;
row.children[3].children[0].onclick = () =>
navigator.clipboard.writeText(value);
row.children[3].children[1].onclick = () => {
localStorage.removeItem(key);
loadStorage();
};
tbody.appendChild(row);
}
document.getElementById("count").textContent =
`${shown} item(s) shown — ${localStorage.length} total`;
}
function exportStorage() {
const data = {};
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
data[key] = localStorage.getItem(key);
}
const blob = new Blob(
[JSON.stringify(data, null, 2)],
{ type: "application/json" }
);
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "localStorage.json";
a.click();
URL.revokeObjectURL(url);
}
document
.getElementById("filter")
.addEventListener("input", loadStorage);
loadStorage();
</script>
</body>
</html>