GitHub Issue Link Status 项目教程

GitHub Issue Link Status 项目教程

github-issue-link-statusColorize issue and PR links to see their status (open, closed, merged)项目地址:https://gitcode.com/gh_mirrors/gi/github-issue-link-status

1、项目的目录结构及介绍

github-issue-link-status/
├── LICENSE
├── README.md
├── background.js
├── content.js
├── manifest.json
├── options.html
├── options.js
└── icons/
    ├── icon128.png
    ├── icon16.png
    ├── icon19.png
    └── icon48.png
  • LICENSE: 项目的许可证文件。
  • README.md: 项目的说明文档。
  • background.js: 扩展的后台脚本。
  • content.js: 注入到网页的内容脚本。
  • manifest.json: 扩展的清单文件,包含扩展的配置信息。
  • options.html: 扩展的选项页面。
  • options.js: 选项页面的脚本。
  • icons/: 扩展的图标文件夹,包含不同尺寸的图标。

2、项目的启动文件介绍

项目的启动文件主要是 manifest.json,它定义了扩展的基本信息和启动配置。以下是 manifest.json 的主要内容:

{
  "manifest_version": 2,
  "name": "GitHub Issue Link Status",
  "version": "1.0",
  "description": "Colorize issue and PR links to see their status (open, closed, merged)",
  "permissions": [
    "https://api.github.com/*",
    "storage"
  ],
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },
  "content_scripts": [
    {
      "matches": ["https://github.com/*"],
      "js": ["content.js"]
    }
  ],
  "options_ui": {
    "page": "options.html",
    "open_in_tab": true
  },
  "icons": {
    "16": "icons/icon16.png",
    "48": "icons/icon48.png",
    "128": "icons/icon128.png"
  }
}
  • manifest_version: 清单文件的版本,目前为2。
  • name: 扩展的名称。
  • version: 扩展的版本号。
  • description: 扩展的描述。
  • permissions: 扩展所需的权限,包括GitHub API和存储权限。
  • background: 后台脚本的配置。
  • content_scripts: 内容脚本的配置,指定在哪些页面注入脚本。
  • options_ui: 选项页面的配置。
  • icons: 扩展的图标配置。

3、项目的配置文件介绍

项目的配置文件主要是 options.htmloptions.js,它们用于设置和保存用户的API令牌。

options.html

<!DOCTYPE html>
<html>
<head>
  <title>GitHub Issue Link Status Options</title>
  <style>
    body { font-family: Arial, sans-serif; }
    .container { margin: 20px; }
  </style>
</head>
<body>
  <div class="container">
    <h1>GitHub Issue Link Status Options</h1>
    <label for="apiToken">GitHub API Token:</label>
    <input type="text" id="apiToken" name="apiToken">
    <button id="save">Save</button>
    <p id="status"></p>
  </div>
  <script src="options.js"></script>
</body>
</html>

options.js

document.getElementById('save').addEventListener('click', function() {
  const apiToken = document.getElementById('apiToken').value;
  chrome.storage.sync.set({ apiToken: apiToken }, function() {
    document.getElementById('status').textContent = 'Options saved.';
  });
});

chrome.storage.sync.get('apiToken', function(data) {
  if (data.apiToken) {
    document.getElementById('apiToken').value = data.apiToken;
  }
});
  • options.html: 提供一个输入框用于输入GitHub API令牌,并有一个保存按钮。
  • options.js: 处理保存按钮的点击事件,

github-issue-link-statusColorize issue and PR links to see their status (open, closed, merged)项目地址:https://gitcode.com/gh_mirrors/gi/github-issue-link-status

  • 14
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陆骊咪Durwin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值