cloudflare / lol-html

Low output latency streaming HTML parser/rewriter with CSS selector-based API
https://crates.io/crates/lol-html
BSD 3-Clause "New" or "Revised" License
1.5k stars 83 forks source link

Generating selector from document and element #45

Open toinbis opened 4 years ago

toinbis commented 4 years ago

Hi,

would it be possible in any ways to generate selector itselfusing lol-html? The input would be: a) the document that will be processed by HTMLRewriter in a worker later on; b) the element that needs to be selected (as generated by 'click' document event listener);

Output needed would be the (most effective) selector to be used to select this element on worker's execution.

Thanks!

P.S. am not familiar with internals of lol-html, it's a bit of a long-shot question. Thanks in advance for looking into it and replying.

Electroid commented 4 years ago

Hi @toinbis,

You could use the lol-html Rust library to make a selector generator, but that functionality doesn't exist out-of-the-box today. What is your use-case for generating selectors in Workers?

toinbis commented 4 years ago

Hi @Electroid - thanks a lot for responding!

Our app allows users to to load their web page in an 'visual editor', make modifications and have those modifications applied on runtime with worker. We provide a worker and the 'visual page editor', clients create the 'transformations' themselves.

Using same codebase for generating selectors and actually selecting elements on runtime seems a wise way to go...

toinbis commented 4 years ago

Hi @Electroid ,

maybe you could write a few guidelines on how to achieve this? We would probably try to find a rust developer to try to work on this...

Much appreciated in advance!

aralroca commented 9 months ago

I'm also interested in generating selectors, @toinbis did you finally get it?