您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
現在のブランチにおける CircleCI Workflows ページへのリンクを追加する
当前为
// ==UserScript== // @name Add CircleCI Workflows Link // @namespace https://github.com/matzkoh // @version 1.0.1 // @description 現在のブランチにおける CircleCI Workflows ページへのリンクを追加する // @author matzkoh // @include https://github.com/* // ==/UserScript== ;(function () { // ASSET: index.js var $Focm$exports = function () { var exports = this var module = { exports: this, } const rules = [ { // プルリク match: /([^/]+)\/(([^/]+))\/pull\//, getUserName(matches) { return matches[1] }, getRepoName(matches) { return matches[2] }, getBranchName() { return document.querySelector('.merge-pr-more-commits a').textContent }, insertButton(btn) { const sidebar = document.getElementById('partial-discussion-sidebar') const sidebarItem = document.createElement('div') sidebarItem.className = 'discussion-sidebar-item' const header = document.createElement('div') header.className = 'discussion-sidebar-heading text-bold' header.textContent = 'CircleCI' sidebarItem.appendChild(header) btn.classList.add('text-inherit') btn.classList.add('text-bold') btn.textContent = 'Workflows' sidebarItem.appendChild(btn) sidebar.insertBefore(sidebarItem, sidebar.firstChild) }, }, ] const { pathname: path } = location const rule = rules.find(({ match }) => match.test(path)) if (!rule) { return module.exports } const matches = path.match(rule.match) const userName = rule.getUserName(matches) const repoName = rule.getRepoName(matches) const branchName = rule.getBranchName(matches) const btn = document.createElement('a') btn.textContent = 'CircleCI Workflows' btn.href = `https://circleci.com/gh/${userName}/workflows/${repoName}/tree/${branchName}` btn.target = '_blank' btn.style.display = 'inline-block' btn.style.height = '20px' btn.style.lineHeight = '20px' btn.style.paddingLeft = '20px' btn.style.background = 'url("https://avatars0.githubusercontent.com/ml/7?s=16") left center no-repeat' rule.insertButton(btn) return module.exports }.call({}) if (typeof exports === 'object' && typeof module !== 'undefined') { // CommonJS module.exports = $Focm$exports } else if (typeof define === 'function' && define.amd) { // RequireJS define(function () { return $Focm$exports }) } })()