Is it possible to check where a pasted content comes from? Because I need to check if a pasted content was copied from a word file...
So, is there something in javascript like:
example.on('paste', function (event) {
if (event.source == "Word") {
// do something
}
}
Thanks in advance!
I need to remove all Office Codes. These are class-attributes starting with Mso
Why not check for what you need to fix?
const text = (event.clipboardData || window.clipboardData).getData('text')
if (text && text.toUpperCase().match(/"MSO/)) ...
I don't believe so, you need the clipboard API, and you only have access to executing the copy and paste commands. This will allow you to read or write content only.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
If you look at the clipboard API, you only get a read string or a DataTransfer instance. Which doesn't include any information on the source of the clipboard contents.
No that's not possible in web because if you copy any text from any source it will be same, And you are just copying that text, not source info, So that's impossible