How to click on a button on a certain website in the background

I wish to write a web extension that would periodically click on a few buttons / links in the background. It is meant for automating a login procedure that a certain website purposely doesn’t want me to stay logged in for too long. Logging in doesn’t require entering a password, just a few link clicks on "Login with " buttons / links. The links / buttons should be accessible via CSS selectors.

I have a very minimal but not zero experience in web extensions development so I’m wondering if this task is suitable for a web extension. Ideally, I would like to publish it - meaning I’d like it not to be a monkey script or alike.

I’d be glad to get an advice or at least a keyword to search Mozilla’s documentation.

In order to interact with websites within tabs, you’ll want to use content scripts.
These can then click on the buttons/links etc. using JS DOM APIs:

Thanks for the advice @freaktechnik . From what I read about content scripts, it seems they can only interact with tabs already open. I’d like my extension to click on those elements completely in the background - meaning I don’t want the user to be forced to have a tab open with active content just for the extension to do it’s job.

Perhaps I should create a moz-extension:// page and put an iframe there? Is this something that’s allowed for extensions to do?

There are two ways to achieve this:

  1. Tab hiding: you can have hidden tabs with extensions, see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/hide
  2. Reverse engineer their session API and manually make the HTTP requests

That first option seems appropriate I guess, cool. Thanks @freaktechnik !