idiotik.js 1.0.1 → 1.0.12

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.
Files changed (2) hide show
  1. package/package.json +7 -2
  2. package/src/idiotik.js +180 -110
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "idiotik.js",
3
- "version": "1.0.1",
3
+ "version": "1.0.12",
4
4
  "description": "youareanidiot-style chaos toolkit for the browser",
5
5
  "main": "src/idiotik.js",
6
6
  "scripts": {
7
7
  "build": "node build.js"
8
8
  },
9
- "keywords": ["chaos", "prank", "browser", "youareanidiot"],
9
+ "keywords": [
10
+ "chaos",
11
+ "prank",
12
+ "browser",
13
+ "youareanidiot"
14
+ ],
10
15
  "license": "MIT",
11
16
  "files": [
12
17
  "src/",
package/src/idiotik.js CHANGED
@@ -8,11 +8,110 @@
8
8
  // ─── GLOBAL STATE ───────────────────────────────────────────────────────────
9
9
  let _recursive = true;
10
10
  let _volume = 100;
11
- let _activeScripts = {}; // id -> { intervals, timeouts, audioNodes }
11
+ let _activeScripts = {};
12
12
  let _activeEffects = new Set();
13
13
  let _audioCtx = null;
14
- let _lastStarted = null; // last method ref passed to idiotik.start()
15
- let _scriptStack = []; // current script context stack
14
+ let _lastStarted = null;
15
+ let _scriptStack = [];
16
+
17
+ // ─── PRESET REGISTRY ────────────────────────────────────────────────────────
18
+ const _presets = {
19
+ classic: function() {
20
+ idiotik.recursive("yes");
21
+ idiotik.start(idiotik.effect("rainbow"))();
22
+ idiotik.start(idiotik.effect("shake"))();
23
+ idiotik.start(idiotik.say("YOU ARE AN IDIOT HA HA HA HA HA HA"));
24
+ idiotik.repeat("inf");
25
+ idiotik.continue;
26
+ idiotik.start(idiotik.scream())();
27
+ },
28
+ nuclear: function() {
29
+ idiotik.recursive("yes");
30
+ idiotik.volume(5000);
31
+ idiotik.start(idiotik.effect("shake"))();
32
+ idiotik.start(idiotik.effect("rainbow"))();
33
+ idiotik.start(idiotik.effect("glitch"))();
34
+ idiotik.start(idiotik.effect("spin"))();
35
+ idiotik.start(idiotik.effect("matrix"))();
36
+ idiotik.start(idiotik.scream())();
37
+ idiotik.start(idiotik.fullscreen())();
38
+ idiotik.start(idiotik.freeze())();
39
+ idiotik.start(idiotik.cursor("none"))();
40
+ idiotik.start(idiotik.say("💀💀💀 YOU ARE SO COOKED 💀💀💀"));
41
+ idiotik.repeat("inf");
42
+ },
43
+ mild: function() {
44
+ idiotik.recursive("no");
45
+ idiotik.volume(100);
46
+ idiotik.start(idiotik.effect("shake"))();
47
+ idiotik.start(idiotik.say("gotcha lol"));
48
+ idiotik.repeat(5);
49
+ },
50
+ rickroll: function() {
51
+ idiotik.recursive("no");
52
+ idiotik.start(idiotik.redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ"))();
53
+ },
54
+ jumpscare: function() {
55
+ idiotik.recursive("yes");
56
+ idiotik.volume(300);
57
+ idiotik.wait(3000).then(() => {
58
+ idiotik.start(idiotik.effect("glitch"))();
59
+ idiotik.start(idiotik.jumpscare(
60
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Camponotus_flavomarginatus_ant.jpg/640px-Camponotus_flavomarginatus_ant.jpg"
61
+ ))();
62
+ idiotik.start(idiotik.scream())();
63
+ });
64
+ },
65
+ epilepsy: function() {
66
+ idiotik.recursive("yes");
67
+ idiotik.volume(450);
68
+ idiotik.start(idiotik.effect("rainbow"))();
69
+ idiotik.start(idiotik.effect("shake"))();
70
+ idiotik.start(idiotik.effect("glitch"))();
71
+ idiotik.start(idiotik.effect("invert"))();
72
+ idiotik.start(idiotik.cursor("rainbow"))();
73
+ idiotik.start(idiotik.scream())();
74
+ },
75
+ robux: function() {
76
+ idiotik.recursive("yes");
77
+ idiotik.volume(200);
78
+ idiotik.script();
79
+ idiotik.id("robux");
80
+ idiotik.start(idiotik.say("FREE ROBUX AT PORNHUB.COM!!!"));
81
+ idiotik.repeat("inf");
82
+ idiotik.continue;
83
+ idiotik.end();
84
+ idiotik.start(idiotik.effect("rainbow"))();
85
+ idiotik.start(idiotik.cursor("explode"))();
86
+ },
87
+ villain: function() {
88
+ idiotik.recursive("no");
89
+ idiotik.volume(150);
90
+ idiotik.start(idiotik.effect("matrix"))();
91
+ idiotik.wait(2000).then(() => {
92
+ idiotik.start(idiotik.effect("glitch"))();
93
+ });
94
+ idiotik.wait(4000).then(() => {
95
+ idiotik.volume(500);
96
+ idiotik.start(idiotik.effect("shake"))();
97
+ idiotik.start(idiotik.scream())();
98
+ idiotik.recursive("yes");
99
+ idiotik.start(idiotik.say("did you really think you were safe 🗿"));
100
+ idiotik.repeat("inf");
101
+ });
102
+ },
103
+ melt: function() {
104
+ idiotik.recursive("no");
105
+ idiotik.volume(100);
106
+ idiotik.start(idiotik.effect("melt"))();
107
+ idiotik.start(idiotik.effect("spin"))();
108
+ idiotik.wait(3000).then(() => {
109
+ idiotik.volume(300);
110
+ idiotik.start(idiotik.effect("rainbow"))();
111
+ idiotik.start(idiotik.scream())();
112
+ });
113
+ },
114
+ };
16
115
 
17
116
  // ─── HELPERS ────────────────────────────────────────────────────────────────
18
117
  function _getAudioCtx() {
@@ -40,22 +139,14 @@
40
139
  const source = ctx.createBufferSource();
41
140
  source.buffer = buffer;
42
141
  source.loop = true;
43
-
44
142
  const gainNode = ctx.createGain();
45
143
  const rawVol = _volume;
46
-
47
- // volume scaling
48
- if (rawVol <= 100) {
49
- gainNode.gain.value = rawVol / 100;
50
- } else if (rawVol <= 200) {
144
+ if (rawVol <= 200) {
51
145
  gainNode.gain.value = rawVol / 100;
52
146
  } else {
53
147
  gainNode.gain.value = Math.min(rawVol / 100, 50);
54
148
  }
55
-
56
149
  let lastNode = source;
57
-
58
- // bass boost kicks in at 201
59
150
  if (rawVol > 200) {
60
151
  const bassBoost = ctx.createBiquadFilter();
61
152
  bassBoost.type = "lowshelf";
@@ -65,17 +156,15 @@
65
156
  lastNode.connect(bassBoost);
66
157
  lastNode = bassBoost;
67
158
  }
68
-
69
- // full EQ rape kicks in at 450
70
159
  if (rawVol >= 450) {
71
160
  const bands = [
72
- { type: "lowshelf", freq: 60, gain: 40 },
73
- { type: "peaking", freq: 250, gain: 40 },
74
- { type: "peaking", freq: 500, gain: 40 },
75
- { type: "peaking", freq: 1500, gain: 40 },
76
- { type: "peaking", freq: 4000, gain: 40 },
77
- { type: "peaking", freq: 8000, gain: 40 },
78
- { type: "highshelf", freq: 16000, gain: 40 },
161
+ { type: "lowshelf", freq: 60, gain: 40 },
162
+ { type: "peaking", freq: 250, gain: 40 },
163
+ { type: "peaking", freq: 500, gain: 40 },
164
+ { type: "peaking", freq: 1500, gain: 40 },
165
+ { type: "peaking", freq: 4000, gain: 40 },
166
+ { type: "peaking", freq: 8000, gain: 40 },
167
+ { type: "highshelf", freq: 16000, gain: 40 },
79
168
  ];
80
169
  for (const b of bands) {
81
170
  const f = ctx.createBiquadFilter();
@@ -86,7 +175,6 @@
86
175
  lastNode = f;
87
176
  }
88
177
  }
89
-
90
178
  lastNode.connect(gainNode);
91
179
  gainNode.connect(ctx.destination);
92
180
  return source;
@@ -102,16 +190,22 @@
102
190
  return source;
103
191
  }
104
192
 
193
+ function _parseAudioUrl(urlOrFile) {
194
+ if (typeof urlOrFile === "string" && urlOrFile.startsWith("file://")) {
195
+ return urlOrFile.replace("file://", "");
196
+ }
197
+ return urlOrFile;
198
+ }
199
+
105
200
  // ─── CURSOR PRESETS ─────────────────────────────────────────────────────────
106
201
  const _cursorPresets = {
107
- hand: "pointer",
108
- none: "none",
202
+ hand: "pointer",
203
+ none: "none",
109
204
  crosshair: "crosshair",
110
- wait: "wait",
111
- // animated ones inject a style tag
112
- rainbow: "__rainbow__",
113
- wiggle: "__wiggle__",
114
- explode: "__explode__",
205
+ wait: "wait",
206
+ rainbow: "__rainbow__",
207
+ wiggle: "__wiggle__",
208
+ explode: "__explode__",
115
209
  };
116
210
 
117
211
  // ─── EFFECT IMPLEMENTATIONS ─────────────────────────────────────────────────
@@ -211,10 +305,10 @@
211
305
  },
212
306
  };
213
307
 
214
- // ─── CORE idiotik OBJECT ───────────────────────────────────────────────────────
308
+ // ─── CORE OBJECT ────────────────────────────────────────────────────────────
215
309
  const idiotik = {
216
310
 
217
- // ── GLOBAL TOGGLES ─────────────────────────────────────────────────────────
311
+ // ── GLOBAL TOGGLES ───────────────────────────────────────────────────────
218
312
 
219
313
  recursive(val) {
220
314
  _recursive = (val === true || val === "yes" || val === 1);
@@ -226,7 +320,32 @@
226
320
  return idiotik;
227
321
  },
228
322
 
229
- // ── SCRIPT CONTEXT ─────────────────────────────────────────────────────────
323
+ // ── PRESET SYSTEM ────────────────────────────────────────────────────────
324
+
325
+ preset(name) {
326
+ return function() {
327
+ if (_presets[name]) {
328
+ _presets[name]();
329
+ } else {
330
+ console.warn(`idiotik.preset: unknown preset "${name}". run idiotik.list() to see available presets.`);
331
+ }
332
+ };
333
+ },
334
+
335
+ list() {
336
+ const names = Object.keys(_presets);
337
+ console.log(`%cidiotik.js — available presets (${names.length})`, "font-weight:bold;color:#ff4444;font-size:14px;");
338
+ names.forEach(n => console.log(` %c• ${n}`, "color:#ffcc00;"));
339
+ console.log('%cusage: idiotik.start(idiotik.preset("name"))()', "color:#aaa;font-style:italic;");
340
+ return names;
341
+ },
342
+
343
+ registerPreset(name, fn) {
344
+ _presets[name] = fn;
345
+ return idiotik;
346
+ },
347
+
348
+ // ── SCRIPT CONTEXT ───────────────────────────────────────────────────────
230
349
 
231
350
  script() {
232
351
  const ctx = {
@@ -253,6 +372,19 @@
253
372
  _requireScript("html");
254
373
  const ctx = _currentScript();
255
374
  ctx._html = code;
375
+ const div = document.createElement("div");
376
+ div.innerHTML = code;
377
+ document.body.appendChild(div);
378
+ ctx.htmlNodes.push(div);
379
+ if (_recursive) {
380
+ const id = setInterval(() => {
381
+ const d = document.createElement("div");
382
+ d.innerHTML = code;
383
+ document.body.appendChild(d);
384
+ ctx.htmlNodes.push(d);
385
+ }, 500);
386
+ ctx.intervals.push(id);
387
+ }
256
388
  return idiotik;
257
389
  },
258
390
 
@@ -262,13 +394,11 @@
262
394
  return idiotik;
263
395
  },
264
396
 
265
- // ── FLOW CONTROL ───────────────────────────────────────────────────────────
397
+ // ── FLOW CONTROL ─────────────────────────────────────────────────────────
266
398
 
267
399
  start(ref) {
268
400
  _lastStarted = ref;
269
- if (typeof ref === "function") {
270
- ref();
271
- }
401
+ if (typeof ref === "function") ref();
272
402
  return idiotik;
273
403
  },
274
404
 
@@ -292,7 +422,6 @@
292
422
  },
293
423
 
294
424
  get continue() {
295
- // no-op — execution continues naturally (async stuff already running)
296
425
  return idiotik;
297
426
  },
298
427
 
@@ -314,7 +443,7 @@
314
443
  return idiotik;
315
444
  },
316
445
 
317
- // ── CONDITIONAL ────────────────────────────────────────────────────────────
446
+ // ── CONDITIONAL ──────────────────────────────────────────────────────────
318
447
 
319
448
  _ifResult: null,
320
449
 
@@ -323,9 +452,7 @@
323
452
  return {
324
453
  then(fn) {
325
454
  if (idiotik._ifResult) fn();
326
- return {
327
- else(fn2) { if (!idiotik._ifResult) fn2(); return idiotik; }
328
- };
455
+ return { else(fn2) { if (!idiotik._ifResult) fn2(); return idiotik; } };
329
456
  }
330
457
  };
331
458
  },
@@ -341,7 +468,7 @@
341
468
  return idiotik;
342
469
  },
343
470
 
344
- // ── CHAOS METHODS ──────────────────────────────────────────────────────────
471
+ // ── CHAOS METHODS ────────────────────────────────────────────────────────
345
472
 
346
473
  say(msg) {
347
474
  return function _say() {
@@ -351,9 +478,7 @@
351
478
  },
352
479
 
353
480
  redirect(url) {
354
- return function() {
355
- window.location.href = url;
356
- };
481
+ return function() { window.location.href = url; };
357
482
  },
358
483
 
359
484
  freeze() {
@@ -384,10 +509,7 @@
384
509
  img.style.cssText = "max-width:100%;max-height:100%;object-fit:contain;";
385
510
  div.appendChild(img);
386
511
  document.body.appendChild(div);
387
- if (sfxUrl) {
388
- const parsed = _parseAudioUrl(sfxUrl);
389
- _loadAndPlay(parsed);
390
- }
512
+ if (sfxUrl) _loadAndPlay(_parseAudioUrl(sfxUrl));
391
513
  const ctx = _currentScript();
392
514
  if (ctx) ctx.htmlNodes.push(div);
393
515
  if (_recursive) setTimeout(() => { div.remove(); _js(); }, 1000);
@@ -395,7 +517,7 @@
395
517
  },
396
518
 
397
519
  scream() {
398
- return function() {
520
+ return function _scream() {
399
521
  const ctx = _getAudioCtx();
400
522
  const osc = ctx.createOscillator();
401
523
  const gain = ctx.createGain();
@@ -406,11 +528,11 @@
406
528
  gain.connect(ctx.destination);
407
529
  osc.start();
408
530
  setTimeout(() => osc.stop(), 2000);
409
- if (_recursive) setTimeout(idiotik.scream()(), 2100);
531
+ if (_recursive) setTimeout(_scream, 2100);
410
532
  };
411
533
  },
412
534
 
413
- // ── AUDIO ──────────────────────────────────────────────────────────────────
535
+ // ── AUDIO ────────────────────────────────────────────────────────────────
414
536
 
415
537
  audio(urlOrFile) {
416
538
  const parsed = _parseAudioUrl(urlOrFile);
@@ -422,7 +544,7 @@
422
544
  };
423
545
  },
424
546
 
425
- // ── EFFECT ─────────────────────────────────────────────────────────────────
547
+ // ── EFFECT ───────────────────────────────────────────────────────────────
426
548
 
427
549
  effect(name) {
428
550
  return function() {
@@ -430,7 +552,7 @@
430
552
  _activeEffects.add(name);
431
553
  _effectImpls[name]();
432
554
  } else {
433
- console.warn(`idiotik.effect: unknown preset "${name}"`);
555
+ console.warn(`idiotik.effect: unknown effect "${name}"`);
434
556
  }
435
557
  };
436
558
  },
@@ -440,13 +562,12 @@
440
562
  document.querySelectorAll("[id^='__idiotik_']").forEach(el => el.remove());
441
563
  },
442
564
 
443
- // ── CURSOR ─────────────────────────────────────────────────────────────────
565
+ // ── CURSOR ───────────────────────────────────────────────────────────────
444
566
 
445
567
  cursor(preset) {
446
568
  return function() {
447
569
  const val = _cursorPresets[preset];
448
570
  if (!val) {
449
- // treat as URL
450
571
  document.body.style.cursor = `url(${preset}), auto`;
451
572
  return;
452
573
  }
@@ -454,12 +575,11 @@
454
575
  let h = 0;
455
576
  setInterval(() => {
456
577
  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>`;
457
- const url = `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
458
- document.body.style.cursor = `${url}, auto`;
578
+ document.body.style.cursor = `url("data:image/svg+xml,${encodeURIComponent(svg)}"), auto`;
459
579
  h = (h + 10) % 360;
460
580
  }, 50);
461
581
  } else if (val === "__wiggle__") {
462
- document.addEventListener("mousemove", e => {
582
+ document.addEventListener("mousemove", () => {
463
583
  const offset = Math.sin(Date.now() / 100) * 10;
464
584
  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`;
465
585
  });
@@ -484,58 +604,8 @@
484
604
  };
485
605
  },
486
606
 
487
- // ── PRESETS ────────────────────────────────────────────────────────────────
488
-
489
- classic() {
490
- return function() {
491
- idiotik.recursive("yes");
492
- idiotik.start(idiotik.say("YOU ARE AN IDIOT HA HA HA HA HA HA"));
493
- idiotik.start(idiotik.effect("rainbow"))();
494
- idiotik.start(idiotik.effect("shake"))();
495
- idiotik.start(idiotik.scream())();
496
- };
497
- },
498
-
499
- mild() {
500
- return function() {
501
- idiotik.recursive("no");
502
- idiotik.start(idiotik.say("gotcha lol"));
503
- idiotik.start(idiotik.effect("shake"))();
504
- };
505
- },
506
-
507
- nuclear() {
508
- return function() {
509
- idiotik.recursive("yes");
510
- idiotik.volume(5000);
511
- idiotik.start(idiotik.effect("shake"))();
512
- idiotik.start(idiotik.effect("rainbow"))();
513
- idiotik.start(idiotik.effect("glitch"))();
514
- idiotik.start(idiotik.effect("spin"))();
515
- idiotik.start(idiotik.scream())();
516
- idiotik.start(idiotik.fullscreen())();
517
- idiotik.start(idiotik.freeze())();
518
- idiotik.start(idiotik.say("💀💀💀 YOU ARE SO COOKED 💀💀💀"));
519
- };
520
- },
521
-
522
- rickroll() {
523
- return function() {
524
- idiotik.recursive("no");
525
- idiotik.start(idiotik.redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ"))();
526
- };
527
- },
528
-
529
607
  };
530
608
 
531
- // ─── INTERNAL UTILS ─────────────────────────────────────────────────────────
532
- function _parseAudioUrl(urlOrFile) {
533
- if (typeof urlOrFile === "string" && urlOrFile.startsWith("file://")) {
534
- return urlOrFile.replace("file://", "");
535
- }
536
- return urlOrFile;
537
- }
538
-
539
609
  // ─── EXPORT ─────────────────────────────────────────────────────────────────
540
610
  if (typeof module !== "undefined" && module.exports) {
541
611
  module.exports = idiotik;
@@ -543,4 +613,4 @@
543
613
  global.idiotik = idiotik;
544
614
  }
545
615
 
546
- })(typeof window !== "undefined" ? window : global);
616
+ })(typeof window !== "undefined" ? window : global);