I have try this way, but some of site like bingChat not allow me to do that.
javascript:(function() {
var currentDateTime = new Date();
document.activeElement.value += currentDateTime;
})();
Also tried this way, but still work not well. Because I need to write some logs in company website, thus I want to insert time by just click a button. Thus I can insert data anywhere.
javascript:(function() {
var currentDateTime = new Date();
var activeElement = document.activeElement;
if (activeElement && activeElement.tagName.toLowerCase() === 'textarea') {
var startPos = activeElement.selectionStart;
var endPos = activeElement.selectionEnd;
activeElement.value = activeElement.value.substring(0, startPos) + currentDateTime + activeElement.value.substring(endPos, activeElement.value.length);
activeElement.selectionStart = startPos + currentDateTime.toString().length;
activeElement.selectionEnd = startPos + currentDateTime.toString().length;
} else {
alert('Please place your cursor in a text area.');
}
})();
If cannot do, just copy the time to cilpboard is OK.
For bingChat, the activeElement
I got is: cib-text-input
, but textarea is one of the offspring.
2
Answers
This is my walkaround, just put the current time in the clipboard, then paste it...
I couldn’t get it to work with the address bar, but you could right click on the textarea, Inspect, and then paste in
$0.value += new Date();
into the console tab.