(function() { 'use strict'; console.log('MinimalProfile: Loading...'); var fieldSelectors = { 'pronouns': '#account-property-pronouns', 'role': '#account-property-role', 'headline': '#account-property-headline', 'biography': '#account-property-biography', 'organisation': '#account-property-organisation', 'phone': '#account-property-phone', 'address': '#account-property-address', 'birthdate': '#account-property-birthdate', 'website': '#account-property-website', 'twitter': '#account-property-twitter', 'fediverse': '#account-property-fediverse', 'location': '#account-property-location' }; function applyCss(hiddenFields) { console.log('MinimalProfile: Hidden fields:', hiddenFields); if (!hiddenFields || hiddenFields.length === 0) { console.log('MinimalProfile: No hidden fields to apply'); return; } var css = ''; hiddenFields.forEach(function(field) { var selector = fieldSelectors[field]; if (selector) { css += '.personal-settings-setting-box:has(' + selector + ') { display: none !important; } '; console.log('MinimalProfile: Hiding field:', field); } else { console.log('MinimalProfile: Unknown field:', field); } }); if (css) { var style = document.createElement('style'); style.id = 'minimalprofile-style'; style.textContent = css; document.head.appendChild(style); console.log('MinimalProfile: CSS applied:', css); } } function init() { var url = OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'); console.log('MinimalProfile: Fetching:', url); var req = new XMLHttpRequest(); req.open('GET', url); req.onload = function() { console.log('MinimalProfile: Response status:', req.status); if (req.status === 200) { try { var data = JSON.parse(req.responseText); console.log('MinimalProfile: Response data:', data); applyCss(data.hiddenFields || []); } catch (e) { console.error('MinimalProfile: Parse error', e); } } else { console.error('MinimalProfile: HTTP error:', req.status); } }; req.onerror = function() { console.error('MinimalProfile: Request failed'); }; req.send(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();