1

I'm trying to build a script that runs every 10seconds and sends a GM_notification. But I dont receive any notification. What's wrong?

// ==UserScript== // @name _Notification test // @grant GM_notification // @require http://code.jquery.com/jquery-1.12.4.min.js // ==/UserScript== setTimeout(function() { GM_notification ( {title: 'foo', text: '42'} ); }, 1000); 
2
  • this script will run once after 1sec Commented Dec 6, 2021 at 17:59
  • Does this answer your question? setTimeout or setInterval? Commented Dec 6, 2021 at 20:24

1 Answer 1

2

you need match url give url of page and for every 10 sec need setInterval not setTimeout

// ==UserScript== // @name _Notification test // @match https://stackoverflow.com/questions/70249774/tampermonkey-run-script-every-10s* // @grant GM_notification // @require http://code.jquery.com/jquery-1.12.4.min.js // ==/UserScript== var intervalId = window.setInterval(function(){ GM_notification ( { title: 'foo', text: '42' } ); }, 10000); 
Sign up to request clarification or add additional context in comments.

2 Comments

I added image parameter but still it doesnt show. If i add // @match stackoverflow.com/questions/70249774* the notification will appear when I will navigate to this page
@rowend i have update my answer now it is working

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.