Github按文件更新日期排序

Github按文件更新日期排序...

目前為 2024-04-15 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Github按文件更新日期排序
  3. // @namespace https://github.com/androidcn/
  4. // @version 1.1
  5. // @description Github按文件更新日期排序...
  6. // @author @Androidcn
  7. // @match https://github.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @grant none
  10.  
  11. // ==/UserScript==
  12. (function() {
  13. 'use strict';
  14.  
  15. function createButton() {
  16. // Create a button element
  17. const button = document.createElement('button');
  18. button.textContent = '排序';
  19. button.style.position = 'fixed';
  20. button.style.top = '60px';
  21. button.style.right = '20px';
  22. button.style.zIndex = '9999';
  23.  
  24. // Append the button to the body
  25. document.body.appendChild(button);
  26.  
  27. // Add click event listener to the button
  28. button.addEventListener('click', performSortedAction);
  29. }
  30.  
  31. function performSortedAction() {
  32.  
  33. var files = document.querySelector('[aria-labelledby="folders-and-files"] tbody');
  34. var children = [...files.children];
  35. files.replaceChildren(
  36. children[0],...[...files.querySelectorAll('.react-directory-row')].sort((a, b) => new Date(a.querySelector('relative-time').datetime) < new Date(b.querySelector('relative-time').datetime) ? 1 : -1),children.at(-1),
  37. );
  38. console.log('已按文件更新日期排序');
  39. }
  40.  
  41. // Wait for the page to load
  42. window.addEventListener('load', createButton);
  43. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址