Advertisement
Guest User

nekto.me (autorestart and keyboard support).user.js

a guest
Jan 19th, 2022
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         nekto.me (autorestart and keyboard support)
  3. // @namespace    http://tampermonkey.net/
  4. // @version      1.9
  5. // @description  autorestart and keyboard support
  6. // @match        https://nekto.me/audiochat*
  7. // @author       Shitty Kitty#2366
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. //setTimeout(beginclick,5000);
  12. var autorestart = true;
  13. window.onload=function(){
  14. //если поставить слишком низкий интервал, то собеседник начинает лагать, 5000 - по умолчанию
  15.   setInterval(autoClick,3000);
  16.  
  17. }
  18.  
  19. /* window.setInterval( function() {
  20.      if (autorestart) {
  21.       if(document.getElementsByClassName("scan-button").length>0){
  22.           document.getElementsByClassName("scan-button")[0].click();
  23.       }
  24.   }
  25. }, 5000);
  26.  */
  27.  
  28.  
  29. //if(!$('#yourID').is(':visible'))
  30.  
  31.  
  32.  
  33.  
  34. function autoClick(){
  35.  
  36.   var testElement = document.getElementById('audio-chat-container');
  37.   if (autorestart) {
  38.  
  39.       if (testElement.classList.contains('state-idle') || testElement.classList.contains('state-hangup')) {
  40.  
  41.           var delayInMilliseconds = 0; //пауза, чтобы хватило время кинуть жалобу
  42.  
  43.           setTimeout(function() {
  44.               //your code to be executed after 1 second
  45.               if(document.getElementsByClassName("scan-button").length>0){
  46.                 document.getElementsByClassName("scan-button")[0].click();
  47.                 console.log("auto press scan-button");
  48.               }
  49.  
  50.               //your code to be executed after 1 second
  51.  
  52.  
  53.               if(document.getElementsByClassName("go-scan-button").length>0){
  54.                 document.getElementsByClassName("go-scan-button")[0].click();
  55.                   console.log("auto press go-scan-button");
  56.               }
  57.  
  58.  
  59.           }, delayInMilliseconds);
  60.  
  61.           //}
  62.       }
  63.  
  64.       else console.log("fail-idle");
  65.  
  66.   }
  67.  
  68.  
  69. }
  70.  
  71.  
  72. var KeyEvent        = (typeof KeyEvent === "object")  ?  KeyEvent  :  [];
  73. //const LEFT_KEY  = KeyEvent.DOM_VK_LEFT   ||  37;
  74. //const RIGHT_KEY = KeyEvent.DOM_VK_RIGHT  ||  39;
  75. const ESC_KEY = 27;
  76. const CapsLock_KEY = 20;
  77. const SPACE_KEY = 32;
  78. const ENTER_KEY = 13;
  79.  
  80. window.addEventListener ("keydown", keyboardHandler, false);
  81.  
  82. function keyboardHandler (zEvent) {
  83.     var bBlockDefaultAction = false;
  84.  
  85.     //--- Assume we want only the plain keys, not the modified versions.
  86.     if (zEvent.altKey || zEvent.ctrlKey || zEvent.shiftKey) {
  87.         //-- Do nothing (most user-friendly option, in most cases).
  88.     }
  89.     else {
  90.         if (zEvent.which == ESC_KEY || zEvent.which == SPACE_KEY || zEvent.which == ENTER_KEY || zEvent.which == CapsLock_KEY) {
  91.             //DO LEFT KEY ACTION HERE.
  92.             //document.getElementsByClassName('go-scan-button')[0].click();
  93.  
  94.             if(document.getElementsByClassName("go-scan-button").length>0){
  95.                 document.getElementsByClassName("go-scan-button")[0].click();
  96.                 console.log("press go-scan-button");
  97.             }
  98.             else console.log("can't press go-scan-button");
  99.  
  100.  
  101.             if(document.getElementsByClassName("stop-talk-button").length>0){ //<button type="button" class="btn btn-lg stop-talk-button">Завершить</button>
  102.                 document.getElementsByClassName("stop-talk-button")[0].click();
  103.                 console.log("press stop-talk-button");
  104.             }
  105.             else console.log("can't press stop-talk-button");
  106.  
  107.             if(document.getElementsByClassName("stop-scan-button").length>0){
  108.                 document.getElementsByClassName("stop-scan-button")[0].click();
  109.                 console.log("press stop-scan-button");
  110.             }
  111.             else console.log("can't press stop-scan-button");
  112.  
  113.             if(document.getElementsByClassName("scan-button").length>0){
  114.                 document.getElementsByClassName("scan-button")[0].click();
  115.                 console.log("press scan-button");
  116.             }
  117.             else console.log("can't press scan-button");
  118.  
  119.             bBlockDefaultAction = true;
  120.         }
  121.  
  122.     }
  123.  
  124.  
  125.     if (bBlockDefaultAction) {
  126.         zEvent.preventDefault ();
  127.         zEvent.stopPropagation ();
  128.     }
  129. }
  130.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement