-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
38 lines (30 loc) · 1.25 KB
/
content.js
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
window.addEventListener('load', function() {
let images = document.querySelectorAll('img');
console.log('Found images:', images.length); // Log the number of images found
images.forEach((img, index) => {
let checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.className = 'image-checkbox';
checkbox.dataset.index = index; // Assign dataset index
checkbox.style.cssText = `
position: absolute;
top: 10px;
right: 10px;
z-index: 1000;
background: white;
border: 2px solid black;
cursor: pointer;
`;
checkbox.addEventListener('click', function(event) {
event.stopPropagation(); // Prevent other click handlers from interfering
});
img.parentElement.style.position = 'relative';
img.parentElement.appendChild(checkbox);
console.log('Checkbox added for image:', img.src); // Log each image URL with a checkbox
});
document.querySelectorAll('.image-checkbox').forEach((checkbox) => {
checkbox.addEventListener('change', function() {
console.log('Checkbox state changed:', checkbox.checked);
});
});
});