{"id":24772369,"url":"https://github.com/ziyi2/chrome-plugins-demo","last_synced_at":"2025-06-21T21:07:25.550Z","repository":{"id":98890081,"uuid":"86653948","full_name":"ziyi2/chrome-plugins-demo","owner":"ziyi2","description":null,"archived":false,"fork":false,"pushed_at":"2017-03-30T12:46:01.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T20:34:26.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ziyi2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-30T03:18:05.000Z","updated_at":"2017-03-30T06:37:37.000Z","dependencies_parsed_at":"2023-03-05T01:30:31.022Z","dependency_job_id":null,"html_url":"https://github.com/ziyi2/chrome-plugins-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ziyi2/chrome-plugins-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziyi2%2Fchrome-plugins-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziyi2%2Fchrome-plugins-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziyi2%2Fchrome-plugins-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziyi2%2Fchrome-plugins-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ziyi2","download_url":"https://codeload.github.com/ziyi2/chrome-plugins-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziyi2%2Fchrome-plugins-demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261193127,"owners_count":23122909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-29T04:01:49.976Z","updated_at":"2025-06-21T21:07:20.527Z","avatar_url":"https://github.com/ziyi2.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chrome-plugins-demo\n\n## 注意\n1.manifest.json -\u003e content_scripts -\u003e　run_at选项　\n- document_start 文件将在所有CSS加载完毕，但是没有创建DOM并且没有运行任何脚本的时候注入。\n- document_end 文件将在创建完DOM之后，但还没有加载类似于图片或frame等的子资源前立刻注入。\n- document_idle 浏览器会在document_end和发出window.onload事件之间的某个时机注入。具体的时机取决与文档加载的复杂度，为加快页面加载而优化。\n\n2. 谷歌大部分API不支持在content_scripts运行\n3. 存储\n- content_scripts读取的localStorage和当前需要注入的页面共享数据,而不是和background读写所在域的localStorage\n- 可以通过Chrome存储API(content_scripts和background共享数据)或者扩展页面间的通信runtime.sendMessage解决\n- Chrome存储API读写速度更快\n- 选项页面的设置存储可以优先选用localStorage(localStorage不能跨域存储)\n4. popup页面的Js变量\n- 只有在用户点击扩展应用时JavaScript都是重新开始运行的,因此不要指望保存全局变量,而是应该通过localStorage存储.\n5. 几种Js的区别\n- content_scripts的Js 和显示的页面有关系,可以对显示页面的DOM进行修改(background不行)\n- popup页面的Js 只有点击扩展应用时才会执行\n- background域的Js 常驻后台,浏览器启动后自动执行\n\n\n\n## 工具\n - [Closure Compiler](https://github.com/google/closure-compiler-js)\n 代码压缩,高性能优化,可以使用Webpack.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziyi2%2Fchrome-plugins-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fziyi2%2Fchrome-plugins-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziyi2%2Fchrome-plugins-demo/lists"}