My chrome extension reads an RSS feed that is updated quite often with new posts. What I want to do is assign every guid to an array that holds and then helps determine whether or not each post is new, and so ought to be passed on (as a notification to me).
$.get('rss-feed', function(data) {
var $xml = $(data);
$xml.find("item").each(function() {
var $this = $(this),
item = {
title: $this.find("title").text(),
link: $this.find("link").text(),
description: $this.find("description").text(),
pubDate: $this.find("pubDate").text(),
guid: $this.find("guid").text()
}
The guid is then assigned to a variable:
var latestID = item.guid.slice(-8);
This is where the problem takes place. The very same post keeps being posted as a new one. Is it because it has an undefined value?
if (latestID == ids[0]) {
} else if (latestID != ids[0]) {
var firstNotification = {
type: "basic",
title: jobType[0] + ": " + jobWords[1] + " words",
iconUrl: "icon48.png",
message: jobPay[0] + "\nID: " + latestID + " Date: " + item.pubDate.slice(17,25),
requireInteraction: true,
buttons: [{
title: "Go to site!"
}],
};
latestID = ids[0];
}