javascript – Run notification script only once, even though script runs on multiple tabs

I use the following code inside a Tampermonkey script.

function scriptMain () {
        GM_notification ( {
            title: 'Refresh Business Manager', text: 'Your about to be logged out of staging, click here to refresh your login.', image: '',
            onclick: () => {
                console.log ("My notice was clicked.");
        } );
    }, 5*1000);
    console.log ("Script main code ran.");

The code shows a notification whenever a browser tab is open for more than 5 seconds which includes a button to refresh the current browser tab. I wanna use this script to alert me every 20 minutes or so, that one of the logins in the browser is about to auto-logout.

The functionality works as expected, but if I have 5 tabs open from the site where im logged in, I will get 5 notifications when the page is about to run out. I would love to be able to tell from within the Tampermonkey script if this script is already running on another tab, to not execute or to maybe just be able to only show the notification once.

I have been looking into the Tampermonkey documentation for the following Grants:


But I dont seem to be able to work out if this functionality would be possible or not.

Can someone help me shine some light on this topic, or perhaps share a solution?