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);
rowend
  • 21
  • 3

1 Answers1

1

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);
Mohammad Ali Rony
  • 4,695
  • 3
  • 19
  • 33
  • I added `image` parameter but still it doesnt show. If i add // @match https://stackoverflow.com/questions/70249774/* the notification will appear when I will navigate to this page – rowend Dec 06 '21 at 18:45
  • @rowend i have update my answer now it is working – Mohammad Ali Rony Dec 06 '21 at 19:27