Hacker News new | ask | show | jobs
by BWStearns 645 days ago
Do you have a good way to modify contenteditable divs from the extension? I'm working on one and we're having a hell of a time trying to come up with One Way to do input updates but everyone's contenteditables behave slightly differently.

Like I just want to be able to ask

* what is the content of this input field

* what is the selected text in the field

* please replace the content of the field with this new content

but the API there is really rough and there's tons of edge cases. Is there some library you use?

1 comments

Hmm this isn’t something I’ve dealt with before, what kind of sites are you targeting? Wordpress sites? I ask because you mention “div” but are talking about input fields

You would probably use a content script and set world to “MAIN” and search for the contenteditable attribute on first guess

I’m targeting any input fields. So like, standard input boxes like HN, but also weird input fields like a google doc or notion page.