i want to keep only Link option to upload document
How can i disable other option
This script customizes the file upload UI in Frappe Web Forms, by hiding unwanted buttons and configuration options such as “Link”, “Camera”, “Set all private/public”, and the optimize/private settings area after file selection.
It uses a MutationObserver
to detect when DOM elements are dynamically inserted (e.g., after opening the file picker or uploading files) and hides specific buttons or sections.
frappe.ready(() => {
const observer = new MutationObserver(() => {
// Hide "Link" and "Camera" buttons
document.querySelectorAll(".btn.btn-file-upload").forEach(btn => {
const labelDiv = btn.querySelector(".mt-1");
if (labelDiv) {
const label = labelDiv.textContent.trim();
if (label === "Link" || label === "Camera") {
btn.style.display = "none";
}
}
});
// Hide "Set all private" immediately when popup appears
document.querySelectorAll('button').forEach(btn => {
if (btn.textContent.trim() === "Set all private") {
btn.style.display = "none";
}
});
// Hide "Optimize" and "Private" config area after file selection
document.querySelectorAll('input[type="file"]').forEach(fileInput => {
fileInput.addEventListener('change', function () {
const configArea = document.querySelector('.config-area');
if (configArea) {
configArea.style.display = 'none';
}
// Hide "Set all public" button
document.querySelectorAll('button').forEach(btn => {
if (btn.textContent.trim() === "Set all public") {
btn.style.display = "none";
}
});
});
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
how to implement this , how to implement this client script