Check on callback if the DOM nodes exist.
If the don't, clear the timer, as each subsequent run would operate on the same empty nodes.
This commit is contained in:
parent
ebd2a09947
commit
4b14ea8de1
2 changed files with 18 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name Facebook desktop notification
|
||||
// @namespace https://www.schtobia.de/
|
||||
// @version 0.1.1
|
||||
// @version 0.2.0
|
||||
// @description Facebook desktop notification (based on HTML5)
|
||||
// @include http*://www.facebook.com/*
|
||||
// @include http*://facebook.com/*
|
||||
|
@ -32,6 +32,14 @@ var intervalID = null;
|
|||
|
||||
notify = function()
|
||||
{
|
||||
if (friendRequestsElement == null || messagesElement == null || notificationsElement == null)
|
||||
{
|
||||
console.log(GM_info.script.name + ": One of the DOM nodes is empty! Clearing the interval timer " + intervalID + "!");
|
||||
clearInterval(intervalID);
|
||||
intervalID = null;
|
||||
return;
|
||||
}
|
||||
|
||||
newFriendRequests = friendRequestsElement.innerHTML;
|
||||
newMessages = messagesElement.innerHTML;
|
||||
newNotifications = notificationsElement.innerHTML;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name Google+ desktop notification
|
||||
// @namespace https://www.schtobia.de/
|
||||
// @version 0.1.1
|
||||
// @version 0.2.0
|
||||
// @description Google+ desktop notification (based on HTML5)
|
||||
// @include http*://plus.google.com/*
|
||||
// @grant GM_getValue
|
||||
|
@ -25,6 +25,14 @@ var intervalID = null;
|
|||
|
||||
notify = function()
|
||||
{
|
||||
if (notificationsElement == null)
|
||||
{
|
||||
console.log(GM_info.script.name + ": The DOM node is empty! Clearing the interval timer " + intervalID + "!");
|
||||
clearInterval(intervalID);
|
||||
intervalID = null;
|
||||
return;
|
||||
}
|
||||
|
||||
newNotifications = notificationsElement.innerHTML;
|
||||
|
||||
if (newNotifications > lastNotifications)
|
||||
|
|
Loading…
Reference in a new issue