Chrome 114 带着侧边栏扩展来了

效果展示

manifest.json

javascript 复制代码
{
  "manifest_version": 3,
  "name": "ChatGPT学习",
  "version": "0.0.2",
  "description": "ChatGPT,GPT-4,Claude3,Midjourney,Stable Diffusion,AI,人工智能,AI",
  "icons": {
    "16": "./src/images/logo.png",
    "48": "./src/images/logo.png",
    "128": "./src/images/logo.png"
  },
  "side_panel": {
    "default_path": "./src/views/panel.html",
    "openPanelOnActionClick": true
  },
  "permissions": ["sidePanel"],
  "action": {
    "default_title": "点击打开ChatGPT学习侧边栏"
  },
  "background": {
    "service_worker": "./src/scripts/service-worker.js"
  },
  "content_scripts": [
    {
      "matches": ["http://*/*", "https://*/*"],
      "exclude_matches": [
        "https://chat.xutongbao.top/*",
        "http://localhost:*/*"
      ],
      "css": ["./dist/lib/layui.css", "./dist/css/app.css"],
      "js": ["./dist/lib/layui.js", "./dist/js/app.js", "./index.js"]
    }
  ],
  "content_security_policy": {
    "extension_pages": "script-src 'self'; object-src 'self';"
  }
}

目录结构

src/scripts/service-worker.js

javascript 复制代码
chrome.sidePanel
  .setPanelBehavior({ openPanelOnActionClick: true })
  .catch((error) => console.error(error))

panel.html

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>ChatGPT学习</title>
  <link rel="stylesheet" href="./index.css">
</head>
<body>
  <iframe src="https://chat.xutongbao.top" class="m-side-panel-iframe"></iframe>
</body>
</html>

index.css

css 复制代码
body{position: absolute;top: 0;left: 0;right: 0;bottom: 0; margin: 0;padding: 0;overflow: hidden;}
.m-side-panel-iframe{width: 100%;height: 100%;border: 0;}

官方文档:

https://developer.chrome.com/docs/extensions/reference/api/sidePanel?hl=zh-cn#description

人工智能学习网站:

https://chat.xutongbao.top

相关推荐
步步为营DotNet1 小时前
深度解析CancellationToken:.NET中的优雅取消机制
java·前端·.net
一位搞嵌入式的 genius2 小时前
从 ES6 到 ESNext:JavaScript 现代语法全解析(含编译工具与实战)
前端·javascript·ecmascript·es6
linweidong4 小时前
C++ 模块化编程(Modules)在大规模系统中的实践难点?
linux·前端·c++
leobertlan8 小时前
2025年终总结
前端·后端·程序员
子兮曰8 小时前
OpenClaw架构揭秘:178k stars的个人AI助手如何用Gateway模式统一控制12+通讯频道
前端·javascript·github
百锦再9 小时前
Reactive编程入门:Project Reactor 深度指南
前端·javascript·python·react.js·django·前端框架·reactjs
莲华君9 小时前
React快速上手:从零到项目实战
前端·reactjs教程
百锦再9 小时前
React编程高级主题:测试代码
android·前端·javascript·react.js·前端框架·reactjs
易安说AI9 小时前
Ralph Loop 让Claude无止尽干活的牛马...
前端·后端
失忆爆表症11 小时前
05_UI 组件库集成指南:Shadcn/ui + Tailwind CSS v4
前端·css·ui