TutorDBOps Helper

try to improve TutorDBOps

目前为 2021-09-24 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name TutorDBOps Helper
  3. // @namespace http://tpdbops.tutorabc.com/
  4. // @version 0.1
  5. // @description try to improve TutorDBOps
  6. // @author Tex
  7. // @match http://tpdbops.tutorabc.com/mysqlmanage/*
  8. // @icon https://www.google.com/s2/favicons?domain=tutorabc.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. function GM_addStyle(css) {
  14. const style = document.getElementById("GM_addStyleBy8626") || (function() {
  15. const style = document.createElement('style');
  16. style.type = 'text/css';
  17. style.id = "GM_addStyleBy8626";
  18. document.head.appendChild(style);
  19. return style;
  20. })();
  21. const sheet = style.sheet;
  22. sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
  23. }
  24.  
  25. GM_addStyle(`
  26. * {
  27. font-family: Consolas;
  28. font-weight: bold;
  29. font-size: 14px;
  30. }
  31. `);
  32.  
  33. let showLeftArea = true;
  34. function toggleRightArea () {
  35. // toggle state
  36. showLeftArea = !showLeftArea;
  37.  
  38. // hide sidebar
  39. const sidebar = document.querySelector("#container > aside");
  40. sidebar.style.width = showLeftArea? '230px' : '0px';
  41. sidebar.style.opacity = showLeftArea? '1' : '0';
  42. sidebar.style['z-index'] = showLeftArea? 'unset' : '-1';
  43.  
  44. // remove right area margin left
  45. const rightblock = document.querySelector("#container > section");
  46. rightblock.style['margin-left'] = showLeftArea ? '230px':'0px';
  47.  
  48.  
  49. }
  50.  
  51. function submitSql() {
  52. const searchBtn = document.getElementById("search");
  53. searchBtn.click();
  54. }
  55.  
  56. // autofocus sql textarea
  57. const sqlTextArea = document.querySelector("form > table > tbody > tr > td:nth-child(1) > div > div > textarea");
  58. sqlTextArea.focus();
  59.  
  60. // enroll events
  61. document.onkeydown = function(e) {
  62. if(e.code === 'Enter' && e.ctrlKey) {
  63. submitSql();
  64. }
  65. if(e.code === 'KeyB' && e.ctrlKey) {
  66. toggleRightArea();
  67. }
  68. }
  69. })();