PageSourceSearch

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

js pupwife.com collected 2026-09-30 15:04:06 UTC 2,003 bytes, 60 lines download raw bytes

1/**
2 * Stable viewport sizing for CitrusOS browser-zoom compensation.
3 * Background shaders render at innerWidth * browserZoom so CSS zoom on the
4 * overlay keeps wallpaper scale aligned with desktop chrome.
5 */
6(function (global) {
7    'use strict';
8
9    function readBrowserZoom() {
10        if (global.CitrusBrowserZoom && typeof global.CitrusBrowserZoom.getScale === 'function') {
11            return global.CitrusBrowserZoom.getScale();
12        }
13        try {
14            var raw = global.getComputedStyle(global.document.documentElement)
15                .getPropertyValue('--citrusos-browser-zoom');
16            var z = parseFloat(raw);
17            if (Number.isFinite(z) && z > 0) return z;
18        } catch (e) { /* ignore */ }
19        return 1;
20    }
21
22    function isCitrusOs() {
23        return !!(global.document && global.document.body &&
24            global.document.body.classList.contains('page-citrusos'));
25    }
26
27    function shouldStabilize() {
28        return isCitrusOs() && Math.abs(readBrowserZoom() - 1) > 0.001;
29    }
30
31    function cssSize() {
32        if (!shouldStabilize()) {
33            return {
34                width: Math.max(1, global.innerWidth),
35                height: Math.max(1, global.innerHeight)
36            };
37        }
38        var z = readBrowserZoom();
39        return {
40            width: Math.max(1, Math.round(global.innerWidth * z)),
41            height: Math.max(1, Math.round(global.innerHeight * z))
42        };
43    }
44
45    function pixelRatio(maxDpr) {
46        var cap = maxDpr == null ? 2 : maxDpr;
47        var dpr = global.devicePixelRatio || 1;
48        if (!shouldStabilize()) return Math.min(dpr, cap);
49        var z = readBrowserZoom();
50        return Math.min(Math.max(dpr / z, 1), cap);
51    }
52
53    global.PupwifeViewportSize = {
54        readBrowserZoom: readBrowserZoom,
55        isCitrusOs: isCitrusOs,
56        shouldStabilize: shouldStabilize,
57        css: cssSize,
58        pixelRatio: pixelRatio
59    };
60})(typeof window !== 'undefined' ? window : this);

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.