This repository was archived by the owner on Apr 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartseite.js
111 lines (88 loc) · 3.36 KB
/
startseite.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
$(function() {
if(!/^(\/?|\/\w{2}\/?)$/.test(window.location.pathname))
return;
chrome.storage.sync.get(null, function(syncStorage) {
var tabs = syncStorage['tabs'],
favoriten = syncStorage['favoriten'],
preisagenten = syncStorage['preisagenten'],
img = $(document.createElement('img'))
.attr('src', chrome.extension.getURL('img/preisagent_16.png'))
.css('vertical-align', 'middle'),
divh = $(document.createElement('div')).addClass('ghinfoboxh').append(img, ' Preisagenten'),
div = $(document.createElement('div')).addClass('ghinfobox').append(divh);
if($.isEmptyObject(preisagenten)) {
var p = $(document.createElement('p')),
a = $(document.createElement('a'))
.html('benachrichtigt')
.attr('href', '#')
.click(function() {
chrome.runtime.sendMessage({
typ: 'notification',
icon: 'preisagent_32.png',
titel: 'Preisagent Beispiel',
text: 'TV 55" 4711 im Tab "Versand" ist billiger geworden: € 555,55 statt € 565,--',
link: window.location.origin + window.location.pathname + '?cat=tvlcd'
});
}),
img = $(document.createElement('img'))
.attr('src', chrome.extension.getURL('img/preisagent_on.png'))
.css('vertical-align', 'middle');
p.append('Füge <strong>Tabs</strong> ', img, ' zu den Preisagenten hinzu und du wirst über Preisänderungen ', a, '.');
div.append(p);
} else {
for(var i in preisagenten) {
(function(i) {
var p,
region = i.substring(0,2),
artikel = i.replace(/^.*_(\d+)_.*$/, '$1'),
tab_id = i.replace(/^.*_(\d+)$/, '$1'),
preis;
if(typeof preisagenten[i].preis == 'number')
preis = preisagenten[i].preis/100;
else
preis = '--';
var selber_artikel = $('[data-artikel=' + region + '_' + artikel + ']', div);
if(selber_artikel.length) {
p = selber_artikel.closest('p');
} else {
var a = $(document.createElement('a')),
img = $(document.createElement('img'));
img.attr('src', '../b/' + region + '.png')
.css('vertical-align', 'middle');
a.html(preisagenten[i].titel)
.attr({
href: window.location.origin + '/' + region + '/' + artikel,
'data-artikel': region + '_' + artikel
});
p = $(document.createElement('p'));
p.append(img, ' ', a);
}
p.append('<br>vor ' + errechne_alter(new Date(preisagenten[i].uhrzeit)) + ' <strong>€ ' + preis +
'</strong> (' + preisagenten[i].haendler + ') in <strong>' + tabs[tab_id].tabname + '</strong>');
div.append(p);
})(i);
}
}
$('#gh_blah').prepend(div);
var div = $(document.createElement('div')).addClass('ghinfobox'),
divh = $(document.createElement('div')).addClass('ghinfoboxh');
var img = $(document.createElement('img'))
.attr('src', chrome.extension.getURL('img/stern_hell.png'))
.css('vertical-align', 'middle');
divh.append(img, ' Favoriten');
div.append(divh);
if($.isEmptyObject(favoriten)) {
var p = $(document.createElement('p'))
.append('Füge <strong>Artikel</strong> zu den Favoriten hinzu um sie hier direkt auswählen zu können.');
div.append(p);
} else {
for(var i in favoriten) {
var a = $(document.createElement('a'))
.html(favoriten[i].titel)
.attr('href', './' + i);
div.append(a, '<br>');
}
}
$('#gh_blah').prepend(div);
});
});