Github open link

增加在线预览代码按钮

  1. // ==UserScript==
  2. // @name Github open link
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 增加在线预览代码按钮
  6. // @author You
  7. // @match https://github.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. const ul = document.querySelector('.pagehead-actions')
  16.  
  17. const button = document.createElement('li')
  18. const a = document.createElement('A')
  19. a.setAttribute('href', document.location.href.replace('github.com', 'github.dev'))
  20. a.setAttribute('target', '_blank')
  21. a.setAttribute('class', 'btn btn-sm')
  22. a.innerText = 'OpenDev'
  23. button.appendChild(a)
  24.  
  25. ul.prepend(button)
  26. // Your code here...
  27. })();