swarmsim cheatsheet left menu

swarmsim cheatsheet left menu! god!

  1. // ==UserScript==
  2. // @name swarmsim cheatsheet left menu
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-12-24
  5. // @description swarmsim cheatsheet left menu! god!
  6. // @author imzhi <yxz_blue@126.com>
  7. // @match https://static.oschina.net/trytry/swarmsim/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=oschina.net
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. document.addEventListener('keydown', function(event) {
  16. if (event.key === 'p') {
  17. event.preventDefault();
  18. // 如果需要的话,可以在这里实现你的逻辑
  19. document.querySelectorAll(`.tab-pane.active .table > tbody > tr`)[curr_act()+1].click()
  20. }
  21. });
  22.  
  23. function curr_act() {
  24. const tr_multi = document.querySelectorAll(`.tab-pane.active .table > tbody > tr`)
  25. const index_act = 0
  26. for (const [tr_key, tr_item] of Object.entries(tr_multi)) {
  27. console.log('tr_multi', tr_key, tr_item, tr_item.className)
  28. if (tr_multi.className && tr_multi.className.includes('active')) {
  29. index_act = tr_key
  30. break
  31. }
  32. }
  33. return index_act
  34. }
  35. })();