This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends RefCounted | |
## Classes/Constants | |
enum State { NEW, CLOSED, CONNECTING, CONNECTED } | |
class Response: | |
var info_hash: String # The info_hash which the repsonse belongs to | |
var peer_id: String # The peer_id of the other peer (who've sent it) | |
var offer_id: String # The offer_id that this offer/answer belongs to | |
var sdp: String # The sdp (webrtc session description) of the other peer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name Http extends RefCounted | |
class Response: | |
var code := -1 | |
var headers := {} | |
var error := "" | |
var text := "" | |
var json = null | |
func _init(opts:={}): | |
for key in opts.keys(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name EventEmitter extends RefCounted | |
var _listeners := {} # Holds listener arrays | |
func emit(name: String, args:=[]): | |
if not name in _listeners: return # Skip if no listeners exist | |
_listeners[name] = _listeners[name].filter(func(e): return e.fn.get_object() != null) # Remove null instances | |
for e in _listeners[name]: # Iterate callbacks | |
e.fn.callv(args) # Call callback | |
_listeners[name] = _listeners[name].filter(func(e): return not e.once) # Remove "once" listeners |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name Promise extends RefCounted | |
# Constants | |
const State = { | |
PENDING = "pending", | |
FULFILLED = "fulfilled", | |
REJECTED = "rejected" | |
} | |
# Signals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logHookFunction(obj, key, hookTime = 5000) { | |
if (typeof obj[key] !== "function") { | |
console.log("[-] Hook failed! Not a function!") | |
return | |
} | |
obj[`o${key}`] = obj[`o${key}`] || obj[key] | |
obj[key] = function(...args) { | |
console.log(`[HOOKR] ${key}(${args.join(',')})`) | |
return this[`o${key}`](...args) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hash from 'hash-it'; | |
import { useEffect, useState } from 'react'; | |
const MIN_DELAY = 50; | |
const MAX_DELAY = 1000; | |
const STEP_DELAY = 50; | |
export function useReactive(target) { | |
const [val, setVal] = useState(target); | |
const [_toggle, setToggle] = useState(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
if (!window.speechSynthesis || !window.SpeechSynthesisUtterance) { | |
return alert('Nicht unterstützt!') | |
} | |
const say = text => { | |
if (!text) return | |
window.speechSynthesis.cancel() | |
const msg = new SpeechSynthesisUtterance(text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const OriginalWebSocket = window.WebSocket | |
class WebSocketHook extends OriginalWebSocket { | |
constructor(url, protocols) { | |
super(url, protocols) | |
const { origin } = new URL(url) | |
this.origin = origin | |
this.onmessage_listener = [] | |
this.addEventListener('open', () => WebSocketHook.emit('open', this)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.single-div-modal { | |
position: fixed; | |
box-sizing: border-box; | |
z-index: 1337; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; |