2022-03-12 02:15:24 +01:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
var availableLinks = [];
|
|
|
|
var links = document.getElementsByTagName('link');
|
|
|
|
var siteTitle = 'No title was found';
|
|
|
|
|
|
|
|
if (document.getElementsByTagName('title').lenght > 0) {
|
|
|
|
siteTitle = document.getElementsByTagName('title')[0].innerHTML
|
|
|
|
}
|
|
|
|
|
|
|
|
for (link of links) {
|
2022-03-12 02:42:53 +01:00
|
|
|
if ( (link.getAttribute('rel') == 'alternate')
|
|
|
|
&& ( (link.getAttribute('type') == 'application/rss+xml')
|
|
|
|
|| (link.getAttribute('type') == 'application/atom+xml')
|
|
|
|
|| (link.getAttribute('type') == 'application/stream+json')
|
|
|
|
|| (link.getAttribute('type') == 'application/rdf+xml')
|
|
|
|
)
|
|
|
|
) {
|
2022-03-12 02:15:24 +01:00
|
|
|
var linkTitle;
|
|
|
|
var linkUrl;
|
|
|
|
|
|
|
|
if (link.hasAttribute('title')) {
|
|
|
|
linkTitle = link.getAttribute('title');
|
|
|
|
} else {
|
|
|
|
linkTitle = siteTitle;
|
|
|
|
}
|
|
|
|
|
2022-06-20 00:08:09 +02:00
|
|
|
if (link.hasAttribute('href') == true) {
|
|
|
|
if (link.getAttribute('href').startsWith('/')) {
|
|
|
|
linkUrl = window.location.protocol + '//' + window.location.hostname + link.getAttribute('href');
|
|
|
|
} else if (!link.getAttribute('href').includes('/')) {
|
|
|
|
linkUrl = window.location.protocol + '//' + window.location.hostname + '/' + link.getAttribute('href');
|
|
|
|
} else {
|
|
|
|
linkUrl = link.getAttribute('href');
|
|
|
|
}
|
|
|
|
|
|
|
|
availableLinks.push({
|
|
|
|
title: linkTitle,
|
|
|
|
url: linkUrl
|
|
|
|
});
|
2022-03-12 02:15:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-12 02:20:11 +01:00
|
|
|
if (availableLinks.length == 0) {
|
2022-03-12 02:15:24 +01:00
|
|
|
availableLinks.push({
|
|
|
|
title: 'No RSS feed was found',
|
|
|
|
url: 'No URL is provided'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var out = {
|
|
|
|
links: availableLinks
|
|
|
|
};
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
|
|
|
})()
|