-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-random-pages-filter.html
More file actions
54 lines (46 loc) · 1.84 KB
/
test-random-pages-filter.html
File metadata and controls
54 lines (46 loc) · 1.84 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
<!DOCTYPE html>
<html>
<head>
<title>Test Random Pages Filter</title>
</head>
<body>
<h1>Random Pages Filter Test</h1>
<div>
<h2>Test localStorage initialization</h2>
<button onclick="setNotMineFilter(true)">Set "Not mine" to ON</button>
<button onclick="setNotMineFilter(false)">Set "Not mine" to OFF</button>
<button onclick="checkFilter()">Check current filter</button>
<button onclick="clearFilter()">Clear filter</button>
</div>
<div id="result"></div>
<script>
function setNotMineFilter(value) {
localStorage.setItem('randomPages_excludeOwnPages', String(value));
document.getElementById('result').innerHTML = `Set excludeOwnPages to: ${value}`;
}
function checkFilter() {
const value = localStorage.getItem('randomPages_excludeOwnPages') === 'true';
document.getElementById('result').innerHTML = `Current excludeOwnPages: ${value}`;
}
function clearFilter() {
localStorage.removeItem('randomPages_excludeOwnPages');
document.getElementById('result').innerHTML = 'Filter cleared';
}
// Test the initialization logic
function testInitialization() {
const excludeOwnPages = (() => {
if (typeof window !== 'undefined') {
return localStorage.getItem('randomPages_excludeOwnPages') === 'true';
}
return false;
})();
return excludeOwnPages;
}
// Run test on page load
window.onload = function() {
const result = testInitialization();
document.getElementById('result').innerHTML = `Initial excludeOwnPages value: ${result}`;
};
</script>
</body>
</html>