Skip to content

Instantly share code, notes, and snippets.

@user19
Created November 12, 2014 08:19
Show Gist options
  • Save user19/5cfa535be47ea4e96d13 to your computer and use it in GitHub Desktop.
Save user19/5cfa535be47ea4e96d13 to your computer and use it in GitHub Desktop.
var d=document;
var el=d.getElementsByTagName('link');
var g=false;
var j=false;
for(i=0;i<el.length;i++){
if(el[i].getAttribute('rel').indexOf('alternate')!=-1){
ty=el[i].getAttribute('type');
if(ty.indexOf('application/rss+xml')!=-1||ty.indexOf('text/xml')!=-1){
g=true;
h=el[i].getAttribute('href');
var k=h.substring(0,1);
if(k=='/'){
h='http://'+location.host+h;
}break;
}
}
}
if(g){
window.open('http://cloud.feedly.com/v3/feeds/feed'+encodeURIComponent('/' h));
return;
}
if(!g){
for(i=0;i<el.length;i++){
if(el[i].getAttribute('rel').indexOf('alternate')!=-1){
ty=el[i].getAttribute('type');
if(ty.indexOf('application/atom+xml')!=-1){
j=true;
h=el[i].getAttribute('href');
var l=h.substring(0,1);
if(l=='/'){
h='http://'+location.host+h;
}
break;
}
}
}
if(j){
window.open('http://cloud.feedly.com/v3/feeds/feed'+encodeURIComponent('/' h));
return;
}
if(!j){
window.alert('Could not find the RSS/Atom Feed');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment