~ghost08/photon

photon/plugins/readed.lua -rw-r--r-- 837 bytes
bdfae33cVladimír Magyar build: update dependencies a month ago
                                                                                
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
--this plugin saves readed (opened/article opened/played) cards to localStorage and shows them in different color
photon = require("photon")
localStorage = require("localStorage")

photon.events.subscribe(
	photon.events.FeedsDownloaded,
	function(e)
		for i = 1, photon.cards:len(), 1 do
			local card = photon.cards:get(i)
			local link = card:link()
			local item = localStorage.getItem(link) 
			if item ~= nil then
				card:foreground(photon.ColorPurple)
			end
		end
	end
)

function opened(e)
	if localStorage.getItem(e:link()) ~= nil then
		return
	end
	localStorage.setItem(e:link(), "")
	e:card():foreground(photon.ColorPurple)
end

photon.events.subscribe(
	photon.events.ArticleOpened,
	opened
)

photon.events.subscribe(
	photon.events.LinkOpened,
	opened
)

photon.events.subscribe(
	photon.events.RunMediaStart,
	opened
)