v1.0.40
This commit is contained in:
@@ -1,76 +1,39 @@
|
|||||||
/**
|
/**
|
||||||
* Minimal Profile - Only run on settings page
|
* Minimal Profile v40 - NEW SCRIPT
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Only run on settings page
|
|
||||||
if (!window.location.pathname.includes('/settings/')) {
|
if (!window.location.pathname.includes('/settings/')) {
|
||||||
console.log('MinimalProfile: Not on settings page, skipping');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('MinimalProfile: START - v1.0.32');
|
console.log('MinimalProfile v40: HERE');
|
||||||
|
|
||||||
var fieldSelectors = {
|
var storageKey = 'minimalprofile_hidden';
|
||||||
|
var stored = localStorage.getItem(storageKey);
|
||||||
|
var hidden = stored ? JSON.parse(stored) : [];
|
||||||
|
var urlParam = new URLSearchParams(window.location.search).get('hide');
|
||||||
|
if (urlParam) hidden = urlParam.split(',');
|
||||||
|
if (!hidden.length) return;
|
||||||
|
|
||||||
|
var map = {
|
||||||
'pronouns': '#account-property-pronouns',
|
'pronouns': '#account-property-pronouns',
|
||||||
'role': '#account-property-role',
|
'role': '#account-property-role',
|
||||||
'headline': '#account-property-headline',
|
'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) {
|
var css = '';
|
||||||
console.log('MinimalProfile: applyCss called with', hiddenFields);
|
hidden.forEach(function(f) {
|
||||||
|
if (map[f]) {
|
||||||
if (!hiddenFields || hiddenFields.length === 0) {
|
css += '.personal-settings-setting-box:has(' + map[f] + ') { display: none !important; }';
|
||||||
console.log('MinimalProfile: No fields to hide');
|
console.log('Hiding:', f);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var css = '';
|
if (css) {
|
||||||
hiddenFields.forEach(function(field) {
|
var s = document.createElement('style');
|
||||||
var selector = fieldSelectors[field];
|
s.textContent = css;
|
||||||
if (selector) {
|
document.head.appendChild(s);
|
||||||
css += '.personal-settings-setting-box:has(' + selector + ') { display: none !important; }';
|
|
||||||
console.log('MinimalProfile: Hiding ' + field);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (css) {
|
|
||||||
var style = document.createElement('style');
|
|
||||||
style.textContent = css;
|
|
||||||
style.id = 'minimalprofile-dynamic';
|
|
||||||
document.head.appendChild(style);
|
|
||||||
console.log('MinimalProfile: CSS applied');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('MinimalProfile: Fetching config...');
|
|
||||||
|
|
||||||
var req = new XMLHttpRequest();
|
|
||||||
req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'));
|
|
||||||
req.onload = function() {
|
|
||||||
console.log('MinimalProfile: Status:', req.status);
|
|
||||||
if (req.status === 200) {
|
|
||||||
try {
|
|
||||||
var data = JSON.parse(req.responseText);
|
|
||||||
console.log('MinimalProfile: Data:', data);
|
|
||||||
applyCss(data.hiddenFields || []);
|
|
||||||
} catch (e) {
|
|
||||||
console.error('MinimalProfile: Parse error', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
req.onerror = function() {
|
|
||||||
console.error('MinimalProfile: Request failed');
|
|
||||||
};
|
|
||||||
req.send();
|
|
||||||
})();
|
})();
|
||||||
Reference in New Issue
Block a user