Skip to content

Is there a way to watch for element updates within an element? #1048

Answered by ysmood
atye asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can use the proto lib to do it. The js code is copied from MDN:

// Package main ...
package main

import (
	"fmt"

	"github.com/go-rod/rod"
	"github.com/go-rod/rod/lib/utils"
	"github.com/ysmood/gson"
)

func main() {
	page := rod.New().MustConnect().MustPage("http://example.com").MustWaitStable()

	page.MustExpose("myChanged", func(j gson.JSON) (interface{}, error) {
		fmt.Println("dom changed", j.JSON("", "  "))

		return nil, nil
	})

	page.MustElement("h1").MustEval(`() => {
		// Options for the observer (which mutations to observe)
		const config = { attributes: true, childList: true, subtree: true };
		
		// Callback function to execute when mutations are observed
		const c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by atye
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy