Advertisement
Igor150195

asd

Apr 15th, 2024
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Shortcut Tracker
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Tracks Ctrl \ key combination on https://app.lepota.site/ and toggles styles
  6. // @author       Your Name
  7. // @match        https://app.lepota.site/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     var ctrlPressed = false;
  15.     var cmdPressed = false;
  16.  
  17.     // Добавляем стили
  18.     var style = document.createElement('style');
  19.     style.innerHTML = `
  20.     .ant-layout-content.hide aside {
  21.         opacity: 0;
  22.         pointer-events: none;
  23.     }
  24.     .ant-layout-content.hide {
  25.         pointer-events: none;
  26.     }
  27.     .ant-layout-content.hide div[class^=styled__ZoomButtonsWrapper] {
  28.         opacity: 0;
  29.         pointer-events: none;
  30.     }
  31.     `;
  32.     document.head.appendChild(style);
  33.  
  34.     document.addEventListener('keydown', function(event) {
  35.         if (event.ctrlKey && event.key === "\\") {
  36.             ctrlPressed = true;
  37.         }
  38.         if (event.metaKey && event.key === "/") { // Для макбуков Cmd + /
  39.             cmdPressed = true;
  40.         }
  41.     });
  42.  
  43.     document.addEventListener('keyup', function(event) {
  44.         if( window.location.pathname.match('editor') ){
  45.             if ((ctrlPressed && event.key === "\\") || (cmdPressed && event.key === "/")) {
  46.                 ctrlPressed = false;
  47.                 cmdPressed = false;
  48.                 toggleStyles();
  49.             }
  50.         }
  51.     });
  52.  
  53.     function toggleStyles() {
  54.         var layoutContent = document.querySelector('.ant-layout-content');
  55.         if (layoutContent) {
  56.             layoutContent.classList.toggle('hide');
  57.         }
  58.     }
  59. })();
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement