I’m trying to automate a task in a weird internal web application. It’s http not (s) and clipboard API is not supported, document.execcommand(‘paste’) is also not working. For now I’m using listener for paste event, but I’d like to eliminate any user input. Any ideas?
// Function to automate
function RD01() {
// Activity input element
let actElement = document.getElementById('ctl00_ctl00_CphContentWrapper_CphMainContent_DocumentEditor_SelectActivity1_HfSelectedId');
if (actElement) actElement.value = '154';
// Employee input element
let emplElement = document.getElementById('ctl00_ctl00_CphContentWrapper_CphMainContent_DocumentEditor_SelectEmployee_HfSelectedId');
if (emplElement) emplElement.value = '%7B%22id%22%3A%221386%22%2C%22type%22%3A%22Employee%22%7D';
// Input element for description (assuming this is where paste happens)
let aboutElement = document.getElementById('ctl00_ctl00_CphContentWrapper_CphMainContent_DocumentEditor_info_About');
if (aboutElement) {
// Add event listener for paste event
aboutElement.addEventListener('paste', function(e) {
// Prevent the default paste behavior
e.preventDefault();
// Get pasted data
let clipboardData = e.clipboardData || window.clipboardData;
let pastedText = clipboardData.getData('text');
// Set the value of aboutElement
aboutElement.value = pastedText;
// Save as working document
let saveButton = document.getElementById('ctl00_ctl00_CphContentWrapper_CphMainContent_DocumentEditor_BtnSaveAsWorking');
if (saveButton) saveButton.click();
});
}
}
}