-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
55 lines (42 loc) · 1.56 KB
/
popup.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
53
54
55
/* Copyright (c) 2014, Anthony Garcia <[email protected]>
* Distributed under the ISC License
*/
function generateFeedLink(feed) {
if (localStorage.ttrssEnabled == "true" && localStorage.ttrssUrl) {
return localStorage.ttrssUrl + "/public.php?op=subscribe&feed_url=" + feed.href;
} else {
return feed.href;
}
}
window.addEventListener("load", function() {
var feedList = document.getElementById("feed-list");
chrome.tabs.query({active: true, lastFocusedWindow: true}, function(tabs) {
var feeds = null;
if (tabs.length != 0) {
var currentFeeds = JSON.parse(localStorage.feeds);
var feeds = currentFeeds[tabs[0].id];
if (!feeds) {
return;
}
feedList.innerHTML = '';
for (var i = 0; i < feeds.length; ++i) {
var feed = feeds[i];
var entry = document.createElement("li");
var title = feed.title;
var link = document.createElement("a");
var icon = "rssicon24.png";
if (title.length == 0) {
title = feed.type + " feed";
}
if (feed.type == "atom") {
icon = "atomicon24.png";
}
link.target = "_blank";
link.href = generateFeedLink(feed);
link.innerHTML = '<img src="' + icon + '" alt=""/> ' + title;
entry.appendChild(link);
feedList.appendChild(entry);
}
}
});
});