fixed github wiki sidebar

固定GitHub wiki 页面的sidebar 方便阅读跳转

  1. // ==UserScript==
  2. // @name fixed github wiki sidebar
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-06-01
  5. // @description 固定GitHub wiki 页面的sidebar 方便阅读跳转
  6. // @author Mrxn
  7. // @homepage https://mrxn.net/
  8. // @match https://github.com/*/wiki/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  10. // @icon https://github.githubassets.com/favicons/favicon.png
  11. // @license MIT
  12. // @run-at document-end
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. // Your code here...
  20. document.addEventListener("scroll", function() {
  21. var sidebar = document.querySelector("#wiki-content > div > div.Layout-sidebar");
  22.  
  23. if (sidebar) {
  24. sidebar.style.position = "fixed";
  25. sidebar.style.top = "1px";
  26. sidebar.style.right = "0px";
  27. sidebar.style.width = "300px";
  28. sidebar.style.height = "100%";
  29. sidebar.style.overflowY = "auto";
  30. }
  31. });
  32. })();