File size: 1,172 Bytes
2fbf461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html>
<head>
    <script src="background.js"></script>
</head>
<body>
    <h3>Welcome to SafeBrowse</h3>
    <form id="categoryForm">
        <label for="violent"><input type="checkbox" id="violent" name="categories" value="violent"> Violent</label>
        <br>
        <label for="sexually_explicit"><input type="checkbox" id="sexually_explicit" name="categories" value="sexually_explicit"> Sexually explicit</label>
        <br>
        <input type="submit" value="Submit">
    </form>

    <script>
        document.getElementById('categoryForm').addEventListener('submit', function (e) {
            e.preventDefault(); // Prevent the default form submission
            const selectedCategories = [];
            const checkboxes = document.getElementsByName('categories');

            for (let i = 0; i < checkboxes.length; i++) {
                if (checkboxes[i].checked) {
                    selectedCategories.push(checkboxes[i].value);
                }
            }

            // Store the selectedCategories array in a global variable
            window.selectedCategories = selectedCategories;
        });
    </script>
</body>
</html>