Reputation: 7736
To periodically emulate DOM interactions on a webpage, I injected some JavaScript within a setInterval
in Chrome Dev Tools' JavaScript Console on that webpage.
setInterval(function() {
// The webpage has already loaded jQuery
$('button.post').click();
}, 1000 * 60);
This works as expected, until the page reloads. Then, I need to re-inject the script in order to continue this process.
Is there a better way to do this, so the script injection survives page reloads?
Upvotes: 1
Views: 604
Reputation: 7736
I ended up using the Chrome extension Custom JavaScript for websites. This extension does the heavy lifting and provides some nice options like jQuery and if the script should be enabled only for a particular domain. So it served my purpose very well. The extension leverages the extensibility of Chrome and injects a content script (basically my script) so it automatically loads every time a page is loaded (as well as refreshed).
Upvotes: 2