v1.0.13 - JS via info.xml

This commit is contained in:
2026-04-16 15:46:23 +02:00
parent 3dd12eb884
commit 563ed657b5
2 changed files with 37 additions and 33 deletions

View File

@@ -4,7 +4,7 @@
<name>Minimal Profile</name> <name>Minimal Profile</name>
<summary>Hides profile fields to create a minimal user profile</summary> <summary>Hides profile fields to create a minimal user profile</summary>
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description> <description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
<version>1.0.12</version> <version>1.0.13</version>
<licence>AGPL</licence> <licence>AGPL</licence>
<author>Your Name</author> <author>Your Name</author>
<namespace>MinimalProfile</namespace> <namespace>MinimalProfile</namespace>

View File

@@ -7,7 +7,7 @@
'role': '#account-property-role', 'role': '#account-property-role',
'headline': '#account-property-headline', 'headline': '#account-property-headline',
'biography': '#account-property-biography', 'biography': '#account-property-biography',
'organisation': '#account-property-organisation', organisation': '#account-property-organisation',
'phone': '#account-property-phone', 'phone': '#account-property-phone',
'address': '#account-property-address', 'address': '#account-property-address',
'birthdate': '#account-property-birthdate', 'birthdate': '#account-property-birthdate',
@@ -17,37 +17,39 @@
'location': '#account-property-location' 'location': '#account-property-location'
}; };
function updateCss(hiddenFields) { function applyCss(hiddenFields) {
if (!hiddenFields || hiddenFields.length === 0) { if (!hiddenFields || hiddenFields.length === 0) {
console.log('MinimalProfile: No hidden fields'); console.log('MinimalProfile: No hidden fields');
return; return;
} }
var css = ''; var css = '';
hiddenFields.forEach(function(field) { hiddenFields.forEach(function(field) {
var selector = fieldSelectors[field]; var selector = fieldSelectors[field];
if (selector) { if (selector) {
css += selector + ' { display: none !important; } '; css += '.personal-settings-setting-box:has(' + selector + ') { display: none !important; } ';
console.log('MinimalProfile: Hiding', field, selector); console.log('MinimalProfile: Hiding', field);
} }
})); });
if (css) {
var style = document.createElement('style'); var style = document.createElement('style');
style.id = 'minimalprofile-style'; style.id = 'minimalprofile-style';
style.textContent = css; style.textContent = css;
document.head.appendChild(style); document.head.appendChild(style);
console.log('MinimalProfile: CSS applied', css); console.log('MinimalProfile: CSS applied');
}
} }
function init() {
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.onload = function() { req.onload = function() {
console.log('MinimalProfile: Response status', req.status);
if (req.status === 200) { if (req.status === 200) {
try { try {
var data = JSON.parse(req.responseText); var data = JSON.parse(req.responseText);
console.log('MinimalProfile: Data', data); applyCss(data.hiddenFields || []);
updateCss(data.hiddenFields);
} catch (e) { } catch (e) {
console.error('MinimalProfile: Error', e); console.error('MinimalProfile: Parse error', e);
} }
} }
}; };
@@ -56,9 +58,11 @@
}; };
req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields')); req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'));
req.send(); req.send();
}
setTimeout(function() { if (document.readyState === 'loading') {
var el = document.querySelector('#account-property-pronouns'); document.addEventListener('DOMContentLoaded', init);
console.log('MinimalProfile: Pronouns element found?', !!el); } else {
}, 3000); init();
}
})(); })();