So I'm trying to detect if some text was pasted from ChatGPT
I know about other AI tools that detect it by the language and structure, but it's not too hard to pass its tests.
So I wanna add a second layer of security that will check the pasted text style before it being added to the text field.
I tried hooking myself to the paste event, but I couldn't find a way to get the text's style info.
Anyone has any clue how to do it?
Asked
Active
Viewed 229 times
-1

Haim
- 321
- 1
- 10
1 Answers
0
Okay, I just found out I missed the correct type from clipboardData.getData.
Here's a working code -
//$0 is the HtmlElement that the text is being pasted into
function handlePaste(e) {
var clipboardData, pastedData;
// Stop data actually being pasted into div
e.stopPropagation();
e.preventDefault();
// Get pasted data via clipboard API
clipboardData = e.clipboardData || window.clipboardData;
pastedData = clipboardData.getData('text/html');
// Do whatever with pasteddata
console.log(pastedData);
}
$0.addEventListener('paste', handlePaste);

Haim
- 321
- 1
- 10