Files
nextcloud_minimalprofile/js/minimalprofile.js

50 lines
1.3 KiB
JavaScript

/**
* MinimalProfile v46 - Clean version
*/
(function() {
'use strict';
if (!window.location.pathname.includes('/settings/')) {
return;
}
var map = {
'pronouns': '#account-property-pronouns',
'role': '#account-property-role',
'headline': '#account-property-headline'
};
function hideFields(hidden) {
if (!hidden || !hidden.length) return;
var css = '';
hidden.forEach(function(f) {
if (map[f]) {
css += '.personal-settings-setting-box:has(' + map[f] + ') { display: none !important; }';
}
});
if (css) {
var s = document.createElement('style');
s.textContent = css;
document.head.appendChild(s);
}
}
function loadConfig() {
var xhr = new XMLHttpRequest();
xhr.open('GET', '/ocs/v2.php/apps/minimalprofile/api/v1/hidden-fields', true);
xhr.onload = function() {
if (xhr.status === 200) {
try {
var data = JSON.parse(xhr.responseText);
var fields = data?.ocs?.data?.hiddenFields || data?.hiddenFields;
hideFields(fields);
} catch(e) {}
}
};
xhr.send();
}
loadConfig();
})();