// ==UserScript== // @name Skribbl.io Auto Drawing Downloader // @namespace http://tampermonkey.net/ // @version 1.2 // @description type shit // @author ZStrike // @match *://skribbl.io/* // @license GPL // @grant none // @source https://git.zstrike.dev/zstrike/skribbl-autosave // @run-at document-start // ==/UserScript== !function(){"use strict";class t{constructor(){null==window.localStorage.getItem("autodl_config")?this.conf={toggle:"1",format:"png",version:"1.2"}:this.conf=JSON.parse(window.localStorage.getItem("autodl_config")),this.toggElm=document.querySelector("#select-autodl_toggle"),this.formElm=document.querySelector("#select-autodl_format"),this.toggElm.value=this.conf.toggle,this.formElm.value=this.conf.format,this.toggElm.onchange,this.formElm.onchange=this.update}update=()=>{this.conf.toggle=this.toggElm.value,this.conf.format=this.formElm.value,localStorage.setItem("autodl_config",JSON.stringify(this.conf))}}function o(){const t=document.querySelector("canvas");if(t)try{const o=t.captureStream(10);d=new MediaRecorder(o,{mimeType:"video/webm"}),c=[],d.ondataavailable=function(t){t.data.size>0&&c.push(t.data)},d.start(),console.log("[Hook] Recording started...")}catch(t){console.error("[Hook] Error starting recording:",t)}else console.warn("Canvas not found, can't start recording")}window.addEventListener("DOMContentLoaded",o=>{document.querySelector(".modal-container-settings").innerHTML+='
Auto-Downloader
Feature Toggle
Download Type
',window.autodlconfig=new t;for(const t of document.querySelectorAll('[class^="select-autodl_"]'))t.onchange=window.autodlconfig.update});const e=window.WebSocket,a=new Map;let n=null,d=null,c=[];window.WebSocket=function(...t){const i=new e(...t);return i.addEventListener("message",function(t){var e;if("string"==typeof t.data&&t.data.startsWith("42"))try{const i=JSON.parse(t.data.slice(2));if("data"===i[0]){const t=i[1];if(10===t.id){a.clear();const e=t.data.users;Array.isArray(e)&&e.forEach(t=>{a.set(t.id,t.name)});const d=t.data.state;d&&4===d.id&&(n=d.data.id,1==window.autodlconfig.conf.toggle&&"webm"==window.autodlconfig.conf.format&&o())}if(1===t.id&&a.set(t.data.id,t.data.name),11===t.id){const i=t.data;if(i&&4===i.id&&(n=i.data.id,1==window.autodlconfig.conf.toggle&&"webm"==window.autodlconfig.conf.format&&o()),i&&5===i.id){const t=i.data,o=a.get(n)||"Unknown Player";console.log(`Drawer: ${o} (ID: ${n})`),console.log("Word:",t.word),1==window.autodlconfig.conf.toggle&&("png"==window.autodlconfig.conf.format?document.querySelector("canvas").toBlob(e=>{!function(t,o){const e=document.createElement("a");e.id="autodl-trigger",e.style.display="none",e.href=URL.createObjectURL(t),e.download=o,document.body.appendChild(e),e.click(),e.remove()}(e,`${t.word} by ${o}`)}):(e=`${t.word} by ${o}.webm`,d&&"inactive"!==d.state&&(d.onstop=function(){const t=new Blob(c,{type:"video/webm"}),o=URL.createObjectURL(t),a=document.createElement("a");a.style.display="none",a.href=o,a.download=e,document.body.appendChild(a),a.click(),setTimeout(()=>{document.body.removeChild(a),URL.revokeObjectURL(o)},100)},d.stop())))}}}}catch(t){console.error(t)}}),i}}();