I would like to add a callback to this function: Notification.requestPermission(). The problem is I don't know when exactly it (that function) will be triggered, hence I think I have to bind the browser notification permission box on click or something like that, to achieve that everytime user clicks on "ALLOW", "BLOCK" or "X"(close) the javascript file finds out what button was clicked on and does something like this:
if (result === 'denied')
{
console.log('Permission wasn\'t granted. Allow a retry.');
return;
}
if (result === 'default')
{
console.log('The permission request was dismissed.');
return;
}
if (result === 'accepted')
{
console.log('The permission request was accepted.');
return;
}
My problem is I don't know how it can be binded to that browser notification permission box like the one below ↓
I do not want to call the permission prompt i.e. Notification.requestPermission() function. I just want to detect when Permission was changed and do something with that result.

You generally request for permission on page load. With jquery you can do something like