一键跳转到github的dev编辑器页面

一键跳转到github的dev编辑器页面!

目前为 2022-03-31 提交的版本。查看 最新版本

// ==UserScript==
// @name         一键跳转到github的dev编辑器页面
// @namespace    https://github.com/xxxily
// @homepage     https://github.com/xxxily
// @version      0.0.1
// @description  一键跳转到github的dev编辑器页面!
// @author       xxxily
// @match        https://github.com/*
// @run-at       document-end
// @license      MIT
// ==/UserScript==

if(!document.getElementById('goToDev')){
  const devBtn = document.createElement("a")
  devBtn.innerText = "Go to Dev"
  devBtn.id = "goToDev"
  devBtn.target = "_blank"
  devBtn.href = window.location.href.replace("github.com", "github.dev")

  const btns = document.querySelectorAll("a.btn")
  btns.forEach(btn => {
    if(btn.innerText === "Go to file"){
      devBtn.className = btn.className
      btn.parentNode.insertBefore(devBtn, btn)
    }
  })
}