PDA

View Full Version : Adding close tab after X minutes to a userscript



dissolutions
09-15-2020, 12:36 AM
I would like to know how to add on code to a userscript that will close the tab or even just stop the script after X amount of time. It is a script that refreshes the page often, so when I tried some other suggestions I found online they did not seem to work. Could someone explain how to do this? Thanks!

Zer0
09-16-2020, 04:16 PM
Sorry. I am a bit new here so I am really not sure what language this user script is written in. Which language is it written in? Regardless, here is some more generalized advice and you can see if it is appropriate for your usage:

1) If you are using Puppeteer (which is for JavaScript), it would be as simple as page.close(). Puppeteer is a library to control headless Chrome written by Google. It is meant for automating testing of webpages often times, but can also be used for botting.

2) Assuming you are not using JavaScript, I would recommend some binding to Puppeteer or look for Selenium for your language. If that is not possible, then maybe you can an autohotkey. An autohotkey for closing tabs for Chrome is CTRL + W.