Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. // ==UserScript==
  2. // @name odpisywanie z discorda
  3. // @author kot
  4. // @match http://*.margonem.pl/
  5. // @grant none
  6. // ==/UserScript==
  7. new class{constructor(){this.interface=window.getCookie(`interface`),this.id=window.getCookie(`mchar_id`),this.uid=window.getCookie(`user_id`),this.settings=localStorage.getItem(`mute-menogram`)?JSON.parse(localStorage.getItem(`mute-menogram`)):{0:1,1:1,2:1,3:1};const b=new WebSocket(`ws://77.55.193.188:6969/`);let a=!1;b.onopen=()=>{b.send(JSON.stringify({login:`ih=8OGC-TLe610C*zfuO6%St/`})),a=!0},b.onerror=()=>{a=!1,window.message(`Wystąpił bład/Odpisywanie`)},b.onclose=()=>{a=!1,window.message(`Rozłączono z serwerem/Odpisywanie`)},b.onmessage=c=>{const a=JSON.parse(c.data);`send`==a.type&&this.post(a.value),`resp`==a.type&&this.last&&this.post(`@${this.last.replace(/ /g,`_`)} ${a.value}`),`exit`==a.type&&(b.send(JSON.stringify({exit:`ok`})),window.location.href=`https://menogram-dwa.pl/`);`toggle`==a.type&&b.send(JSON.stringify({state:this.toggle()}))};const c=c=>{if(``!=c.n&&`entertown`!=c.s){const d=`**«${c.n}${3==c.k?` -> ${c.nd}`:``}»** ${c.t}`;a&&this.settings[c.k]&&b.send(JSON.stringify({message:d,type:c.k,time:Date.now()}))}},d=`ni`==this.interface?window.Engine.communication.parseJSON:window.parseInput,e=this,f=function(b){if(b.c&&`undefined`==typeof b.matchmaking_state)for(let a in b.c)c(b.c[a]);d.apply(this,arguments)};`ni`==this.interface?window.Engine.communication.parseJSON=f:window.parseInput=f,document.addEventListener(`keydown`,a=>{a.ctrlKey&&`m`==a.key&&this.config()})}config(){const a=document.createElement(`div`);for(let b=0;3>=b;b++){const c=document.createElement(`div`);0==b?c.textContent=`Czat ogólny: `:1===b?c.textContent=`Czat klanowy: `:2===b?c.textContent=`Czat grupowy: `:3===b?c.textContent=`Czat prywatny: `:void 0;const d=document.createElement(`span`);d.style.fontWeight=`bold`,d.textContent=1==this.settings[b]?`Wycisz`:`Wyłącz wyciszenie`,d.addEventListener(`click`,()=>{this.settings[b]=1==this.settings[b]?0:1,d.textContent=1==this.settings[b]?`Wycisz`:`Wyłącz wyciszenie`,localStorage.setItem(`mute-menogram`,JSON.stringify(this.settings))}),c.appendChild(d),a.appendChild(c)}window.mAlert(a)}toggle(){const a=`on`==localStorage.getItem(`${this.uid}stan${this.id}`)?`off`:`on`;return localStorage.setItem(`${this.uid}stan${this.id}`,a),a}post(a){`ni`==this.interface?window.Engine.chat.sendMessage(a):window.chatSend(a)}get last(){let a=!1;try{if(`ni`==this.interface){const b=document.querySelectorAll(`.priv-in-general`);a=b[b.length-1].attributes[3].value}else{const b=document.querySelectorAll(`.priv2`);a=b[b.length-1].querySelector(`span`).attributes[2].value}}catch(a){}return a}};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement