Greasy Fork 还支持 简体中文。

Qmetry - Add new step

try to take over the world!

  1. // ==UserScript==
  2. // @name Qmetry - Add new step
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://testmanagement.qmetry.com/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. $(document).keypress(function(e) {
  15. console.log(e.which);
  16. if (e.ctrlKey && e.which == 13) {
  17. newStep();
  18. }else if (e.which == 105) {
  19. enterEditMode();
  20. }
  21. })
  22. // Your code here...
  23. })();
  24.  
  25.  
  26. function newStep(){
  27. var isOpen = $('.fa.fa-plus.pointer.text-primary').attr('aria-expanded') === 'true';
  28.  
  29. if (isOpen) {
  30. $('.pointer.dropdown-item').get(0).dispatchEvent(new Event('click'));
  31. } else {
  32. $('.fa.fa-plus.pointer.text-primary').get(0).dispatchEvent(new Event('click'));
  33. setTimeout(function() {
  34. $('.pointer.dropdown-item').get(0).dispatchEvent(new Event('click'));
  35. }, 0);
  36. }
  37. }
  38.  
  39. function enterEditMode(){
  40. var editButton = $("#page-wrapper > div > detailview > div.ibox > div > div > div > div > div > div.ibox-content.no-space.child.standalone > section:nth-child(9) > form > steps > div.p-b.m-t > div.p-xs.table > div.cell.text-right > div > button:nth-child(1)").get(0);
  41. console.log($(editButton).attr("disabled"));
  42. if($(editButton).attr("disabled") ==null || $(editButton).attr("disabled") != 'disabled' ){
  43. editButton.dispatchEvent(new Event('click'));
  44. }
  45. }