SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         New Userscript
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Script pour ajouter un bouton KICK à côté des pseudos
  6. // @author       RogerduGhetto
  7. // @match        https://redsky.fr/
  8. // @grant        GM_addStyle
  9. // ==/UserScript==
  10.  
  11. class button {
  12.     constructor(pseudo, section) {
  13.         this.pseudo = pseudo;
  14.         this.button = document.createElement('button');
  15.         this.button.innerHTML = 'KICK';
  16.         this.button.id = this.pseudo;
  17.         this.button.classList.add('kick-button');
  18.         this.button.onclick = function onclick() {
  19.             kick(pseudo);
  20.         };
  21.         section.getElementsByClassName('skychat_user_profile_moto')[0].appendChild(this.button);
  22.     }
  23. }
  24.  
  25. async function kick(pseudo) {
  26.         await SkyWindow.client.sendMessage(`/kick ${pseudo}`);
  27.         console.log(`${pseudo} a été kické`)
  28.     }
  29.  
  30. async function createButtons() {
  31.     const connected = document.getElementsByClassName('skychat_pseudo_data');
  32.     for (let i = 0; i<=connected.length; i++) {
  33.         let section = connected[i];
  34.         let regex = new RegExp('profil\/([^\/]+)');
  35.         let pseudo = regex.exec(connected[i].innerHTML)[1];
  36.         new button(pseudo, section);
  37.     }
  38. }
  39.  
  40. (function() {
  41.     window.addEventListener('load', function() {
  42.         setInterval(function() {
  43.             let buttonsExists = document.getElementsByClassName('kick-button');
  44.             if (buttonsExists.length == 0){
  45.                 createButtons();
  46.             };
  47.             clearInterval(interval);
  48.         }, 50);
  49.     }, false);
  50.  
  51. })();
  52.  
  53. GM_addStyle('.kick-button { background-color : black; color: white; margin : 5px; border : none; border-radius : 20%;}');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top