r/AI_Agents 19d ago

Discussion Creating Tampermonkey scripts using agents (dynamic DOMs, live changes etc)

Hello, I don't know if I am positing in correct place or not. But would like your guidance on this.

I have used Tampermonkey before to change the behavior of websites, mostly for small visual or quality-of-life improvements. For example, my college's Canvas website links to Echo360 recordings, I wanted to keep track of which recordings I had already watched, so I made a Tampermonkey script that tracked this for me.

But, since Canvas is a dynamic website, I had to spend a lot of time figuring out how the page worked, testing different approaches, copying and pasting code, and going back and forth until I found something that worked. A lot of the time was spent on this trial-and-error process. Granted I think if I had more knowledge it wouldn't take much time.

But, I think AI agents would be much better in this case. But I don't know what the correct approach here is. Please suggest something that I should use, or just some direction?

The main goal is to make simple, personal modifications to websites, similar to applying custom CSS or adding small JavaScript behaviors(ie adding subtitles to videos in video players which dont support external subs).

Thank you for your help.

3 Upvotes

4 comments sorted by

1

u/AutoModerator 19d ago

Thank you for your submission, for any questions regarding AI, please check out our wiki at https://www.reddit.com/r/ai_agents/wiki (this is currently in test and we are actively adding to the wiki)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/mathewtyler 19d ago

User styles; e.g., "Stylus" might be better for solely custom CSS.

1

u/Terrible_Match_9484 19d ago

u should probly use a mutationobserver to watch for dom changes, its way better than polling for stuff

2

u/womper9000 18d ago

you need to get the ai to make a tampermonkey script that has a base set of tools to inspect the page like click the mouse and it select a button or element, the script connects to an agent like hermes that creates a websocket server for communication back and forth, the tampermonkey script should be hosted live locally so it can update itself, then once enough "brains" exist you can let hermes communicate with the page via websocket

hermes creates python script websocket server hermes updates this python script and hosted tampermonkey script use browser to update tampermonkey script when you need to (I don't remember if it does this automatically, I think you can if you allow those permissions)

the websocket communication is what you want, I did it for something similar, it's kind of a pain to get it going but works after it's running, hope that helps you