Skip to content

Instantly share code, notes, and snippets.

@tkosaka
Created February 24, 2010 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkosaka/313196 to your computer and use it in GitHub Desktop.
Save tkosaka/313196 to your computer and use it in GitHub Desktop.
Get rss urls and do action(s)
// ============================================================ //
// Inside of the PRESERVE Area
// ============================================================ //
function anythingRss () {
var document = window.content.document;
var document_baseurl = document.baseURI;
var links = document.getElementsByTagName("link");
var rssList = [];
for (var i = 0; i < links.length; i++) {
var link = links[i];
var type = link.getAttribute("type");
if (type) {
if (type.match("application\/.+[+]xml$")) {
var url = window.makeURLAbsolute(document_baseurl, link.getAttribute("href"));
var title = link.getAttribute("title");
rssList.push([title, url]);
}
}
}
if (rssList.length == 0) {
display.echoStatusBar("No RSS was found.", 2000);
}
else {
prompt.selector(
{
message: "List of RSS, ATOM, etc.",
collection: rssList,
header: ["title", "url"],
width: [20, 80],
actions: [[function (aArg) {
var url = rssList[aArg][1];
command.setClipboardText(url);
},
"Copy RSS URL",
"copy-rss-url,c"],
]
}
);
}
}
ext.add("anything-rss", anythingRss,
"anything-rss");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment