Skip to content

Instantly share code, notes, and snippets.

@es3n1n
Created November 14, 2024 20:48
Show Gist options
  • Save es3n1n/6d34e305d99193a49615a8b87ab706a4 to your computer and use it in GitHub Desktop.
Save es3n1n/6d34e305d99193a49615a8b87ab706a4 to your computer and use it in GitHub Desktop.
Discord stuff
class LetopisUtilities {
constructor() {
this.updateInterval = null
this.eventListenersAdded = false
this.videoFrame = null
this.handleMouseDown = this.handleMouseDown.bind(this)
this.handleMouseWheel = this.handleMouseWheel.bind(this)
this.onStart()
}
onStart() {
window.webpackChunkdiscord_app.push([
[Math.random()],
{},
(e) => {
if (e && e.c) {
for (let t of Object.keys(e.c)
.map((t) => e.c[t].exports)
.filter((e) => e))
if (
(t.default &&
t.default.getCurrentUser &&
((t.default.getCurrentUser().premiumType = 2),
console.log('NITRO HACKNUTO BRAT')),
t.default && t.default._dispatcher)
) {
const e = t.default._dispatcher,
i = e._actionHandlers._orderedActionHandlers,
s = i.SPOTIFY_PLAYER_STATE[0].actionHandler
i.SPOTIFY_PLAYER_STATE[0].actionHandler = function (t) {
return (
e.dispatch({
type: 'SPOTIFY_PROFILE_UPDATE',
accountId: t.accountId,
isPremium: true,
}),
s(t)
)
}
console.log('SPOTIFY ALMOST HACKNUT BRAT, SKIP THE CURRENT TRACK')
break
}
}
},
])
this.checkForVideoFrame()
this.updateInterval = setInterval(() => this.checkForVideoFrame(), 1000)
}
onStop() {
this.resetStyle()
this.removeEventListeners()
clearInterval(this.updateInterval)
}
checkForVideoFrame() {
let e = [...document.querySelectorAll('div')].filter((e) =>
/^videoWrapper_[a-z0-9]+$/.test(e.getAttribute('class'))
)
0 != e.length &&
(null !== (e = e[0]) &&
this.eventListenersAdded &&
e !== this.videoFrame &&
this.removeEventListeners(),
null === e || this.eventListenersAdded
? null === e && this.eventListenersAdded && this.removeEventListeners()
: (this.resetStyle(),
e.addEventListener('mousedown', this.handleMouseDown),
e.addEventListener('wheel', this.handleMouseWheel),
(this.eventListenersAdded = true),
(this.videoFrame = e)))
}
resetStyle() {
this.videoFrame &&
((this.videoFrame.style.top = '0px'),
(this.videoFrame.style.left = '1px'),
(this.videoFrame.style.transform = 'scale(1)'),
(this.videoFrame.style.position = 'relative'))
}
removeEventListeners() {
this.videoFrame &&
(this.videoFrame.removeEventListener('mousedown', this.handleMouseDown),
this.videoFrame.removeEventListener('wheel', this.handleMouseWheel))
this.eventListenersAdded = false
this.videoFrame = null
}
handleMouseDown(e) {
if (1 === e.button) {
e.preventDefault()
let t = e.clientX,
i = e.clientY,
s = this.videoFrame.getBoundingClientRect(),
o = parseInt(this.videoFrame.style.left, 10) || s.left,
n = parseInt(this.videoFrame.style.top, 10) || s.top,
d = (e) => {
let s = e.clientX - t,
d = e.clientY - i
this.videoFrame.style.position = 'relative'
this.videoFrame.style.left = o + s + 'px'
this.videoFrame.style.top = n + d + 'px'
},
r = () => {
document.removeEventListener('mousemove', d)
document.removeEventListener('mouseup', r)
}
document.addEventListener('mousemove', d)
document.addEventListener('mouseup', r)
}
}
handleMouseWheel(e) {
if (e.ctrlKey) {
e.preventDefault()
let t =
Number(this.videoFrame.style.transform.replace(/[^0-9.]/g, '')) || 1,
i = e.deltaY < 0 ? 0.05 : -0.05,
s = Math.max(0.1, t + i),
o = this.videoFrame.getBoundingClientRect(),
n = e.clientX - o.left,
d = e.clientY - o.top,
r = ((n - o.width / 2) * i) / s,
l = ((d - o.height / 2) * i) / s
this.videoFrame.style.position = 'relative'
this.videoFrame.style.transform = `scale(${s})`
this.videoFrame.style.left =
(parseFloat(this.videoFrame.style.left) || 0) - r + 'px'
this.videoFrame.style.top =
(parseFloat(this.videoFrame.style.top) || 0) - l + 'px'
}
}
}
function handleUnload(e) {
'Delete' === e.code &&
(e.shiftKey
? (document.letopis.onStop(),
(document.letopis = void 0),
document.body.removeEventListener('keydown', handleUnload))
: document.letopis.resetStyle())
}
document.letopis = new LetopisUtilities()
document.body.addEventListener('keydown', handleUnload)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment