PageSourceSearch

https://pupwife.com/scripts/effects/trailColorSupport.js

js pupwife.com collected 2026-09-30 15:06:27 UTC 4,142 bytes, 142 lines download raw bytes

1/**
2 * Cursor trail color customization metadata + palette helpers.
3 */
4(function (global) {
5    'use strict';
6
7    var DEFAULT_TRAIL_COLORS = {
8        primary: '#c8a8ff',
9        secondary: '#ffb3ba',
10        tertiary: '#89cff0'
11    };
12
13    /** trail id -> number of customizable color slots (1–3) */
14    var TRAIL_COLOR_SLOTS = {
15        sparkles: 3,
16        fairy: 2,
17        bubbles: 2,
18        stars: 2,
19        fire: 3,
20        snow: 2,
21        leaves: 2,
22        pawPrints: 2,
23        confetti: 3,
24        musicNotes: 2,
25        neonLines: 2,
26        paintSplatter: 3,
27        smoke: 2,
28        ripples: 2,
29        geometric: 3,
30        spiral: 2,
31        lightning: 2,
32        comets: 2,
33        energyOrbs: 3,
34        crystals: 3,
35        matrix: 2,
36        circuit: 2,
37        binary: 2,
38        hearts: 2,
39        dandelion: 2,
40        rosePetals: 2,
41        cherryBlossoms: 2,
42        fireflies: 2,
43        butterflies: 2,
44        magicRunes: 3,
45        paintStrokes: 3,
46        chalk: 2,
47        pastels: 3,
48        sprinkles: 3,
49        bouncyBalls: 3,
50        equalizerBars: 3,
51        glitterSparkles: 3,
52        moonDust: 2,
53        shootingStars: 2,
54        woims: 2,
55        gummyWoims: 3
56    };
57
58    var SLOT_KEYS = ['primary', 'secondary', 'tertiary'];
59
60    function normalizeHex(hex, fallback) {
61        var raw = String(hex || '').trim();
62        if (raw[0] !== '#') raw = '#' + raw;
63        if (/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(raw)) {
64            if (raw.length === 4) {
65                raw = '#' + raw.slice(1).split('').map(function (c) { return c + c; }).join('');
66            }
67            return raw.toLowerCase();
68        }
69        return fallback;
70    }
71
72    function mergeTrailColors(raw) {
73        var d = DEFAULT_TRAIL_COLORS;
74        if (!raw || typeof raw !== 'object') {
75            return { primary: d.primary, secondary: d.secondary, tertiary: d.tertiary };
76        }
77        return {
78            primary: normalizeHex(raw.primary, d.primary),
79            secondary: normalizeHex(raw.secondary, d.secondary),
80            tertiary: normalizeHex(raw.tertiary, d.tertiary)
81        };
82    }
83
84    function supportsTrailColors(trailId) {
85        return !!(trailId && TRAIL_COLOR_SLOTS[trailId]);
86    }
87
88    function getSlotCount(trailId) {
89        return TRAIL_COLOR_SLOTS[trailId] || 0;
90    }
91
92    function pickColor(colors, slotIndex) {
93        colors = mergeTrailColors(colors);
94        var key = SLOT_KEYS[slotIndex % 3];
95        return colors[key];
96    }
97
98    function randomHex() {
99        return '#' + Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0');
100    }
101
102    function randomTrailColors() {
103        return {
104            primary: randomHex(),
105            secondary: randomHex(),
106            tertiary: randomHex()
107        };
108    }
109
110    function getPaletteTrailColors(paletteId) {
111        var stripes = ['#6184ce', '#9b7cc9', '#c8a8ff'];
112        if (global.SiteThemePalettes && typeof global.SiteThemePalettes.getPaletteOption === 'function') {
113            var opt = global.SiteThemePalettes.getPaletteOption(paletteId || 'default');
114            if (opt && opt.stripes && opt.stripes.length) {
115                stripes[0] = opt.stripes[0];
116                stripes[1] = opt.stripes[1] || opt.stripes[0];
117            }
118        }
119        try {
120            var accent = getComputedStyle(document.documentElement).getPropertyValue('--accent-primary').trim();
121            if (accent) stripes[2] = accent;
122        } catch (e) { /* ignore */ }
123        return mergeTrailColors({
124            primary: stripes[0],
125            secondary: stripes[1],
126            tertiary: stripes[2]
127        });
128    }
129
130    global.PupwifeTrailColorSupport = {
131        DEFAULT_TRAIL_COLORS: DEFAULT_TRAIL_COLORS,
132        TRAIL_COLOR_SLOTS: TRAIL_COLOR_SLOTS,
133        SLOT_KEYS: SLOT_KEYS,
134        mergeTrailColors: mergeTrailColors,
135        supportsTrailColors: supportsTrailColors,
136        getSlotCount: getSlotCount,
137        pickColor: pickColor,
138        randomTrailColors: randomTrailColors,
139        getPaletteTrailColors: getPaletteTrailColors,
140        normalizeHex: normalizeHex
141    };
142})(window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.