This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
export.js
52 lines (33 loc) · 1.42 KB
/
export.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var bgPage = chrome.extension.getBackgroundPage();
$(document).ready(function()
{
$('#close').click(function(){window.close();});
if(bgPage.options.feedsource == 1)
chrome.bookmarks.get(bgPage.options.feedfolderid, ExportBookmarks);
else
ExportFeeds();
});
// exports opml -> bookmarks
function ExportBookmarks(startNode)
{
chrome.bookmarks.getChildren(startNode[0].id, function(nodes)
{
var opml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><opml version=\"2.0\">\n<head><title>Slick RSS OPML Export</title></head>\n<body>";
for(var i = 0; i < nodes.length;i++)
opml += "<outline type=\"rss\" text=\"" + nodes[i].title.replace("&", "&") + "\" xmlUrl=\"" + nodes[i].url.replace("&", "&") + "\"/>\n";
opml += "</body>\n</opml>";
document.getElementById("opml").value = opml;
});
}
// imports opml -> feed list
function ExportFeeds()
{
var opml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><opml version=\"2.0\">\n<head><title>Slick RSS OPML Export</title></head>\n<body>";
for(var i = 0; i < bgPage.feeds.length;i++)
{
if(bgPage.feeds[i].title != "Read Later")
opml += "<outline type=\"rss\" text=\"" + bgPage.feeds[i].title.replace("&", "&") + "\" xmlUrl=\"" + bgPage.feeds[i].url.replace("&", "&") + "\"/>\n";
}
opml += "</body>\n</opml>";
document.getElementById("opml").innerText = opml;
}