From a3e2b2530a3c60e0a28248784d5582b243cb54cc Mon Sep 17 00:00:00 2001 From: DEKHTIARJonathan Date: Wed, 27 Sep 2017 18:19:44 +0200 Subject: [PATCH] Feed Detection Improved with all known content types and base_url append if needed Release 1.0.12 --- app/background.js | 39 ++++++++++++++++++++++++++++++++++----- manifest.json | 2 +- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/app/background.js b/app/background.js index 1b3147d..f9984d2 100755 --- a/app/background.js +++ b/app/background.js @@ -88,11 +88,40 @@ function checkRSSFeeds() { chrome.tabs.executeScript( tabs[0].id, { - code: 'var rss_tag = document.querySelector("[type=\'application/rss+xml\']"); \ - if (rss_tag == null){rss_tag = document.querySelector("[type=\'application/atom+xml\']");} \ - if (rss_tag == null) {\ - if (["application/xhtml+xml","application/xml"].indexOf(document.contentType) > -1){document.documentURI;} else{null;} \ - } else { rss_tag.getAttribute("href");}' + code: ` + var RSS_CONTENT_TYPES = [ + "application/xhtml+xml", + "application/xml", + "application/atom+xml", + "application/rss+xml", + "application/rdf+xml", + "text/xml" + ] + + var rss_tag = null; + + for (x in RSS_CONTENT_TYPES){ + rss_tag = document.querySelector("[type=\'"+RSS_CONTENT_TYPES [x]+"\']"); + if (rss_tag != null){ + feed_url = rss_tag.getAttribute("href"); + break; + } + } + + if (rss_tag == null) { + if (RSS_CONTENT_TYPES.indexOf(document.contentType) > -1){ + feed_url = document.documentURI; + } else { + null; + } + } + + if (feed_url[0] == "/" && feed_url.substring(0, 2) != "//"){ + feed_url = window.location.origin + feed_url; + } + + feed_url + ` }, function(rss_href){ if(chrome.runtime.lastError == undefined){ diff --git a/manifest.json b/manifest.json index 5a9b630..e9d45f7 100755 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "short_name": "Feedcrunch", "author": "Jonathan DEKHTIAR", "manifest_version": 2, - "version": "1.0.11", + "version": "1.0.12", "description": "Feedcrunch.IO - Chrome Extension", "icons": {