Greasy Fork is available in English.

Discussions » Development

Dear bro. How do I make a timed loop of script ?

§
Posted: 26-09-2022

https://greasyfork.org/en/scripts/10976-replace-text-on-webpages?locale_override=1

Due to my web pages load too slowly can't complete the textual substitution, how can I let the script continue to run once every 10 seconds?

Who could help me?

§
Posted: 27-09-2022

Use

// @run-at document-end

and/or

window.onload = (function () {

§
Posted: 27-09-2022

// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @run-at document-end
// ==/UserScript==

(function() {
'use strict';
window.onload = (function () {

// Your code here...

}

})();


Dear hacker09.My bro. Is that so?

Please don't laugh at me, I don't quite understand JS.

And the "window.onload" function seems to be on the script loaded.I want to achieve scripts run once every 10 seconds.

§
Posted: 27-09-2022

That looks good, I think it will work in your case.

Either use the code you posted or I guess the one below will also work
window.onload = (function() {
'use strict';
// Your code here...
})();

Post reply

Sign in to post a reply.