PageSourceSearch

https://pupwife.com/scripts/desktop/citrusStylesPolicy.js

js pupwife.com collected 2026-09-30 15:05:51 UTC 5,052 bytes, 135 lines download raw bytes

1/**
2 * Which dashboard shell CSS loads where.
3 *
4 * - CitrusOS (index.html, in-shell windows): citrusos.css + citrusTools.css (tools only)
5 * - Legacy standalone dashboard pages: modernstyle.css + sidebarNav.css
6 *
7 * Do not load modernstyle on page-citrusos — it paints every footer/button
8 * and breaks the taskbar, window chrome, and theme isolation.
9 */
10(function (global) {
11    'use strict';
12
13    var LEGACY_SHELL_CSS = ['/css/modernstyle.css', '/css/sidebarNav.css'];
14    var CITRUS_SHELL_CSS = ['/css/citrusos.css'];
15
16    /** The only stylesheet for tool/silly apps inside CitrusOS windows (preloaded on index.html). */
17    var CITRUS_TOOLS_CSS = '/css/citrusTools.css';
18
19    /**
20     * Non-tool routes may still inject their own CSS on CitrusOS (chat, music, study hall, etc.).
21     * Everything else under /css/ or /projects/ is blocked — tools use citrusTools.css only.
22     */
23    var ALLOWED_ROUTE_CSS_ON_CITRUS = {
24        '/css/citrusTools.css': true,
25        '/css/bookings.css': true,
26        '/css/siteReveal.css': true,
27        '/css/studyHallCitrus.css': true,
28        '/css/musicPage.css': true,
29        '/css/musicCitrus.css': true,
30        '/css/friends.css': true,
31        '/css/blog.css': true,
32        '/css/citrusBlog.css': true,
33        '/css/cookbook.css': true,
34        '/css/infoPages.css': true,
35        '/css/citrusInfo.css': true,
36        '/css/citrusBookings.css': true,
37        '/css/citrusDnd.css': true,
38        '/css/citrusWebAwesome.css': true,
39        '/projects/chatroom/notification.css': true,
40        '/css/dawDesktop.css': true,
41        '/css/strudelApp.css': true,
42        '/css/citrusChatroom.css': true,
43        '/css/citrusChatroomRetro.css': true,
44        '/css/chatroomSpaChrome.css': true,
45        '/css/chatroomConfirm.css': true,
46        '/css/citrusSettings.css': true,
47        '/css/citrusAdmin.css': true,
48        '/css/citrusChatroomSettings.css': true,
49        '/projects/chatroom/chatroom.css': true,
50        '/projects/chatroom/chatroomScrollbars.css': true,
51        '/projects/terrarium/terrarium.css': true
52    };
53
54    /** Injected route CSS that must not remain on the CitrusOS host document. */
55    var PRUNE_ON_CITRUS_HOST = {
56        '/css/settings-menu.css': true
57    };
58
59    /** Route/page CSS that must never inject on the CitrusOS host document. */
60    var BLOCKED_ON_CITRUS_HOST = {
61        '/css/modernstyle.css': true,
62        'css/modernstyle.css': true,
63        '/css/sidebarNav.css': true,
64        'css/sidebarNav.css': true,
65        '/css/tools.css': true,
66        '/css/citrusToolShell.css': true,
67        '/css/citrusSillyTools.css': true,
68        '/css/citrusToolRoutes.css': true
69    };
70
71    function normalizeCssHref(href) {
72        if (!href) return '';
73        var key = String(href).split('?')[0].split('#')[0];
74        if (key.charAt(0) !== '/') key = '/' + key.replace(/^\.\//, '');
75        return key;
76    }
77
78    function isCitrusOsHost() {
79        return !!(document.body && document.body.classList.contains('page-citrusos'));
80    }
81
82    function shellStylesheets() {
83        return isCitrusOsHost() ? CITRUS_SHELL_CSS.slice() : LEGACY_SHELL_CSS.slice();
84    }
85
86    function isBlockedOnCitrusHost(href) {
87        if (!isCitrusOsHost()) return false;
88        var key = normalizeCssHref(href);
89        return !!BLOCKED_ON_CITRUS_HOST[key];
90    }
91
92    function isToolRouteCssBlockedOnCitrus(href) {
93        if (!isCitrusOsHost()) return false;
94        var key = normalizeCssHref(href);
95        if (isBlockedOnCitrusHost(key)) return true;
96        if (ALLOWED_ROUTE_CSS_ON_CITRUS[key]) return false;
97        if (/^\/css\/.+\.css$/i.test(key)) return true;
98        if (/^\/projects\/.+\.css$/i.test(key)) return true;
99        return false;
100    }
101
102    function filterRouteCss(list) {
103        if (!list || !list.length || !isCitrusOsHost()) return list || [];
104        var out = [];
105        for (var i = 0; i < list.length; i++) {
106            if (isToolRouteCssBlockedOnCitrus(list[i])) continue;
107            out.push(list[i]);
108        }
109        return out;
110    }
111
112    function pruneDisallowedHostStyles() {
113        if (!isCitrusOsHost()) return;
114        var links = document.querySelectorAll('link[rel="stylesheet"]');
115        for (var i = 0; i < links.length; i++) {
116            var href = links[i].getAttribute('href') || '';
117            var key = normalizeCssHref(href);
118            if (PRUNE_ON_CITRUS_HOST[key] && links[i].parentNode) {
119                links[i].parentNode.removeChild(links[i]);
120            }
121        }
122    }
123
124    global.CitrusStylesPolicy = {
125        LEGACY_SHELL_CSS: LEGACY_SHELL_CSS,
126        CITRUS_SHELL_CSS: CITRUS_SHELL_CSS,
127        CITRUS_TOOLS_CSS: CITRUS_TOOLS_CSS,
128        isCitrusOsHost: isCitrusOsHost,
129        shellStylesheets: shellStylesheets,
130        isBlockedOnCitrusHost: isBlockedOnCitrusHost,
131        isToolRouteCssBlockedOnCitrus: isToolRouteCssBlockedOnCitrus,
132        filterRouteCss: filterRouteCss,
133        pruneDisallowedHostStyles: pruneDisallowedHostStyles
134    };
135})(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.