UNPKG

pranks

Version:

A collection of fun pranks for web pages

1 lines 9.48 kB
{"version":3,"file":"index.cjs","sources":["../src/pranks/hacker/index.ts","../src/pranks/rotation/index.ts"],"sourcesContent":["export function showHackedMessage(): void {\n (function (): void {\n if (document.getElementById('matrix-canvas')) return;\n const japanese: string[] = 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン'.split('');\n function getRandomJapaneseChar(): string {\n return japanese[Math.floor(Math.random() * japanese.length)];\n }\n function transformTextNodes(node: Node): { node: Node; text: string[]; index: number }[] {\n const nodesToTransform: { node: Node; text: string[]; index: number }[] = [];\n \n function collectTextNodes(node: Node): void {\n if (node.nodeType === Node.TEXT_NODE && node.nodeValue?.trim()) {\n nodesToTransform.push({\n node,\n text: node.nodeValue.split(''),\n index: 0\n });\n } else if (node.nodeType === Node.ELEMENT_NODE && (node as Element).tagName !== 'SCRIPT' && (node as Element).tagName !== 'STYLE') {\n for (const child of node.childNodes) {\n collectTextNodes(child);\n }\n }\n }\n \n collectTextNodes(node);\n return nodesToTransform;\n }\n\n const nodesToProcess = transformTextNodes(document.body);\n const interval = setInterval(() => {\n let allDone = true;\n \n for (const item of nodesToProcess) {\n if (item.index < item.text.length) {\n item.text[item.index] = getRandomJapaneseChar();\n item.node.nodeValue = item.text.join('');\n item.index++;\n allDone = false;\n }\n }\n \n if (allDone) {\n clearInterval(interval);\n }\n }, 50);\n document.body.style.backgroundColor = 'black !important';\n document.body.style.color = '#0f0 !important';\n document.body.style.fontFamily = \"'Courier New', Courier, monospace !important\";\n const canvas = document.createElement('canvas');\n canvas.id = 'matrix-canvas';\n canvas.style.position = 'fixed';\n canvas.style.top = '0px';\n canvas.style.left = '0px';\n canvas.style.width = '100%';\n canvas.style.height = '100%';\n canvas.style.zIndex = '999999';\n canvas.style.pointerEvents = 'none';\n document.body.appendChild(canvas);\n const ctx = canvas.getContext('2d');\n if (!ctx) return; // Add null check for context\n let width: number, height: number, columns: number, drops: number[];\n const fontSize = 14;\n function resize(): void {\n width = canvas.width = window.innerWidth;\n height = canvas.height = window.innerHeight;\n columns = Math.floor(width / fontSize);\n drops = Array(columns).fill(1);\n }\n window.addEventListener('resize', resize);\n resize();\n function draw(): void {\n if (!ctx) return;\n ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';\n ctx.fillRect(0, 0, width, height);\n ctx.fillStyle = '#0F0';\n ctx.font = `${fontSize}px 'Courier New', Courier, monospace`;\n for (let i = 0; i < drops.length; i++) {\n const text = japanese[Math.floor(Math.random() * japanese.length)];\n const x = i * fontSize;\n const y = drops[i] * fontSize;\n ctx.fillText(text, x, y);\n if (y > height && Math.random() > 0.975) {\n drops[i] = 0;\n }\n drops[i]++;\n }\n \n // Add \"You've been hacked\" message in the middle\n const hackedMessage = \"YOU'VE BEEN HACKED\";\n ctx.font = \"48px 'Courier New', Courier, monospace\";\n ctx.fillStyle = \"#00FF00\"; // Red color for emphasis\n \n // Calculate text width to center it\n const textMetrics = ctx.measureText(hackedMessage);\n const textWidth = textMetrics.width;\n \n // Center the text on the canvas\n ctx.fillText(hackedMessage, (width - textWidth) / 2, height / 2);\n \n requestAnimationFrame(draw);\n }\n // Wait 3 seconds before starting animation\n setTimeout(() => {\n draw();\n }, 3000);\n })();\n}\n\n// Auto-execute when script loads\nif (typeof window !== 'undefined') {\n // Wait for the DOM to be fully loaded\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => {\n setTimeout(showHackedMessage, 3000);\n });\n } else {\n // DOM is already loaded\n setTimeout(showHackedMessage, 3000);\n }\n} ","export function rotatePage(): void {\n if (typeof window === 'undefined') return;\n\n const style = document.createElement('style');\n style.textContent = `\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n\n body {\n animation: spin 3s linear infinite;\n transform-origin: center center;\n }\n `;\n\n document.head.appendChild(style);\n}\n\n// Auto-execute when script loads\nif (typeof window !== 'undefined') {\n if (document.readyState === 'loading') {\n document.addE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