mirror of
https://github.com/aureliendavid/rsspreview.git
synced 2025-08-22 19:28:39 +00:00
detect rss feeds from itunes links
This commit is contained in:
parent
537dfaeb6c
commit
f03abbfb84
@ -2,7 +2,7 @@
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "RSSPreview",
|
||||
"version": "3.5",
|
||||
"version": "3.6",
|
||||
"author": "Aurelien David",
|
||||
"homepage_url": "https://github.com/aureliendavid/rsspreview",
|
||||
|
||||
|
@ -340,6 +340,23 @@
|
||||
|
||||
let feeds = {};
|
||||
|
||||
function registerFeeds(feeds) {
|
||||
|
||||
if (Object.keys(feeds).length > 0) {
|
||||
|
||||
function handleResponse(message) {
|
||||
}
|
||||
|
||||
function handleError(error) {
|
||||
//console.log(error);
|
||||
}
|
||||
|
||||
browser.runtime.sendMessage(feeds).then(handleResponse, handleError);
|
||||
}
|
||||
}
|
||||
|
||||
var async_send = false;
|
||||
|
||||
document.querySelectorAll("link[rel='alternate']").forEach( (elem) => {
|
||||
|
||||
let type_attr = elem.getAttribute('type');
|
||||
@ -361,18 +378,42 @@
|
||||
}
|
||||
});
|
||||
|
||||
if (Object.keys(feeds).length > 0) {
|
||||
if (document.domain == "itunes.apple.com") {
|
||||
|
||||
function handleResponse(message) {
|
||||
let match = document.URL.match(/id(\d+)/)
|
||||
if (match) {
|
||||
let itunesid = match[1];
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', "https://itunes.apple.com/lookup?id="+itunesid+"&entity=podcast");
|
||||
|
||||
xhr.onload = function () {
|
||||
if (xhr.readyState === xhr.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
let res = JSON.parse(xhr.responseText);
|
||||
|
||||
if ("results" in res) {
|
||||
|
||||
let pod = res["results"][0];
|
||||
let title = pod["collectionName"] || document.title;
|
||||
let url = pod["feedUrl"];
|
||||
if (url) {
|
||||
feeds[url] = title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerFeeds(feeds);
|
||||
};
|
||||
async_send = true;
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function handleError(error) {
|
||||
//console.log(error);
|
||||
}
|
||||
|
||||
browser.runtime.sendMessage(feeds).then(handleResponse, handleError);
|
||||
}
|
||||
|
||||
if (!async_send)
|
||||
registerFeeds(feeds);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user