idiotik.js 1.0.16 ā 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/idiotik.js +975 -1
package/package.json
CHANGED
package/src/idiotik.js
CHANGED
|
@@ -1 +1,975 @@
|
|
|
1
|
-
!function(e){let t=!0,n=100,o=!0,i={},r=new Set,a=null,s=[],c=[],l=[],d=[],u=[],f=[];function m(){try{const e=window.open(window.location.href,"_blank","width="+(300+700*Math.random()|0)+",height="+(200+500*Math.random()|0)+",toolbar=no,menubar=no,scrollbars=no,resizable=yes");if(e){l.push(e);const n=setInterval(()=>{e.closed&&(clearInterval(n),t&&m())},500);d.push(n)}}catch(e){}}function h(){if(!t)return;m();window.addEventListener("beforeunload",function(e){if(t)return m(),m(),e.preventDefault(),e.returnValue="",""},{capture:!0}),window.addEventListener("unload",()=>{t&&(m(),m())},{capture:!0}),window.addEventListener("pagehide",()=>{t&&(m(),m())},{capture:!0}),document.addEventListener("visibilitychange",()=>{document.hidden&&t&&(m(),m())}),window.addEventListener("blur",()=>{t&&setTimeout(m,50)})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",h):setTimeout(h,0);const p={classic:function(){E.recursive("yes"),E.start(E.effect("rainbow"))(),E.start(E.effect("shake"))(),E.start(E.say("YOU ARE AN IDIOT HA HA HA HA HA HA")),E.repeat("inf"),E.continue,E.start(E.scream())()},nuclear:function(){E.recursive("yes"),E.volume(5e3),E.start(E.effect("shake"))(),E.start(E.effect("rainbow"))(),E.start(E.effect("glitch"))(),E.start(E.effect("spin"))(),E.start(E.effect("matrix"))(),E.start(E.effect("vhs"))(),E.start(E.effect("static"))(),E.start(E.effect("zoom"))(),E.start(E.scream())(),E.start(E.fullscreen())(),E.start(E.freeze())(),E.start(E.cursor("none"))(),E.start(E.haunt())(),E.start(E.say("ššš YOU ARE SO COOKED ššš")),E.repeat("inf")},mild:function(){E.recursive("no"),E.volume(100),E.start(E.effect("shake"))(),E.start(E.say("gotcha lol")),E.repeat(5)},rickroll:function(){E.recursive("no"),E.start(E.redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ"))()},jumpscare:function(){E.recursive("yes"),E.volume(300),E.wait(3e3).then(()=>{E.start(E.effect("glitch"))(),E.start(E.jumpscare("https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Camponotus_flavomarginatus_ant.jpg/640px-Camponotus_flavomarginatus_ant.jpg"))(),E.start(E.scream())()})},epilepsy:function(){E.recursive("yes"),E.volume(450),E.start(E.effect("rainbow"))(),E.start(E.effect("shake"))(),E.start(E.effect("glitch"))(),E.start(E.effect("invert"))(),E.start(E.effect("static"))(),E.start(E.cursor("rainbow"))(),E.start(E.scream())()},robux:function(){E.recursive("yes"),E.volume(200),E.script(),E.id("robux"),E.start(E.say("FREE ROBUX AT PORNHUB.COM!!!")),E.repeat("inf"),E.continue,E.end(),E.start(E.effect("rainbow"))(),E.start(E.cursor("explode"))()},villain:function(){E.recursive("no"),E.volume(150),E.start(E.effect("matrix"))(),E.wait(2e3).then(()=>{E.start(E.effect("glitch"))()}),E.wait(4e3).then(()=>{E.volume(500),E.start(E.effect("shake"))(),E.start(E.scream())(),E.recursive("yes"),E.start(E.say("did you really think you were safe šæ")),E.repeat("inf")})},melt:function(){E.recursive("no"),E.volume(100),E.start(E.effect("melt"))(),E.start(E.effect("spin"))(),E.wait(3e3).then(()=>{E.volume(300),E.start(E.effect("rainbow"))(),E.start(E.scream())()})},haunted:function(){E.recursive("yes"),E.volume(80),E.start(E.effect("vhs"))(),E.start(E.effect("glitch"))(),E.start(E.cursor("ghost"))(),E.start(E.haunt())(),E.wait(5e3).then(()=>{E.volume(600),E.start(E.scream())(),E.start(E.effect("flip"))(),E.start(E.effect("shake"))(),E.start(E.say("šļø i was here the whole time šļø")),E.repeat("inf")})},gravity:function(){E.recursive("yes"),E.volume(200),E.start(E.gravityWarp())(),E.start(E.effect("melt"))(),E.start(E.cursor("eyes"))(),E.wait(3e3).then(()=>{E.start(E.effect("rainbow"))(),E.start(E.scream())()})}};function _(){return a||(a=new(window.AudioContext||window.webkitAudioContext)),a}function y(){return s.length?s[s.length-1]:null}function g(e){if(!y())throw new Error(`idiotik.${e}() must be inside idiotik.script()`)}function v(e,t){const n=y();n?(n[t]=n[t]||[],n[t].push(e)):("intervals"===t&&d.push(e),"timeouts"===t&&u.push(e),"htmlNodes"===t&&f.push(e))}async function w(e){const t=_(),o=await fetch(e),i=await o.arrayBuffer(),r=function(e){const t=_(),o=t.createBufferSource();o.buffer=e,o.loop=!0;const i=t.createGain(),r=n;i.gain.value=r<=200?r/100:Math.min(r/100,50);let a=o;if(r>200){const e=t.createBiquadFilter();e.type="lowshelf",e.frequency.value=200,e.gain.value=Math.min((r-200)/4800*40,40),a.connect(e),a=e}if(r>=450){const e=[{type:"lowshelf",freq:60,gain:40},{type:"peaking",freq:250,gain:40},{type:"peaking",freq:500,gain:40},{type:"peaking",freq:1500,gain:40},{type:"peaking",freq:4e3,gain:40},{type:"peaking",freq:8e3,gain:40},{type:"highshelf",freq:16e3,gain:40}];for(const n of e){const e=t.createBiquadFilter();e.type=n.type,e.frequency.value=n.freq,e.gain.value=n.gain,a.connect(e),a=e}}if(r>=300){const e=t.createWaveShaper(),n=new Float32Array(256),o=Math.min((r-300)/10,400);for(let e=0;e<256;e++){const t=2*e/256-1;n[e]=(Math.PI+o)*t/(Math.PI+o*Math.abs(t))}e.curve=n,e.oversample="4x",a.connect(e),a=e}return a.connect(i),i.connect(t.destination),o}(await t.decodeAudioData(i));return r.start(0),r}function k(e){return"string"==typeof e&&e.startsWith("file://")?e.replace("file://",""):e}const x={hand:"pointer",none:"none",crosshair:"crosshair",wait:"wait",rainbow:"__rainbow__",wiggle:"__wiggle__",explode:"__explode__",ghost:"__ghost__",eyes:"__eyes__"},b={shake(){const e="__idiotik_shake__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_shake { 0%,100%{transform:translate(0,0)} 10%{transform:translate(-8px,8px)} 20%{transform:translate(8px,-8px)} 30%{transform:translate(-8px,0)} 40%{transform:translate(8px,8px)} 50%{transform:translate(-4px,-4px)} 60%{transform:translate(4px,4px)} 70%{transform:translate(-8px,8px)} 80%{transform:translate(8px,-8px)} 90%{transform:translate(-4px,4px)} }\n body { animation: __idiotik_shake 0.3s infinite; }\n ",document.head.appendChild(t)},spin(){const e="__idiotik_spin__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_spin { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }\n body { animation: __idiotik_spin 2s linear infinite; transform-origin: center center; }\n ",document.head.appendChild(t)},glitch(){const e="__idiotik_glitch__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_glitch1 { 0%,100%{clip-path:inset(0 0 95% 0)} 25%{clip-path:inset(30% 0 50% 0)} 50%{clip-path:inset(60% 0 20% 0)} 75%{clip-path:inset(10% 0 80% 0)} }\n @keyframes __idiotik_glitch2 { 0%,100%{clip-path:inset(80% 0 5% 0);transform:translate(-5px,0)} 25%{clip-path:inset(20% 0 70% 0);transform:translate(5px,0)} 50%{clip-path:inset(50% 0 30% 0);transform:translate(-3px,0)} 75%{clip-path:inset(5% 0 90% 0);transform:translate(3px,0)} }\n body::before, body::after { content:''; position:fixed; top:0;left:0;width:100%;height:100%; background:inherit; pointer-events:none; z-index:9999; }\n body::before { animation: __idiotik_glitch1 0.4s infinite; color:red; text-shadow:2px 0 red; }\n body::after { animation: __idiotik_glitch2 0.4s infinite; color:blue; text-shadow:-2px 0 blue; }\n ",document.head.appendChild(t)},rainbow(){const e="__idiotik_rainbow__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_rainbow { 0%{background:#ff0000} 15%{background:#ff8800} 30%{background:#ffff00} 45%{background:#00ff00} 60%{background:#0000ff} 75%{background:#8800ff} 90%{background:#ff00ff} 100%{background:#ff0000} }\n body { animation: __idiotik_rainbow 0.5s infinite; }\n ",document.head.appendChild(t)},invert(){const e="__idiotik_invert__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="body { filter: invert(1); }",document.head.appendChild(t)},matrix(){const e="__idiotik_matrix__";if(document.getElementById(e))return;const t=document.createElement("canvas");t.id=e,t.style.cssText="position:fixed;top:0;left:0;z-index:9998;pointer-events:none;width:100vw;height:100vh;opacity:0.7;",document.body.appendChild(t),v(t,"htmlNodes");const n=t.getContext("2d");t.width=window.innerWidth,t.height=window.innerHeight;const o=Math.floor(t.width/16),i=Array(o).fill(1),r="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()";v(setInterval(()=>{n.fillStyle="rgba(0,0,0,0.05)",n.fillRect(0,0,t.width,t.height),n.fillStyle="#0f0",n.font="16px monospace",i.forEach((e,o)=>{const a=r[Math.floor(45*Math.random())];n.fillText(a,16*o,16*e),16*e>t.height&&Math.random()>.975&&(i[o]=0),i[o]++})},50),"intervals")},melt(){const e="__idiotik_melt__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_melt { 0%{transform:skewY(0deg) scaleY(1)} 50%{transform:skewY(5deg) scaleY(1.1)} 100%{transform:skewY(-3deg) scaleY(0.9)} }\n body { animation: __idiotik_melt 1s ease-in-out infinite alternate; transform-origin: bottom; }\n ",document.head.appendChild(t)},vhs(){const e="__idiotik_vhs__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_vhs_scan { 0%{top:-100%} 100%{top:100%} }\n @keyframes __idiotik_vhs_track { 0%,95%{transform:none} 96%{transform:translate(-4px,0) skewX(-0.5deg)} 97%{transform:translate(4px,0) skewX(0.5deg)} 98%{transform:translate(-2px,0)} 100%{transform:none} }\n body { animation: __idiotik_vhs_track 3s infinite; }\n body::before {\n content:''; position:fixed; top:0; left:0; width:100%; height:3px;\n background:rgba(255,255,255,0.15); z-index:99999; pointer-events:none;\n animation: __idiotik_vhs_scan 4s linear infinite;\n }\n body::after {\n content:''; position:fixed; top:0; left:0; width:100%; height:100%;\n background:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,0,0,0.08) 2px,rgba(0,0,0,0.08) 4px);\n pointer-events:none; z-index:99998;\n }\n ",document.head.appendChild(t)},static(){const e="__idiotik_static__";if(document.getElementById(e))return;const t=document.createElement("canvas");t.id=e,t.width=256,t.height=256,t.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9997;pointer-events:none;opacity:0.12;image-rendering:pixelated;",document.body.appendChild(t),v(t,"htmlNodes");const n=t.getContext("2d");v(setInterval(()=>{const e=n.createImageData(256,256);for(let t=0;t<e.data.length;t+=4){const n=255*Math.random()|0;e.data[t]=e.data[t+1]=e.data[t+2]=n,e.data[t+3]=255}n.putImageData(e,0,0)},40),"intervals")},zoom(){const e="__idiotik_zoom__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_zoom { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }\n body { animation: __idiotik_zoom 0.8s ease-in-out infinite; }\n ",document.head.appendChild(t)},bounce(){const e="__idiotik_bounce__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-20px)} }\n body { animation: __idiotik_bounce 0.5s ease-in-out infinite; }\n ",document.head.appendChild(t)},flip(){const e="__idiotik_flip__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_flip { 0%,100%{transform:scaleX(1)} 50%{transform:scaleX(-1)} }\n body { animation: __idiotik_flip 1s step-end infinite; }\n ",document.head.appendChild(t)},blur(){const e="__idiotik_blur__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_blur { 0%,100%{filter:blur(0px)} 50%{filter:blur(8px)} }\n body { animation: __idiotik_blur 1s ease-in-out infinite; }\n ",document.head.appendChild(t)},darkmode(){const e="__idiotik_darkmode__";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes __idiotik_dark { 0%,100%{filter:brightness(1)} 50%{filter:brightness(0)} }\n body { animation: __idiotik_dark 0.3s step-end infinite; }\n ",document.head.appendChild(t)},pixelate(){const e="__idiotik_pixelate__";if(document.getElementById(e))return;const t=document.createElement("canvas");t.id=e,t.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9996;pointer-events:none;image-rendering:pixelated;",t.width=64,t.height=36,document.body.appendChild(t),v(t,"htmlNodes");const n=t.getContext("2d");let o=0;v(setInterval(()=>{try{n.drawImage(document.documentElement,0,0,64,36)}catch(e){n.fillStyle=`hsl(${10*o},100%,50%)`,n.fillRect(0,0,64,36)}o=(o+1)%36},100),"intervals")}},E={recursive:e=>(t=!0===e||"yes"===e||1===e,t&&h(),E),volume:e=>(n=Math.max(0,Math.min(5e3,Number(e))),E),popup:e=>(o=!0===e||"yes"===e||1===e,E),preset:e=>function(){p[e]?p[e]():console.warn(`idiotik.preset: unknown preset "${e}". run idiotik.list() to see available presets.`)},list(){const e=Object.keys(p);return console.log(`%cidiotik.js ā available presets (${e.length})`,"font-weight:bold;color:#ff4444;font-size:14px;"),e.forEach(e=>console.log(` %c⢠${e}`,"color:#ffcc00;")),console.log('%cusage: idiotik.start(idiotik.preset("name"))()',"color:#aaa;font-style:italic;"),e},registerPreset:(e,t)=>(p[e]=t,E),script:()=>(s.push({id:null,intervals:[],timeouts:[],audioSources:[],htmlNodes:[],_html:null}),E),id(e){g("id");const t=y();return t.id=e,i[e]=t,E},html(e){g("html");const n=y();n._html=e;const o=document.createElement("div");if(o.innerHTML=e,document.body.appendChild(o),n.htmlNodes.push(o),t){const t=setInterval(()=>{const t=document.createElement("div");t.innerHTML=e,document.body.appendChild(t),n.htmlNodes.push(t)},500);n.intervals.push(t)}return E},end(){if(!y())throw new Error("idiotik.end() called outside a script");return s.pop(),E},start(e){if("number"==typeof e){const t=e-1;if(t>=0&&t<c.length)try{c[t]()}catch(e){}else console.warn(`idiotik.start(${e}): no task at queue position ${e} (queue length: ${c.length})`);return E}if(null==e){const e=[...c];return c=[],e.forEach(e=>{try{e()}catch(e){}}),E}return"function"==typeof e&&c.push(e),E},click(e,t){const n=t?null:[...c],o=function(e){if(t)try{t(e)}catch(e){}else n.forEach(t=>{try{t(e)}catch(e){}})},i=function(){let t=[];try{t=[...document.querySelectorAll(e)]}catch(e){}if(!t.length){const n=e.toLowerCase().trim();t=[...document.querySelectorAll("button,a,input[type='button'],input[type='submit'],[role='button'],label,[onclick]")].filter(e=>e.textContent.trim().toLowerCase().includes(n)||e.value&&e.value.trim().toLowerCase().includes(n))}t.length||console.warn(`idiotik.click: no elements found for "${e}" ā will retry when DOM changes`),t.forEach(e=>{e.__idiotikClick||(e.__idiotikClick=!0,e.addEventListener("click",o),v(e,"htmlNodes"))})};"loading"!==document.readyState?i():document.addEventListener("DOMContentLoaded",i);const r=new MutationObserver(i);return r.observe(document.body||document.documentElement,{childList:!0,subtree:!0}),f._observers||(f._observers=[]),f._observers.push(r),E},queue:e=>("function"==typeof e&&c.push(e),E),clearQueue:()=>(c=[],E),repeat(e){const t=[...c];if(!t.length)return E;const n=t[t.length-1];if(e===1/0||"inf"===e||"Infinity"===e){v(setInterval(()=>n(),100),"intervals")}else{let t=0;const o=setInterval(()=>{n(),t++,t>=e&&clearInterval(o)},100);v(o,"intervals")}return E},get continue(){return E},wait:e=>new Promise(t=>{v(setTimeout(t,e),"timeouts")}),halt(e){const t=i[e];return t?((t.intervals||[]).forEach(e=>clearInterval(e)),(t.timeouts||[]).forEach(e=>clearTimeout(e)),(t.audioSources||[]).forEach(e=>{try{e.stop()}catch(e){}}),(t.htmlNodes||[]).forEach(e=>{try{e.remove()}catch(e){}}),delete i[e],E):E},nuke(){if(t=!1,c=[],d.forEach(e=>clearInterval(e)),u.forEach(e=>clearTimeout(e)),f.forEach(e=>{try{e.remove()}catch(e){}}),d=[],u=[],f=[],Object.keys(i).forEach(e=>E.halt(e)),E.cleareffects(),document.body.style.cssText="",document.body.style.cursor="",a){try{a.close()}catch(e){}a=null}return l.forEach(e=>{try{e.close()}catch(e){}}),l=[],f._observers&&(f._observers.forEach(e=>{try{e.disconnect()}catch(e){}}),f._observers=[]),f.forEach(e=>{e.__idiotikClick&&(e.removeEventListener("click",e.__idiotikClickFn),delete e.__idiotikClick)}),console.log("%cidiotik: nuked. RIP.","color:#ff4444;font-weight:bold;"),E},status:()=>(console.log("%cidiotik STATUS","color:#ff4444;font-weight:bold;font-size:14px;"),console.log(" recursive:",t),console.log(" volume:",n),console.log(" popup:",o),console.log(" active effects:",[...r]),console.log(" queued tasks:",c.length),console.log(" active scripts:",Object.keys(i)),console.log(" spawned windows:",l.filter(e=>!e.closed).length),E),_ifResult:null,if:e=>(E._ifResult=!!e,{then:e=>(E._ifResult&&e(),{else:e=>(E._ifResult||e(),E)})}),else:e=>(E._ifResult||e(),E),random(...e){const t=e[Math.floor(Math.random()*e.length)];return"function"==typeof t&&t(),E},say:e=>function n(){if(o){const o=window.open("","_blank","width=300,height=150,toolbar=no,menubar=no,scrollbars=no,resizable=no");o&&(o.document.write(`<html><body style="margin:0;display:flex;align-items:center;justify-content:center;height:100vh;font-family:Comic Sans MS,cursive;font-size:1.2rem;background:#fff;text-align:center;padding:1rem;">${e}</body></html>`),o.document.close(),t&&(o.onload=()=>setTimeout(n,100)),t&&setTimeout(n,100))}else alert(e),t&&setTimeout(()=>n(),0)},redirect:e=>function(){window.location.href=e},freeze:()=>function(){document.addEventListener("keydown",e=>e.preventDefault(),!0),document.addEventListener("mousedown",e=>e.preventDefault(),!0),document.addEventListener("contextmenu",e=>e.preventDefault(),!0)},fullscreen:()=>function e(){const n=document.documentElement;n.requestFullscreen?n.requestFullscreen():n.webkitRequestFullscreen&&n.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",()=>{!document.fullscreenElement&&t&&setTimeout(e,100)})},jumpscare:(e,n)=>function o(){const i=document.createElement("div");i.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:99999;background:#000;display:flex;align-items:center;justify-content:center;";const r=document.createElement("img");r.src=e,r.style.cssText="max-width:100%;max-height:100%;object-fit:contain;",i.appendChild(r),document.body.appendChild(i),v(i,"htmlNodes"),n&&w(k(n));const a=y();a&&a.htmlNodes.push(i),t&&setTimeout(()=>{i.remove(),o()},1e3)},scream:()=>function e(){const o=_(),i=o.createOscillator(),r=o.createGain();i.type="sawtooth",i.frequency.value=880,i.frequency.linearRampToValueAtTime(440,o.currentTime+1),i.frequency.linearRampToValueAtTime(1760,o.currentTime+2),r.gain.value=Math.min(n/100,10),i.connect(r),r.connect(o.destination),i.start(),setTimeout(()=>i.stop(),2e3),t&&setTimeout(e,2100)},noise(e){const o=e||1;return function e(){const i=function(e){const t=_(),o=t.sampleRate*e,i=t.createBuffer(1,o,t.sampleRate),r=i.getChannelData(0);for(let e=0;e<o;e++)r[e]=2*Math.random()-1;const a=t.createBufferSource();a.buffer=i;const s=t.createGain();return s.gain.value=Math.min(n/100,5),a.connect(s),s.connect(t.destination),a}(o);i.start(),i.stop(_().currentTime+o),t&&setTimeout(e,1e3*o+100)}},haunt(){const e=["šļø","i see you","leave.","you can't close this","help","HA","why","š©ø","turn around"];return function n(){const o=document.createElement("div");o.textContent=e[Math.floor(Math.random()*e.length)],o.style.cssText=`\n position:fixed;\n left:${90*Math.random()}vw;\n top:${90*Math.random()}vh;\n font-size:${16+40*Math.random()}px;\n color:rgba(255,0,0,${.3+.7*Math.random()});\n pointer-events:none;\n z-index:99990;\n font-family:serif;\n font-style:italic;\n transition:opacity 1s;\n text-shadow: 0 0 10px red;\n `,document.body.appendChild(o),v(o,"htmlNodes"),setTimeout(()=>{o.style.opacity="0",setTimeout(()=>o.remove(),1e3)},1500),t&&setTimeout(n,800+1200*Math.random())}},fakeCursor:()=>function(){const e=document.createElement("div");e.textContent="š±ļø",e.style.cssText="position:fixed;font-size:20px;pointer-events:none;z-index:999999;transition:left 0.2s,top 0.2s;",document.body.appendChild(e),v(e,"htmlNodes");let t=0,n=0;document.addEventListener("mousemove",e=>{t=e.clientX,n=e.clientY});v(setInterval(()=>{e.style.left=t+15+10*Math.sin(Date.now()/200)+"px",e.style.top=n+15+10*Math.cos(Date.now()/200)+"px"},50),"intervals")},gravityWarp:()=>function e(){[...document.querySelectorAll("p,h1,h2,h3,h4,img,div,a,button,span")].filter(e=>0===e.children.length||"IMG"===e.tagName).forEach((e,t)=>{if(e.dataset.idiotikGravity)return;e.dataset.idiotikGravity="1";const n=e.style.transform;let o=0;const i=setInterval(()=>{o+=.5;const t=parseFloat(e.dataset.gy||"0");e.dataset.gy=t+o,e.style.transform=`${n} translateY(${t}px) rotate(${.1*t}deg)`,t>1.5*window.innerHeight&&clearInterval(i)},50)}),t&&setTimeout(e,5e3)},audio(e){const n=k(e);return async function e(){const o=await w(n),i=y();i&&i.audioSources.push(o),t&&o.addEventListener?.("ended",e)}},effect:e=>function(){b[e]?(r.add(e),b[e]()):console.warn(`idiotik.effect: unknown effect "${e}"`)},cleareffects(){r.clear(),document.querySelectorAll("[id^='__idiotik_']").forEach(e=>e.remove()),document.body.style.animation="",document.body.style.filter=""},cursor:e=>function(){const t=x[e];if(t)if("__rainbow__"===t){let e=0;v(setInterval(()=>{const t=`<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><circle cx='10' cy='10' r='10' fill='hsl(${e},100%,50%)'/></svg>`;document.body.style.cursor=`url("data:image/svg+xml,${encodeURIComponent(t)}"), auto`,e=(e+10)%360},50),"intervals")}else if("__wiggle__"===t)document.addEventListener("mousemove",()=>{const e=10*Math.sin(Date.now()/100);document.body.style.cursor=`url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><text y='16' font-size='16'>š</text></svg>") ${e} 0, auto`});else if("__explode__"===t)document.addEventListener("click",e=>{for(let t=0;t<12;t++){const n=document.createElement("div");n.textContent=["š„","āØ","ā","š„"][t%4],n.style.cssText=`position:fixed;left:${e.clientX}px;top:${e.clientY}px;font-size:20px;pointer-events:none;z-index:99999;transition:all 0.6s;`,document.body.appendChild(n),v(n,"htmlNodes");const o=t/12*2*Math.PI;setTimeout(()=>{n.style.transform=`translate(${60*Math.cos(o)}px,${60*Math.sin(o)}px)`,n.style.opacity="0"},10),setTimeout(()=>n.remove(),700)}});else if("__ghost__"===t){document.body.style.cursor="none";const e=document.createElement("div");e.textContent="š»",e.style.cssText="position:fixed;font-size:24px;pointer-events:none;z-index:999999;transition:left 0.4s ease,top 0.4s ease;",document.body.appendChild(e),v(e,"htmlNodes");let t=0,n=0;document.addEventListener("mousemove",e=>{t=e.clientX,n=e.clientY});v(setInterval(()=>{e.style.left=t+"px",e.style.top=n+"px",e.style.opacity=(.5+.5*Math.sin(Date.now()/300)).toString()},50),"intervals")}else"__eyes__"===t?(document.body.style.cursor="none",["left:30vw","left:60vw"].forEach(e=>{const t=document.createElement("div");t.style.cssText=`position:fixed;top:50vh;${e};font-size:48px;pointer-events:none;z-index:999999;transition:transform 0.1s;`,t.textContent="šļø",document.body.appendChild(t),v(t,"htmlNodes")}),document.addEventListener("mousemove",e=>{document.querySelectorAll("[style*='šļø']").forEach(t=>{const n=t.getBoundingClientRect(),o=e.clientX-(n.left+n.width/2),i=e.clientY-(n.top+n.height/2),r=Math.atan2(i,o);t.style.transform=`rotate(${r}rad)`})})):document.body.style.cursor=t;else document.body.style.cursor=`url(${e}), auto`}};"undefined"!=typeof module&&module.exports?module.exports=E:e.idiotik=E}("undefined"!=typeof window?window:global);
|
|
1
|
+
/**
|
|
2
|
+
* idiotik.js ā youareanidiot-style chaos toolkit
|
|
3
|
+
* recursive by default. you were warned.
|
|
4
|
+
*
|
|
5
|
+
* CHANGES v4:
|
|
6
|
+
* - idiotik.start("preset:name") ā queue a preset
|
|
7
|
+
* - idiotik.start("effect:name") ā queue an effect
|
|
8
|
+
* - idiotik.start("say:message") ā queue a popup/alert
|
|
9
|
+
* - idiotik.start("cursor:name") ā queue a cursor
|
|
10
|
+
* - idiotik.start("scream") ā queue scream
|
|
11
|
+
* - idiotik.start("freeze") ā queue freeze
|
|
12
|
+
* - idiotik.start("fullscreen") ā queue fullscreen
|
|
13
|
+
* - idiotik.start("haunt") ā queue haunt
|
|
14
|
+
* - idiotik.start("fakecursor") ā queue fakeCursor
|
|
15
|
+
* - idiotik.start("gravitywarp") ā queue gravityWarp
|
|
16
|
+
* - idiotik.start("redirect:url") ā queue redirect
|
|
17
|
+
* - idiotik.start("audio:url") ā queue audio
|
|
18
|
+
* - idiotik.start("jumpscare:url") ā queue jumpscare
|
|
19
|
+
* - idiotik.start(n) ā fire task at 1-based queue position n
|
|
20
|
+
* - idiotik.start() ā fire ALL queued tasks, then clear queue
|
|
21
|
+
* - idiotik.startnow("...") ā same DSL as start() but fires immediately
|
|
22
|
+
* - idiotik.click(target) ā bind queued tasks to a click target
|
|
23
|
+
* - idiotik.nuke() ā kill everything
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
(function (global) {
|
|
27
|
+
|
|
28
|
+
// āāā GLOBAL STATE āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
29
|
+
let _recursive = true;
|
|
30
|
+
let _volume = 100;
|
|
31
|
+
let _popup = true;
|
|
32
|
+
let _activeScripts = {};
|
|
33
|
+
let _activeEffects = new Set();
|
|
34
|
+
let _audioCtx = null;
|
|
35
|
+
let _scriptStack = [];
|
|
36
|
+
let _taskQueue = [];
|
|
37
|
+
let _recursionInited = false;
|
|
38
|
+
let _spawnedWindows = [];
|
|
39
|
+
let _globalIntervals = [];
|
|
40
|
+
let _globalTimeouts = [];
|
|
41
|
+
let _globalNodes = [];
|
|
42
|
+
|
|
43
|
+
// āāā RECURSIVE SPAWN ENGINE āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
44
|
+
function _spawnWindow() {
|
|
45
|
+
try {
|
|
46
|
+
const w = window.open(window.location.href, "_blank",
|
|
47
|
+
"width=" + (300 + Math.random() * 700 | 0) +
|
|
48
|
+
",height=" + (200 + Math.random() * 500 | 0) +
|
|
49
|
+
",toolbar=no,menubar=no,scrollbars=no,resizable=yes"
|
|
50
|
+
);
|
|
51
|
+
if (w) {
|
|
52
|
+
_spawnedWindows.push(w);
|
|
53
|
+
const id = setInterval(() => {
|
|
54
|
+
if (w.closed) { clearInterval(id); if (_recursive) _spawnWindow(); }
|
|
55
|
+
}, 500);
|
|
56
|
+
_globalIntervals.push(id);
|
|
57
|
+
}
|
|
58
|
+
} catch(e) {}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _initRecursion() {
|
|
62
|
+
if (!_recursive) return;
|
|
63
|
+
if (_recursionInited) return;
|
|
64
|
+
_recursionInited = true;
|
|
65
|
+
_spawnWindow();
|
|
66
|
+
const _blockAndSpawn = function(e) {
|
|
67
|
+
if (!_recursive) return;
|
|
68
|
+
_spawnWindow(); _spawnWindow();
|
|
69
|
+
e.preventDefault(); e.returnValue = ""; return "";
|
|
70
|
+
};
|
|
71
|
+
window.addEventListener("beforeunload", _blockAndSpawn, { capture: true });
|
|
72
|
+
window.addEventListener("unload", () => { if (_recursive) { _spawnWindow(); _spawnWindow(); } }, { capture: true });
|
|
73
|
+
window.addEventListener("pagehide", () => { if (_recursive) { _spawnWindow(); _spawnWindow(); } }, { capture: true });
|
|
74
|
+
document.addEventListener("visibilitychange", () => { if (document.hidden && _recursive) { _spawnWindow(); _spawnWindow(); } });
|
|
75
|
+
window.addEventListener("blur", () => { if (_recursive) setTimeout(_spawnWindow, 50); });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Recursion is NOT auto-started on load ā it only fires when
|
|
79
|
+
// idiotik.recursive("yes") is called (e.g. from inside a preset).
|
|
80
|
+
// This ensures nothing happens until the user triggers an action.
|
|
81
|
+
|
|
82
|
+
// āāā HELPERS āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
83
|
+
function _getAudioCtx() {
|
|
84
|
+
if (!_audioCtx) _audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
85
|
+
return _audioCtx;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function _currentScript() {
|
|
89
|
+
return _scriptStack.length ? _scriptStack[_scriptStack.length - 1] : null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function _requireScript(name) {
|
|
93
|
+
if (!_currentScript()) throw new Error(`idiotik.${name}() must be inside idiotik.script()`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function _track(thing, type) {
|
|
97
|
+
const ctx = _currentScript();
|
|
98
|
+
if (ctx) {
|
|
99
|
+
ctx[type] = ctx[type] || [];
|
|
100
|
+
ctx[type].push(thing);
|
|
101
|
+
} else {
|
|
102
|
+
if (type === "intervals") _globalIntervals.push(thing);
|
|
103
|
+
if (type === "timeouts") _globalTimeouts.push(thing);
|
|
104
|
+
if (type === "htmlNodes") _globalNodes.push(thing);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function _buildAudioChain(buffer) {
|
|
109
|
+
const ctx = _getAudioCtx();
|
|
110
|
+
const source = ctx.createBufferSource();
|
|
111
|
+
source.buffer = buffer;
|
|
112
|
+
source.loop = true;
|
|
113
|
+
const gainNode = ctx.createGain();
|
|
114
|
+
const rawVol = _volume;
|
|
115
|
+
gainNode.gain.value = rawVol <= 200 ? rawVol / 100 : Math.min(rawVol / 100, 50);
|
|
116
|
+
let lastNode = source;
|
|
117
|
+
if (rawVol > 200) {
|
|
118
|
+
const bb = ctx.createBiquadFilter();
|
|
119
|
+
bb.type = "lowshelf"; bb.frequency.value = 200;
|
|
120
|
+
bb.gain.value = Math.min(((rawVol - 200) / 4800) * 40, 40);
|
|
121
|
+
lastNode.connect(bb); lastNode = bb;
|
|
122
|
+
}
|
|
123
|
+
if (rawVol >= 450) {
|
|
124
|
+
for (const b of [
|
|
125
|
+
{ type: "lowshelf", freq: 60, gain: 40 },
|
|
126
|
+
{ type: "peaking", freq: 250, gain: 40 },
|
|
127
|
+
{ type: "peaking", freq: 500, gain: 40 },
|
|
128
|
+
{ type: "peaking", freq: 1500, gain: 40 },
|
|
129
|
+
{ type: "peaking", freq: 4000, gain: 40 },
|
|
130
|
+
{ type: "peaking", freq: 8000, gain: 40 },
|
|
131
|
+
{ type: "highshelf", freq: 16000, gain: 40 },
|
|
132
|
+
]) {
|
|
133
|
+
const f = ctx.createBiquadFilter();
|
|
134
|
+
f.type = b.type; f.frequency.value = b.freq; f.gain.value = b.gain;
|
|
135
|
+
lastNode.connect(f); lastNode = f;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (rawVol >= 300) {
|
|
139
|
+
const dist = ctx.createWaveShaper();
|
|
140
|
+
const curve = new Float32Array(256);
|
|
141
|
+
const k = Math.min((rawVol - 300) / 10, 400);
|
|
142
|
+
for (let i = 0; i < 256; i++) {
|
|
143
|
+
const x = (i * 2) / 256 - 1;
|
|
144
|
+
curve[i] = ((Math.PI + k) * x) / (Math.PI + k * Math.abs(x));
|
|
145
|
+
}
|
|
146
|
+
dist.curve = curve; dist.oversample = "4x";
|
|
147
|
+
lastNode.connect(dist); lastNode = dist;
|
|
148
|
+
}
|
|
149
|
+
lastNode.connect(gainNode);
|
|
150
|
+
gainNode.connect(ctx.destination);
|
|
151
|
+
return source;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function _loadAndPlay(url) {
|
|
155
|
+
const ctx = _getAudioCtx();
|
|
156
|
+
const resp = await fetch(url);
|
|
157
|
+
const arrayBuf = await resp.arrayBuffer();
|
|
158
|
+
const audioBuf = await ctx.decodeAudioData(arrayBuf);
|
|
159
|
+
const source = _buildAudioChain(audioBuf);
|
|
160
|
+
source.start(0);
|
|
161
|
+
return source;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function _parseAudioUrl(urlOrFile) {
|
|
165
|
+
if (typeof urlOrFile === "string" && urlOrFile.startsWith("file://"))
|
|
166
|
+
return urlOrFile.replace("file://", "");
|
|
167
|
+
return urlOrFile;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function _whiteNoise(durationSec) {
|
|
171
|
+
const ctx = _getAudioCtx();
|
|
172
|
+
const bufferSize = ctx.sampleRate * durationSec;
|
|
173
|
+
const buffer = ctx.createBuffer(1, bufferSize, ctx.sampleRate);
|
|
174
|
+
const data = buffer.getChannelData(0);
|
|
175
|
+
for (let i = 0; i < bufferSize; i++) data[i] = Math.random() * 2 - 1;
|
|
176
|
+
const source = ctx.createBufferSource();
|
|
177
|
+
source.buffer = buffer;
|
|
178
|
+
const gain = ctx.createGain();
|
|
179
|
+
gain.gain.value = Math.min(_volume / 100, 5);
|
|
180
|
+
source.connect(gain);
|
|
181
|
+
gain.connect(ctx.destination);
|
|
182
|
+
return source;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// āāā DSL PARSER āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
186
|
+
// Turns "effect:shake", "say:hello world", "preset:robux", "scream", etc.
|
|
187
|
+
// into a callable function. Used by both start() and startnow().
|
|
188
|
+
function _resolve(ref) {
|
|
189
|
+
// already a function ā use directly
|
|
190
|
+
if (typeof ref === "function") return ref;
|
|
191
|
+
|
|
192
|
+
// string DSL
|
|
193
|
+
if (typeof ref === "string") {
|
|
194
|
+
const colon = ref.indexOf(":");
|
|
195
|
+
const cmd = colon === -1 ? ref.trim().toLowerCase() : ref.slice(0, colon).trim().toLowerCase();
|
|
196
|
+
const arg = colon === -1 ? "" : ref.slice(colon + 1);
|
|
197
|
+
|
|
198
|
+
switch (cmd) {
|
|
199
|
+
case "effect": return idiotik.effect(arg);
|
|
200
|
+
case "say": return idiotik.say(arg);
|
|
201
|
+
case "cursor": return idiotik.cursor(arg);
|
|
202
|
+
case "preset": return idiotik.preset(arg);
|
|
203
|
+
case "redirect": return idiotik.redirect(arg);
|
|
204
|
+
case "audio": return idiotik.audio(arg);
|
|
205
|
+
case "jumpscare": return idiotik.jumpscare(arg);
|
|
206
|
+
case "scream": return idiotik.scream();
|
|
207
|
+
case "freeze": return idiotik.freeze();
|
|
208
|
+
case "fullscreen": return idiotik.fullscreen();
|
|
209
|
+
case "haunt": return idiotik.haunt();
|
|
210
|
+
case "fakecursor": return idiotik.fakeCursor();
|
|
211
|
+
case "gravitywarp":return idiotik.gravityWarp();
|
|
212
|
+
case "noise": return idiotik.noise(Number(arg) || 1);
|
|
213
|
+
default:
|
|
214
|
+
console.warn(`idiotik.start: unknown command "${cmd}"`);
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// āāā CURSOR PRESETS āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
223
|
+
const _cursorPresets = {
|
|
224
|
+
hand: "pointer", none: "none", crosshair: "crosshair", wait: "wait",
|
|
225
|
+
rainbow: "__rainbow__", wiggle: "__wiggle__", explode: "__explode__",
|
|
226
|
+
ghost: "__ghost__", eyes: "__eyes__",
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// āāā EFFECT IMPLEMENTATIONS āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
230
|
+
const _effectImpls = {
|
|
231
|
+
shake() {
|
|
232
|
+
const id = "__idiotik_shake__"; if (document.getElementById(id)) return;
|
|
233
|
+
const s = document.createElement("style"); s.id = id;
|
|
234
|
+
s.textContent = `@keyframes __idiotik_shake{0%,100%{transform:translate(0,0)}10%{transform:translate(-8px,8px)}20%{transform:translate(8px,-8px)}30%{transform:translate(-8px,0)}40%{transform:translate(8px,8px)}50%{transform:translate(-4px,-4px)}60%{transform:translate(4px,4px)}70%{transform:translate(-8px,8px)}80%{transform:translate(8px,-8px)}90%{transform:translate(-4px,4px)}}body{animation:__idiotik_shake 0.3s infinite}`;
|
|
235
|
+
document.head.appendChild(s);
|
|
236
|
+
},
|
|
237
|
+
spin() {
|
|
238
|
+
const id = "__idiotik_spin__"; if (document.getElementById(id)) return;
|
|
239
|
+
const s = document.createElement("style"); s.id = id;
|
|
240
|
+
s.textContent = `@keyframes __idiotik_spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}body{animation:__idiotik_spin 2s linear infinite;transform-origin:center center}`;
|
|
241
|
+
document.head.appendChild(s);
|
|
242
|
+
},
|
|
243
|
+
glitch() {
|
|
244
|
+
const id = "__idiotik_glitch__"; if (document.getElementById(id)) return;
|
|
245
|
+
const s = document.createElement("style"); s.id = id;
|
|
246
|
+
s.textContent = `@keyframes __idiotik_glitch1{0%,100%{clip-path:inset(0 0 95% 0)}25%{clip-path:inset(30% 0 50% 0)}50%{clip-path:inset(60% 0 20% 0)}75%{clip-path:inset(10% 0 80% 0)}}@keyframes __idiotik_glitch2{0%,100%{clip-path:inset(80% 0 5% 0);transform:translate(-5px,0)}25%{clip-path:inset(20% 0 70% 0);transform:translate(5px,0)}50%{clip-path:inset(50% 0 30% 0);transform:translate(-3px,0)}75%{clip-path:inset(5% 0 90% 0);transform:translate(3px,0)}}body::before,body::after{content:'';position:fixed;top:0;left:0;width:100%;height:100%;background:inherit;pointer-events:none;z-index:9999}body::before{animation:__idiotik_glitch1 0.4s infinite;color:red;text-shadow:2px 0 red}body::after{animation:__idiotik_glitch2 0.4s infinite;color:blue;text-shadow:-2px 0 blue}`;
|
|
247
|
+
document.head.appendChild(s);
|
|
248
|
+
},
|
|
249
|
+
rainbow() {
|
|
250
|
+
const id = "__idiotik_rainbow__"; if (document.getElementById(id)) return;
|
|
251
|
+
const s = document.createElement("style"); s.id = id;
|
|
252
|
+
s.textContent = `@keyframes __idiotik_rainbow{0%{background:#ff0000}15%{background:#ff8800}30%{background:#ffff00}45%{background:#00ff00}60%{background:#0000ff}75%{background:#8800ff}90%{background:#ff00ff}100%{background:#ff0000}}body{animation:__idiotik_rainbow 0.5s infinite}`;
|
|
253
|
+
document.head.appendChild(s);
|
|
254
|
+
},
|
|
255
|
+
invert() {
|
|
256
|
+
const id = "__idiotik_invert__"; if (document.getElementById(id)) return;
|
|
257
|
+
const s = document.createElement("style"); s.id = id;
|
|
258
|
+
s.textContent = `body{filter:invert(1)}`;
|
|
259
|
+
document.head.appendChild(s);
|
|
260
|
+
},
|
|
261
|
+
matrix() {
|
|
262
|
+
const cid = "__idiotik_matrix__"; if (document.getElementById(cid)) return;
|
|
263
|
+
const canvas = document.createElement("canvas"); canvas.id = cid;
|
|
264
|
+
canvas.style.cssText = "position:fixed;top:0;left:0;z-index:9998;pointer-events:none;width:100vw;height:100vh;opacity:0.7;";
|
|
265
|
+
document.body.appendChild(canvas); _track(canvas, "htmlNodes");
|
|
266
|
+
const ctx = canvas.getContext("2d");
|
|
267
|
+
canvas.width = window.innerWidth; canvas.height = window.innerHeight;
|
|
268
|
+
const cols = Math.floor(canvas.width / 16);
|
|
269
|
+
const drops = Array(cols).fill(1);
|
|
270
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()";
|
|
271
|
+
_track(setInterval(() => {
|
|
272
|
+
ctx.fillStyle = "rgba(0,0,0,0.05)"; ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
273
|
+
ctx.fillStyle = "#0f0"; ctx.font = "16px monospace";
|
|
274
|
+
drops.forEach((y, i) => {
|
|
275
|
+
const ch = chars[Math.floor(Math.random() * chars.length)];
|
|
276
|
+
ctx.fillText(ch, i * 16, y * 16);
|
|
277
|
+
if (y * 16 > canvas.height && Math.random() > 0.975) drops[i] = 0;
|
|
278
|
+
drops[i]++;
|
|
279
|
+
});
|
|
280
|
+
}, 50), "intervals");
|
|
281
|
+
},
|
|
282
|
+
melt() {
|
|
283
|
+
const id = "__idiotik_melt__"; if (document.getElementById(id)) return;
|
|
284
|
+
const s = document.createElement("style"); s.id = id;
|
|
285
|
+
s.textContent = `@keyframes __idiotik_melt{0%{transform:skewY(0deg) scaleY(1)}50%{transform:skewY(5deg) scaleY(1.1)}100%{transform:skewY(-3deg) scaleY(0.9)}}body{animation:__idiotik_melt 1s ease-in-out infinite alternate;transform-origin:bottom}`;
|
|
286
|
+
document.head.appendChild(s);
|
|
287
|
+
},
|
|
288
|
+
vhs() {
|
|
289
|
+
const id = "__idiotik_vhs__"; if (document.getElementById(id)) return;
|
|
290
|
+
const s = document.createElement("style"); s.id = id;
|
|
291
|
+
s.textContent = `@keyframes __idiotik_vhs_scan{0%{top:-100%}100%{top:100%}}@keyframes __idiotik_vhs_track{0%,95%{transform:none}96%{transform:translate(-4px,0) skewX(-0.5deg)}97%{transform:translate(4px,0) skewX(0.5deg)}98%{transform:translate(-2px,0)}100%{transform:none}}body{animation:__idiotik_vhs_track 3s infinite}body::before{content:'';position:fixed;top:0;left:0;width:100%;height:3px;background:rgba(255,255,255,0.15);z-index:99999;pointer-events:none;animation:__idiotik_vhs_scan 4s linear infinite}body::after{content:'';position:fixed;top:0;left:0;width:100%;height:100%;background:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,0,0,0.08) 2px,rgba(0,0,0,0.08) 4px);pointer-events:none;z-index:99998}`;
|
|
292
|
+
document.head.appendChild(s);
|
|
293
|
+
},
|
|
294
|
+
static() {
|
|
295
|
+
const cid = "__idiotik_static__"; if (document.getElementById(cid)) return;
|
|
296
|
+
const canvas = document.createElement("canvas"); canvas.id = cid;
|
|
297
|
+
canvas.width = 256; canvas.height = 256;
|
|
298
|
+
canvas.style.cssText = "position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9997;pointer-events:none;opacity:0.12;image-rendering:pixelated;";
|
|
299
|
+
document.body.appendChild(canvas); _track(canvas, "htmlNodes");
|
|
300
|
+
const ctx = canvas.getContext("2d");
|
|
301
|
+
_track(setInterval(() => {
|
|
302
|
+
const img = ctx.createImageData(256, 256);
|
|
303
|
+
for (let i = 0; i < img.data.length; i += 4) {
|
|
304
|
+
const v = Math.random() * 255 | 0;
|
|
305
|
+
img.data[i] = img.data[i+1] = img.data[i+2] = v; img.data[i+3] = 255;
|
|
306
|
+
}
|
|
307
|
+
ctx.putImageData(img, 0, 0);
|
|
308
|
+
}, 40), "intervals");
|
|
309
|
+
},
|
|
310
|
+
zoom() {
|
|
311
|
+
const id = "__idiotik_zoom__"; if (document.getElementById(id)) return;
|
|
312
|
+
const s = document.createElement("style"); s.id = id;
|
|
313
|
+
s.textContent = `@keyframes __idiotik_zoom{0%,100%{transform:scale(1)}50%{transform:scale(1.08)}}body{animation:__idiotik_zoom 0.8s ease-in-out infinite}`;
|
|
314
|
+
document.head.appendChild(s);
|
|
315
|
+
},
|
|
316
|
+
bounce() {
|
|
317
|
+
const id = "__idiotik_bounce__"; if (document.getElementById(id)) return;
|
|
318
|
+
const s = document.createElement("style"); s.id = id;
|
|
319
|
+
s.textContent = `@keyframes __idiotik_bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-20px)}}body{animation:__idiotik_bounce 0.5s ease-in-out infinite}`;
|
|
320
|
+
document.head.appendChild(s);
|
|
321
|
+
},
|
|
322
|
+
flip() {
|
|
323
|
+
const id = "__idiotik_flip__"; if (document.getElementById(id)) return;
|
|
324
|
+
const s = document.createElement("style"); s.id = id;
|
|
325
|
+
s.textContent = `@keyframes __idiotik_flip{0%,100%{transform:scaleX(1)}50%{transform:scaleX(-1)}}body{animation:__idiotik_flip 1s step-end infinite}`;
|
|
326
|
+
document.head.appendChild(s);
|
|
327
|
+
},
|
|
328
|
+
blur() {
|
|
329
|
+
const id = "__idiotik_blur__"; if (document.getElementById(id)) return;
|
|
330
|
+
const s = document.createElement("style"); s.id = id;
|
|
331
|
+
s.textContent = `@keyframes __idiotik_blur{0%,100%{filter:blur(0px)}50%{filter:blur(8px)}}body{animation:__idiotik_blur 1s ease-in-out infinite}`;
|
|
332
|
+
document.head.appendChild(s);
|
|
333
|
+
},
|
|
334
|
+
darkmode() {
|
|
335
|
+
const id = "__idiotik_darkmode__"; if (document.getElementById(id)) return;
|
|
336
|
+
const s = document.createElement("style"); s.id = id;
|
|
337
|
+
s.textContent = `@keyframes __idiotik_dark{0%,100%{filter:brightness(1)}50%{filter:brightness(0)}}body{animation:__idiotik_dark 0.3s step-end infinite}`;
|
|
338
|
+
document.head.appendChild(s);
|
|
339
|
+
},
|
|
340
|
+
pixelate() {
|
|
341
|
+
const cid = "__idiotik_pixelate__"; if (document.getElementById(cid)) return;
|
|
342
|
+
const canvas = document.createElement("canvas"); canvas.id = cid;
|
|
343
|
+
canvas.style.cssText = "position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9996;pointer-events:none;image-rendering:pixelated;";
|
|
344
|
+
canvas.width = 64; canvas.height = 36;
|
|
345
|
+
document.body.appendChild(canvas); _track(canvas, "htmlNodes");
|
|
346
|
+
const ctx = canvas.getContext("2d");
|
|
347
|
+
let level = 0;
|
|
348
|
+
_track(setInterval(() => {
|
|
349
|
+
try { ctx.drawImage(document.documentElement, 0, 0, 64, 36); }
|
|
350
|
+
catch(e) { ctx.fillStyle = `hsl(${level * 10},100%,50%)`; ctx.fillRect(0, 0, 64, 36); }
|
|
351
|
+
level = (level + 1) % 36;
|
|
352
|
+
}, 100), "intervals");
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// āāā PRESET REGISTRY āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
357
|
+
const _presets = {
|
|
358
|
+
classic() {
|
|
359
|
+
idiotik.recursive("yes");
|
|
360
|
+
idiotik.startnow("effect:rainbow");
|
|
361
|
+
idiotik.startnow("effect:shake");
|
|
362
|
+
idiotik.start("say:YOU ARE AN IDIOT HA HA HA HA HA HA");
|
|
363
|
+
idiotik.repeat("inf");
|
|
364
|
+
idiotik.startnow("scream");
|
|
365
|
+
},
|
|
366
|
+
nuclear() {
|
|
367
|
+
idiotik.recursive("yes");
|
|
368
|
+
idiotik.volume(5000);
|
|
369
|
+
idiotik.startnow("effect:shake");
|
|
370
|
+
idiotik.startnow("effect:rainbow");
|
|
371
|
+
idiotik.startnow("effect:glitch");
|
|
372
|
+
idiotik.startnow("effect:spin");
|
|
373
|
+
idiotik.startnow("effect:matrix");
|
|
374
|
+
idiotik.startnow("effect:vhs");
|
|
375
|
+
idiotik.startnow("effect:static");
|
|
376
|
+
idiotik.startnow("effect:zoom");
|
|
377
|
+
idiotik.startnow("scream");
|
|
378
|
+
idiotik.startnow("fullscreen");
|
|
379
|
+
idiotik.startnow("freeze");
|
|
380
|
+
idiotik.startnow("cursor:none");
|
|
381
|
+
idiotik.startnow("haunt");
|
|
382
|
+
idiotik.start("say:ššš YOU ARE SO COOKED ššš");
|
|
383
|
+
idiotik.repeat("inf");
|
|
384
|
+
},
|
|
385
|
+
mild() {
|
|
386
|
+
idiotik.recursive("no");
|
|
387
|
+
idiotik.volume(100);
|
|
388
|
+
idiotik.startnow("effect:shake");
|
|
389
|
+
idiotik.start("say:gotcha lol");
|
|
390
|
+
idiotik.repeat(5);
|
|
391
|
+
},
|
|
392
|
+
rickroll() {
|
|
393
|
+
idiotik.recursive("no");
|
|
394
|
+
idiotik.startnow("redirect:https://www.youtube.com/watch?v=dQw4w9WgXcQ");
|
|
395
|
+
},
|
|
396
|
+
jumpscare() {
|
|
397
|
+
idiotik.recursive("yes");
|
|
398
|
+
idiotik.volume(300);
|
|
399
|
+
idiotik.wait(3000).then(() => {
|
|
400
|
+
idiotik.startnow("effect:glitch");
|
|
401
|
+
idiotik.startnow("jumpscare:https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Camponotus_flavomarginatus_ant.jpg/640px-Camponotus_flavomarginatus_ant.jpg");
|
|
402
|
+
idiotik.startnow("scream");
|
|
403
|
+
});
|
|
404
|
+
},
|
|
405
|
+
epilepsy() {
|
|
406
|
+
idiotik.recursive("yes");
|
|
407
|
+
idiotik.volume(450);
|
|
408
|
+
idiotik.startnow("effect:rainbow");
|
|
409
|
+
idiotik.startnow("effect:shake");
|
|
410
|
+
idiotik.startnow("effect:glitch");
|
|
411
|
+
idiotik.startnow("effect:invert");
|
|
412
|
+
idiotik.startnow("effect:static");
|
|
413
|
+
idiotik.startnow("cursor:rainbow");
|
|
414
|
+
idiotik.startnow("scream");
|
|
415
|
+
},
|
|
416
|
+
robux() {
|
|
417
|
+
idiotik.recursive("yes");
|
|
418
|
+
idiotik.volume(200);
|
|
419
|
+
idiotik.startnow("effect:rainbow");
|
|
420
|
+
idiotik.startnow("cursor:explode");
|
|
421
|
+
idiotik.start("say:FREE ROBUX AT PORNHUB.COM!!!");
|
|
422
|
+
idiotik.repeat("inf");
|
|
423
|
+
},
|
|
424
|
+
villain() {
|
|
425
|
+
idiotik.recursive("no");
|
|
426
|
+
idiotik.volume(150);
|
|
427
|
+
idiotik.startnow("effect:matrix");
|
|
428
|
+
idiotik.wait(2000).then(() => idiotik.startnow("effect:glitch"));
|
|
429
|
+
idiotik.wait(4000).then(() => {
|
|
430
|
+
idiotik.volume(500);
|
|
431
|
+
idiotik.startnow("effect:shake");
|
|
432
|
+
idiotik.startnow("scream");
|
|
433
|
+
idiotik.recursive("yes");
|
|
434
|
+
idiotik.start("say:did you really think you were safe šæ");
|
|
435
|
+
idiotik.repeat("inf");
|
|
436
|
+
});
|
|
437
|
+
},
|
|
438
|
+
melt() {
|
|
439
|
+
idiotik.recursive("no");
|
|
440
|
+
idiotik.volume(100);
|
|
441
|
+
idiotik.startnow("effect:melt");
|
|
442
|
+
idiotik.startnow("effect:spin");
|
|
443
|
+
idiotik.wait(3000).then(() => {
|
|
444
|
+
idiotik.volume(300);
|
|
445
|
+
idiotik.startnow("effect:rainbow");
|
|
446
|
+
idiotik.startnow("scream");
|
|
447
|
+
});
|
|
448
|
+
},
|
|
449
|
+
haunted() {
|
|
450
|
+
idiotik.recursive("yes");
|
|
451
|
+
idiotik.volume(80);
|
|
452
|
+
idiotik.startnow("effect:vhs");
|
|
453
|
+
idiotik.startnow("effect:glitch");
|
|
454
|
+
idiotik.startnow("cursor:ghost");
|
|
455
|
+
idiotik.startnow("haunt");
|
|
456
|
+
idiotik.wait(5000).then(() => {
|
|
457
|
+
idiotik.volume(600);
|
|
458
|
+
idiotik.startnow("scream");
|
|
459
|
+
idiotik.startnow("effect:flip");
|
|
460
|
+
idiotik.startnow("effect:shake");
|
|
461
|
+
idiotik.start("say:šļø i was here the whole time šļø");
|
|
462
|
+
idiotik.repeat("inf");
|
|
463
|
+
});
|
|
464
|
+
},
|
|
465
|
+
gravity() {
|
|
466
|
+
idiotik.recursive("yes");
|
|
467
|
+
idiotik.volume(200);
|
|
468
|
+
idiotik.startnow("gravitywarp");
|
|
469
|
+
idiotik.startnow("effect:melt");
|
|
470
|
+
idiotik.startnow("cursor:eyes");
|
|
471
|
+
idiotik.wait(3000).then(() => {
|
|
472
|
+
idiotik.startnow("effect:rainbow");
|
|
473
|
+
idiotik.startnow("scream");
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
// āāā CORE OBJECT āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
479
|
+
const idiotik = {
|
|
480
|
+
|
|
481
|
+
// āā GLOBAL TOGGLES āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
482
|
+
|
|
483
|
+
recursive(val) {
|
|
484
|
+
_recursive = (val === true || val === "yes" || val === 1);
|
|
485
|
+
if (_recursive) _initRecursion();
|
|
486
|
+
return idiotik;
|
|
487
|
+
},
|
|
488
|
+
|
|
489
|
+
volume(n) {
|
|
490
|
+
_volume = Math.max(0, Math.min(5000, Number(n)));
|
|
491
|
+
return idiotik;
|
|
492
|
+
},
|
|
493
|
+
|
|
494
|
+
popup(val) {
|
|
495
|
+
_popup = (val === true || val === "yes" || val === 1);
|
|
496
|
+
return idiotik;
|
|
497
|
+
},
|
|
498
|
+
|
|
499
|
+
// āā PRESET SYSTEM āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
500
|
+
|
|
501
|
+
preset(name) {
|
|
502
|
+
return function() {
|
|
503
|
+
if (_presets[name]) _presets[name]();
|
|
504
|
+
else console.warn(`idiotik.preset: unknown preset "${name}". try idiotik.list()`);
|
|
505
|
+
};
|
|
506
|
+
},
|
|
507
|
+
|
|
508
|
+
list() {
|
|
509
|
+
const names = Object.keys(_presets);
|
|
510
|
+
console.log(`%cidiotik.js ā available presets (${names.length})`, "font-weight:bold;color:#ff4444;font-size:14px;");
|
|
511
|
+
names.forEach(n => console.log(` %c⢠${n}`, "color:#ffcc00;"));
|
|
512
|
+
console.log('%cusage: idiotik.start("preset:name")', "color:#aaa;font-style:italic;");
|
|
513
|
+
return names;
|
|
514
|
+
},
|
|
515
|
+
|
|
516
|
+
registerPreset(name, fn) {
|
|
517
|
+
_presets[name] = fn;
|
|
518
|
+
return idiotik;
|
|
519
|
+
},
|
|
520
|
+
|
|
521
|
+
// āā SCRIPT CONTEXT āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
522
|
+
|
|
523
|
+
script() {
|
|
524
|
+
_scriptStack.push({ id: null, intervals: [], timeouts: [], audioSources: [], htmlNodes: [], _html: null });
|
|
525
|
+
return idiotik;
|
|
526
|
+
},
|
|
527
|
+
|
|
528
|
+
id(name) {
|
|
529
|
+
_requireScript("id");
|
|
530
|
+
const ctx = _currentScript();
|
|
531
|
+
ctx.id = name; _activeScripts[name] = ctx;
|
|
532
|
+
return idiotik;
|
|
533
|
+
},
|
|
534
|
+
|
|
535
|
+
html(code) {
|
|
536
|
+
_requireScript("html");
|
|
537
|
+
const ctx = _currentScript();
|
|
538
|
+
ctx._html = code;
|
|
539
|
+
const div = document.createElement("div");
|
|
540
|
+
div.innerHTML = code; document.body.appendChild(div); ctx.htmlNodes.push(div);
|
|
541
|
+
if (_recursive) {
|
|
542
|
+
const id = setInterval(() => {
|
|
543
|
+
const d = document.createElement("div"); d.innerHTML = code;
|
|
544
|
+
document.body.appendChild(d); ctx.htmlNodes.push(d);
|
|
545
|
+
}, 500);
|
|
546
|
+
ctx.intervals.push(id);
|
|
547
|
+
}
|
|
548
|
+
return idiotik;
|
|
549
|
+
},
|
|
550
|
+
|
|
551
|
+
end() {
|
|
552
|
+
if (!_currentScript()) throw new Error("idiotik.end() called outside a script");
|
|
553
|
+
_scriptStack.pop();
|
|
554
|
+
return idiotik;
|
|
555
|
+
},
|
|
556
|
+
|
|
557
|
+
// āā QUEUE / START SYSTEM āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* idiotik.start(ref)
|
|
561
|
+
*
|
|
562
|
+
* start() ā fire ALL queued tasks, clear queue
|
|
563
|
+
* start(n) ā fire task at 1-based position n (don't clear)
|
|
564
|
+
* start("effect:shake") ā enqueue effect
|
|
565
|
+
* start("say:hello") ā enqueue popup
|
|
566
|
+
* start("preset:robux") ā enqueue preset
|
|
567
|
+
* start("scream") ā enqueue scream
|
|
568
|
+
* start(fn) ā enqueue a raw function
|
|
569
|
+
*/
|
|
570
|
+
start(ref) {
|
|
571
|
+
// fire all
|
|
572
|
+
if (ref === undefined || ref === null) {
|
|
573
|
+
const tasks = [..._taskQueue];
|
|
574
|
+
_taskQueue = [];
|
|
575
|
+
tasks.forEach(fn => { try { fn(); } catch(e) {} });
|
|
576
|
+
return idiotik;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// fire by 1-based index
|
|
580
|
+
if (typeof ref === "number") {
|
|
581
|
+
const idx = ref - 1;
|
|
582
|
+
if (idx >= 0 && idx < _taskQueue.length) {
|
|
583
|
+
try { _taskQueue[idx](); } catch(e) {}
|
|
584
|
+
} else {
|
|
585
|
+
console.warn(`idiotik.start(${ref}): no task at position ${ref} (queue length: ${_taskQueue.length})`);
|
|
586
|
+
}
|
|
587
|
+
return idiotik;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// resolve and enqueue
|
|
591
|
+
const fn = _resolve(ref);
|
|
592
|
+
if (fn) _taskQueue.push(fn);
|
|
593
|
+
return idiotik;
|
|
594
|
+
},
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* idiotik.startnow(ref)
|
|
598
|
+
* Same DSL as start() but resolves AND fires immediately.
|
|
599
|
+
* Does NOT use the queue.
|
|
600
|
+
*/
|
|
601
|
+
startnow(ref) {
|
|
602
|
+
const fn = _resolve(ref);
|
|
603
|
+
if (fn) { try { fn(); } catch(e) {} }
|
|
604
|
+
return idiotik;
|
|
605
|
+
},
|
|
606
|
+
|
|
607
|
+
// āā CLICK BINDING āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* idiotik.click(target, ref?)
|
|
611
|
+
* Fires queued tasks (or ref) when a matching element is clicked.
|
|
612
|
+
* target: CSS selector or plain text matched against clickable elements.
|
|
613
|
+
* ref: optional DSL string or function ā if omitted, snapshots current queue.
|
|
614
|
+
*/
|
|
615
|
+
click(target, ref) {
|
|
616
|
+
const tasksSnapshot = ref ? null : [..._taskQueue];
|
|
617
|
+
|
|
618
|
+
const _fire = function(e) {
|
|
619
|
+
if (ref) {
|
|
620
|
+
const fn = _resolve(ref);
|
|
621
|
+
if (fn) { try { fn(e); } catch(err) {} }
|
|
622
|
+
} else {
|
|
623
|
+
tasksSnapshot.forEach(task => { try { task(e); } catch(err) {} });
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
const _attach = function() {
|
|
628
|
+
let els = [];
|
|
629
|
+
try { els = [...document.querySelectorAll(target)]; } catch(e) {}
|
|
630
|
+
if (!els.length) {
|
|
631
|
+
const lower = target.toLowerCase().trim();
|
|
632
|
+
els = [...document.querySelectorAll("button,a,input[type='button'],input[type='submit'],[role='button'],label,[onclick]")]
|
|
633
|
+
.filter(el => el.textContent.trim().toLowerCase().includes(lower)
|
|
634
|
+
|| (el.value && el.value.trim().toLowerCase().includes(lower)));
|
|
635
|
+
}
|
|
636
|
+
if (!els.length) console.warn(`idiotik.click: no elements found for "${target}" ā will retry on DOM changes`);
|
|
637
|
+
els.forEach(el => {
|
|
638
|
+
if (el.__idiotikClick) return;
|
|
639
|
+
el.__idiotikClick = true;
|
|
640
|
+
el.addEventListener("click", _fire);
|
|
641
|
+
_track(el, "htmlNodes");
|
|
642
|
+
});
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
if (document.readyState !== "loading") _attach();
|
|
646
|
+
else document.addEventListener("DOMContentLoaded", _attach);
|
|
647
|
+
|
|
648
|
+
const observer = new MutationObserver(_attach);
|
|
649
|
+
observer.observe(document.body || document.documentElement, { childList: true, subtree: true });
|
|
650
|
+
if (!_globalNodes._observers) _globalNodes._observers = [];
|
|
651
|
+
_globalNodes._observers.push(observer);
|
|
652
|
+
|
|
653
|
+
return idiotik;
|
|
654
|
+
},
|
|
655
|
+
|
|
656
|
+
queue(ref) {
|
|
657
|
+
const fn = _resolve(ref);
|
|
658
|
+
if (fn) _taskQueue.push(fn);
|
|
659
|
+
return idiotik;
|
|
660
|
+
},
|
|
661
|
+
|
|
662
|
+
clearQueue() {
|
|
663
|
+
_taskQueue = [];
|
|
664
|
+
return idiotik;
|
|
665
|
+
},
|
|
666
|
+
|
|
667
|
+
repeat(n) {
|
|
668
|
+
if (!_taskQueue.length) return idiotik;
|
|
669
|
+
const fn = _taskQueue[_taskQueue.length - 1];
|
|
670
|
+
const infinite = (n === Infinity || n === "inf" || n === "Infinity");
|
|
671
|
+
if (infinite) {
|
|
672
|
+
_track(setInterval(() => fn(), 100), "intervals");
|
|
673
|
+
} else {
|
|
674
|
+
let count = 0;
|
|
675
|
+
const id = setInterval(() => { fn(); count++; if (count >= n) clearInterval(id); }, 100);
|
|
676
|
+
_track(id, "intervals");
|
|
677
|
+
}
|
|
678
|
+
return idiotik;
|
|
679
|
+
},
|
|
680
|
+
|
|
681
|
+
get continue() { return idiotik; },
|
|
682
|
+
|
|
683
|
+
wait(ms) {
|
|
684
|
+
return new Promise(resolve => { _track(setTimeout(resolve, ms), "timeouts"); });
|
|
685
|
+
},
|
|
686
|
+
|
|
687
|
+
halt(name) {
|
|
688
|
+
const ctx = _activeScripts[name];
|
|
689
|
+
if (!ctx) return idiotik;
|
|
690
|
+
(ctx.intervals || []).forEach(id => clearInterval(id));
|
|
691
|
+
(ctx.timeouts || []).forEach(id => clearTimeout(id));
|
|
692
|
+
(ctx.audioSources || []).forEach(s => { try { s.stop(); } catch(e){} });
|
|
693
|
+
(ctx.htmlNodes || []).forEach(n => { try { n.remove(); } catch(e){} });
|
|
694
|
+
delete _activeScripts[name];
|
|
695
|
+
return idiotik;
|
|
696
|
+
},
|
|
697
|
+
|
|
698
|
+
nuke() {
|
|
699
|
+
_recursive = false;
|
|
700
|
+
_recursionInited = false;
|
|
701
|
+
_taskQueue = [];
|
|
702
|
+
_globalIntervals.forEach(id => clearInterval(id));
|
|
703
|
+
_globalTimeouts.forEach(id => clearTimeout(id));
|
|
704
|
+
_globalNodes.forEach(n => { try { n.remove(); } catch(e){} });
|
|
705
|
+
_globalIntervals = []; _globalTimeouts = []; _globalNodes = [];
|
|
706
|
+
Object.keys(_activeScripts).forEach(k => idiotik.halt(k));
|
|
707
|
+
idiotik.cleareffects();
|
|
708
|
+
document.body.style.cssText = "";
|
|
709
|
+
document.body.style.cursor = "";
|
|
710
|
+
if (_audioCtx) { try { _audioCtx.close(); } catch(e){} _audioCtx = null; }
|
|
711
|
+
_spawnedWindows.forEach(w => { try { w.close(); } catch(e){} });
|
|
712
|
+
_spawnedWindows = [];
|
|
713
|
+
if (_globalNodes._observers) {
|
|
714
|
+
_globalNodes._observers.forEach(obs => { try { obs.disconnect(); } catch(e){} });
|
|
715
|
+
_globalNodes._observers = [];
|
|
716
|
+
}
|
|
717
|
+
console.log("%cidiotik: nuked. RIP.", "color:#ff4444;font-weight:bold;");
|
|
718
|
+
return idiotik;
|
|
719
|
+
},
|
|
720
|
+
|
|
721
|
+
status() {
|
|
722
|
+
console.log("%cidiotik STATUS", "color:#ff4444;font-weight:bold;font-size:14px;");
|
|
723
|
+
console.log(" recursive:", _recursive);
|
|
724
|
+
console.log(" volume:", _volume);
|
|
725
|
+
console.log(" popup:", _popup);
|
|
726
|
+
console.log(" active effects:", [..._activeEffects]);
|
|
727
|
+
console.log(" queued tasks:", _taskQueue.length);
|
|
728
|
+
console.log(" active scripts:", Object.keys(_activeScripts));
|
|
729
|
+
console.log(" spawned windows:", _spawnedWindows.filter(w => !w.closed).length);
|
|
730
|
+
return idiotik;
|
|
731
|
+
},
|
|
732
|
+
|
|
733
|
+
// āā CONDITIONAL āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
734
|
+
|
|
735
|
+
_ifResult: null,
|
|
736
|
+
|
|
737
|
+
if(condition) {
|
|
738
|
+
idiotik._ifResult = !!condition;
|
|
739
|
+
return {
|
|
740
|
+
then(fn) {
|
|
741
|
+
if (idiotik._ifResult) fn();
|
|
742
|
+
return { else(fn2) { if (!idiotik._ifResult) fn2(); return idiotik; } };
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
},
|
|
746
|
+
|
|
747
|
+
else(fn) {
|
|
748
|
+
if (!idiotik._ifResult) fn();
|
|
749
|
+
return idiotik;
|
|
750
|
+
},
|
|
751
|
+
|
|
752
|
+
random(...methods) {
|
|
753
|
+
const pick = methods[Math.floor(Math.random() * methods.length)];
|
|
754
|
+
if (typeof pick === "function") pick();
|
|
755
|
+
return idiotik;
|
|
756
|
+
},
|
|
757
|
+
|
|
758
|
+
// āā CHAOS METHODS āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
759
|
+
|
|
760
|
+
say(msg) {
|
|
761
|
+
return function _say() {
|
|
762
|
+
if (_popup) {
|
|
763
|
+
const w = window.open("", "_blank", "width=300,height=150,toolbar=no,menubar=no,scrollbars=no,resizable=no");
|
|
764
|
+
if (w) {
|
|
765
|
+
w.document.write(`<html><body style="margin:0;display:flex;align-items:center;justify-content:center;height:100vh;font-family:Comic Sans MS,cursive;font-size:1.2rem;background:#fff;text-align:center;padding:1rem;">${msg}</body></html>`);
|
|
766
|
+
w.document.close();
|
|
767
|
+
if (_recursive) w.onload = () => setTimeout(_say, 100);
|
|
768
|
+
if (_recursive) setTimeout(_say, 100);
|
|
769
|
+
}
|
|
770
|
+
} else {
|
|
771
|
+
alert(msg);
|
|
772
|
+
if (_recursive) setTimeout(() => _say(), 0);
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
},
|
|
776
|
+
|
|
777
|
+
redirect(url) { return function() { window.location.href = url; }; },
|
|
778
|
+
|
|
779
|
+
freeze() {
|
|
780
|
+
return function() {
|
|
781
|
+
document.addEventListener("keydown", e => e.preventDefault(), true);
|
|
782
|
+
document.addEventListener("mousedown", e => e.preventDefault(), true);
|
|
783
|
+
document.addEventListener("contextmenu", e => e.preventDefault(), true);
|
|
784
|
+
};
|
|
785
|
+
},
|
|
786
|
+
|
|
787
|
+
fullscreen() {
|
|
788
|
+
return function _fs() {
|
|
789
|
+
const el = document.documentElement;
|
|
790
|
+
if (el.requestFullscreen) el.requestFullscreen();
|
|
791
|
+
else if (el.webkitRequestFullscreen) el.webkitRequestFullscreen();
|
|
792
|
+
document.addEventListener("fullscreenchange", () => {
|
|
793
|
+
if (!document.fullscreenElement && _recursive) setTimeout(_fs, 100);
|
|
794
|
+
});
|
|
795
|
+
};
|
|
796
|
+
},
|
|
797
|
+
|
|
798
|
+
jumpscare(imgUrl, sfxUrl) {
|
|
799
|
+
return function _js() {
|
|
800
|
+
const div = document.createElement("div");
|
|
801
|
+
div.style.cssText = "position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:99999;background:#000;display:flex;align-items:center;justify-content:center;";
|
|
802
|
+
const img = document.createElement("img");
|
|
803
|
+
img.src = imgUrl; img.style.cssText = "max-width:100%;max-height:100%;object-fit:contain;";
|
|
804
|
+
div.appendChild(img); document.body.appendChild(div); _track(div, "htmlNodes");
|
|
805
|
+
if (sfxUrl) _loadAndPlay(_parseAudioUrl(sfxUrl));
|
|
806
|
+
const ctx = _currentScript(); if (ctx) ctx.htmlNodes.push(div);
|
|
807
|
+
if (_recursive) setTimeout(() => { div.remove(); _js(); }, 1000);
|
|
808
|
+
};
|
|
809
|
+
},
|
|
810
|
+
|
|
811
|
+
scream() {
|
|
812
|
+
return function _scream() {
|
|
813
|
+
const ctx = _getAudioCtx();
|
|
814
|
+
const osc = ctx.createOscillator();
|
|
815
|
+
const gain = ctx.createGain();
|
|
816
|
+
osc.type = "sawtooth"; osc.frequency.value = 880;
|
|
817
|
+
osc.frequency.linearRampToValueAtTime(440, ctx.currentTime + 1);
|
|
818
|
+
osc.frequency.linearRampToValueAtTime(1760, ctx.currentTime + 2);
|
|
819
|
+
gain.gain.value = Math.min(_volume / 100, 10);
|
|
820
|
+
osc.connect(gain); gain.connect(ctx.destination);
|
|
821
|
+
osc.start(); setTimeout(() => osc.stop(), 2000);
|
|
822
|
+
if (_recursive) setTimeout(_scream, 2100);
|
|
823
|
+
};
|
|
824
|
+
},
|
|
825
|
+
|
|
826
|
+
noise(durationSec) {
|
|
827
|
+
const dur = durationSec || 1;
|
|
828
|
+
return function _noise() {
|
|
829
|
+
const source = _whiteNoise(dur);
|
|
830
|
+
source.start(); source.stop(_getAudioCtx().currentTime + dur);
|
|
831
|
+
if (_recursive) setTimeout(_noise, dur * 1000 + 100);
|
|
832
|
+
};
|
|
833
|
+
},
|
|
834
|
+
|
|
835
|
+
haunt() {
|
|
836
|
+
const msgs = ["šļø", "i see you", "leave.", "you can't close this", "help", "HA", "why", "š©ø", "turn around"];
|
|
837
|
+
return function _haunt() {
|
|
838
|
+
const span = document.createElement("div");
|
|
839
|
+
span.textContent = msgs[Math.floor(Math.random() * msgs.length)];
|
|
840
|
+
span.style.cssText = `position:fixed;left:${Math.random()*90}vw;top:${Math.random()*90}vh;font-size:${16+Math.random()*40}px;color:rgba(255,0,0,${0.3+Math.random()*0.7});pointer-events:none;z-index:99990;font-family:serif;font-style:italic;transition:opacity 1s;text-shadow:0 0 10px red;`;
|
|
841
|
+
document.body.appendChild(span); _track(span, "htmlNodes");
|
|
842
|
+
setTimeout(() => { span.style.opacity = "0"; setTimeout(() => span.remove(), 1000); }, 1500);
|
|
843
|
+
if (_recursive) setTimeout(_haunt, 800 + Math.random() * 1200);
|
|
844
|
+
};
|
|
845
|
+
},
|
|
846
|
+
|
|
847
|
+
fakeCursor() {
|
|
848
|
+
return function() {
|
|
849
|
+
const cur = document.createElement("div");
|
|
850
|
+
cur.textContent = "š±ļø";
|
|
851
|
+
cur.style.cssText = "position:fixed;font-size:20px;pointer-events:none;z-index:999999;transition:left 0.2s,top 0.2s;";
|
|
852
|
+
document.body.appendChild(cur); _track(cur, "htmlNodes");
|
|
853
|
+
let mx = 0, my = 0;
|
|
854
|
+
document.addEventListener("mousemove", e => { mx = e.clientX; my = e.clientY; });
|
|
855
|
+
_track(setInterval(() => {
|
|
856
|
+
cur.style.left = (mx + 15 + Math.sin(Date.now() / 200) * 10) + "px";
|
|
857
|
+
cur.style.top = (my + 15 + Math.cos(Date.now() / 200) * 10) + "px";
|
|
858
|
+
}, 50), "intervals");
|
|
859
|
+
};
|
|
860
|
+
},
|
|
861
|
+
|
|
862
|
+
gravityWarp() {
|
|
863
|
+
return function _gw() {
|
|
864
|
+
[...document.querySelectorAll("p,h1,h2,h3,h4,img,div,a,button,span")]
|
|
865
|
+
.filter(e => e.children.length === 0 || e.tagName === "IMG")
|
|
866
|
+
.forEach(el => {
|
|
867
|
+
if (el.dataset.idiotikGravity) return;
|
|
868
|
+
el.dataset.idiotikGravity = "1";
|
|
869
|
+
const orig = el.style.transform; let vy = 0;
|
|
870
|
+
const id = setInterval(() => {
|
|
871
|
+
vy += 0.5;
|
|
872
|
+
const cur = parseFloat(el.dataset.gy || "0");
|
|
873
|
+
el.dataset.gy = cur + vy;
|
|
874
|
+
el.style.transform = `${orig} translateY(${cur}px) rotate(${cur * 0.1}deg)`;
|
|
875
|
+
if (cur > window.innerHeight * 1.5) clearInterval(id);
|
|
876
|
+
}, 50);
|
|
877
|
+
});
|
|
878
|
+
if (_recursive) setTimeout(_gw, 5000);
|
|
879
|
+
};
|
|
880
|
+
},
|
|
881
|
+
|
|
882
|
+
audio(urlOrFile) {
|
|
883
|
+
const parsed = _parseAudioUrl(urlOrFile);
|
|
884
|
+
return async function _audio() {
|
|
885
|
+
const source = await _loadAndPlay(parsed);
|
|
886
|
+
const ctx = _currentScript(); if (ctx) ctx.audioSources.push(source);
|
|
887
|
+
if (_recursive) source.addEventListener?.("ended", _audio);
|
|
888
|
+
};
|
|
889
|
+
},
|
|
890
|
+
|
|
891
|
+
effect(name) {
|
|
892
|
+
return function() {
|
|
893
|
+
if (_effectImpls[name]) { _activeEffects.add(name); _effectImpls[name](); }
|
|
894
|
+
else console.warn(`idiotik.effect: unknown effect "${name}"`);
|
|
895
|
+
};
|
|
896
|
+
},
|
|
897
|
+
|
|
898
|
+
cleareffects() {
|
|
899
|
+
_activeEffects.clear();
|
|
900
|
+
document.querySelectorAll("[id^='__idiotik_']").forEach(el => el.remove());
|
|
901
|
+
document.body.style.animation = "";
|
|
902
|
+
document.body.style.filter = "";
|
|
903
|
+
},
|
|
904
|
+
|
|
905
|
+
cursor(preset) {
|
|
906
|
+
return function() {
|
|
907
|
+
const val = _cursorPresets[preset];
|
|
908
|
+
if (!val) { document.body.style.cursor = `url(${preset}), auto`; return; }
|
|
909
|
+
if (val === "__rainbow__") {
|
|
910
|
+
let h = 0;
|
|
911
|
+
_track(setInterval(() => {
|
|
912
|
+
const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><circle cx='10' cy='10' r='10' fill='hsl(${h},100%,50%)'/></svg>`;
|
|
913
|
+
document.body.style.cursor = `url("data:image/svg+xml,${encodeURIComponent(svg)}"), auto`;
|
|
914
|
+
h = (h + 10) % 360;
|
|
915
|
+
}, 50), "intervals");
|
|
916
|
+
} else if (val === "__wiggle__") {
|
|
917
|
+
document.addEventListener("mousemove", () => {
|
|
918
|
+
const offset = Math.sin(Date.now() / 100) * 10;
|
|
919
|
+
document.body.style.cursor = `url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><text y='16' font-size='16'>š</text></svg>") ${offset} 0, auto`;
|
|
920
|
+
});
|
|
921
|
+
} else if (val === "__explode__") {
|
|
922
|
+
document.addEventListener("click", e => {
|
|
923
|
+
for (let i = 0; i < 12; i++) {
|
|
924
|
+
const p = document.createElement("div");
|
|
925
|
+
p.textContent = ["š„","āØ","ā","š„"][i % 4];
|
|
926
|
+
p.style.cssText = `position:fixed;left:${e.clientX}px;top:${e.clientY}px;font-size:20px;pointer-events:none;z-index:99999;transition:all 0.6s;`;
|
|
927
|
+
document.body.appendChild(p); _track(p, "htmlNodes");
|
|
928
|
+
const angle = (i / 12) * 2 * Math.PI;
|
|
929
|
+
setTimeout(() => { p.style.transform = `translate(${Math.cos(angle)*60}px,${Math.sin(angle)*60}px)`; p.style.opacity = "0"; }, 10);
|
|
930
|
+
setTimeout(() => p.remove(), 700);
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
} else if (val === "__ghost__") {
|
|
934
|
+
document.body.style.cursor = "none";
|
|
935
|
+
const ghost = document.createElement("div");
|
|
936
|
+
ghost.textContent = "š»";
|
|
937
|
+
ghost.style.cssText = "position:fixed;font-size:24px;pointer-events:none;z-index:999999;transition:left 0.4s ease,top 0.4s ease;";
|
|
938
|
+
document.body.appendChild(ghost); _track(ghost, "htmlNodes");
|
|
939
|
+
let gx = 0, gy = 0;
|
|
940
|
+
document.addEventListener("mousemove", e => { gx = e.clientX; gy = e.clientY; });
|
|
941
|
+
_track(setInterval(() => {
|
|
942
|
+
ghost.style.left = gx + "px"; ghost.style.top = gy + "px";
|
|
943
|
+
ghost.style.opacity = (0.5 + 0.5 * Math.sin(Date.now() / 300)).toString();
|
|
944
|
+
}, 50), "intervals");
|
|
945
|
+
} else if (val === "__eyes__") {
|
|
946
|
+
document.body.style.cursor = "none";
|
|
947
|
+
["left:30vw", "left:60vw"].forEach(pos => {
|
|
948
|
+
const eye = document.createElement("div");
|
|
949
|
+
eye.style.cssText = `position:fixed;top:50vh;${pos};font-size:48px;pointer-events:none;z-index:999999;transition:transform 0.1s;`;
|
|
950
|
+
eye.textContent = "šļø"; document.body.appendChild(eye); _track(eye, "htmlNodes");
|
|
951
|
+
});
|
|
952
|
+
document.addEventListener("mousemove", e => {
|
|
953
|
+
document.querySelectorAll("[style*='šļø']").forEach(el => {
|
|
954
|
+
const rect = el.getBoundingClientRect();
|
|
955
|
+
const dx = e.clientX - (rect.left + rect.width / 2);
|
|
956
|
+
const dy = e.clientY - (rect.top + rect.height / 2);
|
|
957
|
+
el.style.transform = `rotate(${Math.atan2(dy, dx)}rad)`;
|
|
958
|
+
});
|
|
959
|
+
});
|
|
960
|
+
} else {
|
|
961
|
+
document.body.style.cursor = val;
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
},
|
|
965
|
+
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
// āāā EXPORT āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
969
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
970
|
+
module.exports = idiotik;
|
|
971
|
+
} else {
|
|
972
|
+
global.idiotik = idiotik;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
})(typeof window !== "undefined" ? window : global);
|