HTML Rewriter

Hello,

I am looking to use the HTML Rewriter to edit parts of a website like meta data and divs and so forth, but upon attempting to add the HTML Rewriter I noticed that it doesn’t autocomplete with anything from the API. And when I want to use it methods like .transform simply don’t do anything. I am coding this inside of my wrangler. but am confused on how exactly this API is supposed to be implemented.

Thank you.

Try using one of the examples to guide you from the developer documentation:

This shows how to rewrite links - essentially you’d do the same for your meta tags or divs.

can i also add multiple domains const OLD_URL = "developer.mozilla.org" in the script?

You could do that - you’d need to rework the example to handle multiple URLs of course - some kind of array structure of old & new URLs that you would then loop through and replace.

Hi Sir, can you tell me how the code is written? I’m not very good at javascript

thanks again for your answer

Hi there, I cannot write the Javascript code for you - so you would need to modify it yourself. If you don’t want to learn javascript, you could use a service like Fiverr to pay someone to create it to your exact specification: