批量打开网站
这只是一个示例, 起到抛砖引玉的作用
javascript: (function () {
const websites = [
{ name: 'baidu', url: 'https://www.baidu.com' },
{ name: 'google', url: 'https://www.google.com' },
// 添加更多网站链接
];
const popupContainer = document.createElement('div');
popupContainer.style.position = 'fixed';
popupContainer.style.top = '50%';
popupContainer.style.left = '50%';
popupContainer.style.transform = 'translate(-50%, -50%)';
popupContainer.style.background = '#fff';
popupContainer.style.padding = '20px';
popupContainer.style.border = '2px solid #ccc';
popupContainer.style.borderRadius = '8px';
popupContainer.style.zIndex = '9999';
const ulElement = document.createElement('ul');
ulElement.style.listStyleType = 'none';
ulElement.style.paddingLeft = '0';
websites.forEach((site, index) => {
const liElement = document.createElement('li');
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.id = `site_${index}`;
checkbox.value = site.url;
const label = document.createElement('label');
label.setAttribute('for', `site_${index}`);
label.textContent = site.name;
liElement.appendChild(checkbox);
liElement.appendChild(label);
ulElement.appendChild(liElement);
});
const buttonElement = document.createElement('button');
buttonElement.textContent = 'Open Selected';
buttonElement.id = 'openSelectedBtn';
popupContainer.appendChild(ulElement);
popupContainer.appendChild(buttonElement);
document.body.appendChild(popupContainer);
buttonElement.addEventListener('click', function () {
const checkboxes = document.querySelectorAll(
'input[type="checkbox"]:checked'
);
checkboxes.forEach((checkbox) => {
const url = checkbox.value;
window.open(url, '_blank');
});
document.body.removeChild(popupContainer);
});
})();
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
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
上次更新: 2025/10/09, 23:53:03