Repository navigation
Expand file tree
/
Copy pathbackground.js
More file actions
60 lines (50 loc) · 1.63 KB
/
Copy pathbackground.js
File metadata and controls
60 lines (50 loc) · 1.63 KB
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
const numbers = [];
// setThresholdFn((maxValue, value) => {
// return (maxValue - value)/maxValue > .02
// });
setInterval(() => {
chrome.storage.sync.get(['trailing', 'symbol'], (result) => {
if(result.symbol) {
var envUrl = chrome.runtime.getURL("env.json");
fetch(envUrl).then(data=> {
console.log(data);
return data.json();
}).then(data=> {
fetch('https://api.robinhood.com/quotes/?symbols=PS', {
headers: {
Authorization: 'Bearer '+data.bearer
}
}).then((r) => {
return r.json();
})
.then((data) => {
// appedEntry(result.symbol, data.results[0]['bid_price']);
numbers.push(data.results[0]['bid_price']);
runCheck();
document.write(JSON.stringify(data));
})
})
}
});
console.log('running');
}, 1000)
chrome.runtime.onMessage.addListener((val) => {
chrome.storage.sync.set({
trailing: val.trailing,
symbol: val.symbol
});
console.log('browser action clicked');
console.log(val)
})
function runCheck() {
if(numbers.length === 10) {
chrome.notifications.create('123', {
title: 'Sell',
message: 'You should sell now!',
priority: 2,
requireInteraction: true,
type: 'basic',
iconUrl: '/images/robbinhoodbot-16.png'
})
}
}