Jacky's blog
首页
  • 学习笔记

    • web
    • android
    • iOS
    • vue
  • 分类
  • 标签
  • 归档
收藏
  • tool
  • algo
  • python
  • java
  • server
  • growth
  • frida
  • blog
  • SP
  • more
GitHub (opens new window)

Jack Yang

编程; 随笔
首页
  • 学习笔记

    • web
    • android
    • iOS
    • vue
  • 分类
  • 标签
  • 归档
收藏
  • tool
  • algo
  • python
  • java
  • server
  • growth
  • frida
  • blog
  • SP
  • more
GitHub (opens new window)
  • web
  • web concept
  • javascript

  • css

  • vue

  • react

  • nextjs

  • module

  • web faq
  • web3

  • more

    • 一行代码"黑"掉任意网站
    • 批量打开网站
    • 启动express服务
    • nodejs中的http请求
    • blob url
    • php
    • session and cookie
    • prettier
  • 《web》
  • more
Jacky
2024-03-29

批量打开网站

这只是一个示例, 起到抛砖引玉的作用

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
上次更新: 2025/10/09, 23:53:03
一行代码"黑"掉任意网站
启动express服务

← 一行代码"黑"掉任意网站 启动express服务→

最近更新
01
npx 使用指南
10-12
02
cursor
09-28
03
inspect
07-20
更多文章>
Theme by Vdoing | Copyright © 2019-2025 Jacky | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式