-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please add example for "Paste text from clipboard" #521
Comments
Is there not sufficient information for this in https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard#using_execcommand_2 ? |
I try that but that example is using HTML (where it looks for a ID of the text area) and i don't use any HTML. I just want to "paste" in a web page in a browser using the extension. When i use that code say execCommand is deprecated. |
The question you're asking and the code snippet are two different things. "Paste" means reading from the clipboard. What do you want that is not already covered in https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard ? |
I try that but that example use HTML to look for the ID of the text area were the text is going to be pasted. I really don't know how to do it. So if someone can share a example preferably with code i first share i am going to be really grateful. Edit: Or this code to try to put the text in the comment or the search bar using this page. browser.menus.create({ browser.menus.onClicked.addListener((info, tab) => { |
@Rob--W I think that @Hellboy00000 is looking for code to allow his extension to paste into a webpage. My understanding is you can't do that in code, the user has to initiate the paste. All the code can do is add or remove content from the clipboard. |
This is in a background.js
This code can be used to create the example:
browser.menus.create({
id: "whatever",
title: "Paste clipboard Text"
});
browser.menus.onClicked.addListener((info, tab) => {
navigator.clipboard.writeText("Paste Hello"); // This add the code to the clipboard
// The code needed to paste the text
});
The context menu is not needed for the "paste code" i want to see, but i think that with this example is more easy for everyone to understand the code.
Thanks
The text was updated successfully, but these errors were encountered: