Jacky's blog
首页
  • Android
  • Web
  • Server
  • Python
  • iOS
  • Java
  • Vue
  • 计算机基础
  • AI
  • 全部工具
  • CLI 工具
  • 编辑器
  • 开发工具
  • 构建工具
  • 版本控制
  • 调试工具
  • 网络工具
  • 个人成长
  • 博客
  • 分类
  • 标签
  • 归档
收藏
GitHub (opens new window)

Jack Yang

编程; 随笔
首页
  • Android
  • Web
  • Server
  • Python
  • iOS
  • Java
  • Vue
  • 计算机基础
  • AI
  • 全部工具
  • CLI 工具
  • 编辑器
  • 开发工具
  • 构建工具
  • 版本控制
  • 调试工具
  • 网络工具
  • 个人成长
  • 博客
  • 分类
  • 标签
  • 归档
收藏
GitHub (opens new window)
  • web
  • 工具

  • JavaScript

  • CSS

  • Vue

  • React

  • Next.js

  • 模块化

  • web faq
  • Web3

  • 更多

    • typescript
    • 批量打开网站
    • 启动express服务
    • nodejs中的http请求
    • blob url
    • php
    • prettier
    • electron
    • animation
    • 一行代码"黑"掉任意网站
    • Atom 状态管理
  • web concept
  • 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
#Web
上次更新: 2026/10/18, 22:14:48
typescript
启动express服务

← typescript 启动express服务→

最近更新
01
Codex 使用与会话管理指南
10-17
02
Tailscale 入门:让自己的设备跨网络互联
10-15
03
GitHub CLI(gh)工作流与 CI 排查
10-08
更多文章>
Theme by Vdoing | Copyright © 2019-2026 Jacky | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式