-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.html
117 lines (103 loc) · 3.69 KB
/
background.html
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
112
113
114
115
116
117
<html>
<head>
<script src="/javascripts/3dparty/jsOAuth-1.3.1/jsOAuth.min.js"></script>
<script src="/javascripts/twitter/init.js"></script>
<script src="/javascripts/twitter/timeline.js"></script>
<script src="/javascripts/fowl/storage.js"></script>
<script src="/javascripts/fowl/pubsub.js"></script>
<script src="/javascripts/fowl/timeline.js"></script>
<script src="/javascripts/fowl/init.js"></script>
<script>
function storeCredentials( aScreenName, aUserId, accessTokenKey, accessTokenSecret, consumerKey, consumerSecret ){
fowl.storage.set({
'screen_name': aScreenName,
'user_id': aUserId,
'access_token_key': accessTokenKey,
'access_token_secret': accessTokenSecret,
'consumer_key': consumerKey,
'consumer_secret': consumerSecret
});
}
function getCredentials(){
var credentials = {};
credentials.accessTokenKey = fowl.storage.get('access_token_key');
credentials.accessTokenSecret = fowl.storage.get('access_token_secret');
credentials.consumerKey = fowl.storage.get('consumer_key');
credentials.consumerSecret = fowl.storage.get('consumer_secret');
return credentials;
}
function getUserInfo(){
var userInfo = {};
userInfo.screenName = fowl.storage.get('screen_name');
userInfo.userId = fowl.storage.get('user_id');
return userInfo;
};
function init(){
var credentials = getCredentials();
if( !credentials.accessTokenKey ){
return;
}
fowl.pubsub.subscribe(fowl.timeline.EventType.HOME, function( status, tweets, firstChunk ){
var popup = chrome.extension.getViews({ type: 'popup' })[0],
homeTimeline = fowl.storage.get('home_timeline'),
homeTimelineNew = fowl.storage.get('home_timeline_new');
if( !homeTimelineNew ){
homeTimelineNew = [];
}
if( !firstChunk ){
homeTimelineNew = tweets.concat( homeTimelineNew );
fowl.storage.set('home_timeline_new', homeTimelineNew);
}
if( popup ){
popup.updateTimelineWithType( 'home', homeTimelineNew, true );
homeTimelineNew = [];
fowl.storage.set('home_timeline_new', homeTimelineNew);
}
// tweets.forEach(function( tweet ){
// console.group('TWEET');
// console.log(tweet.user.screen_name);
// console.log(tweet.text);
// console.groupEnd('TWEET');
// });
});
var params = {
consumerKey: credentials.consumerKey,
consumerSecret: credentials.consumerSecret,
accessTokenKey: credentials.accessTokenKey,
accessTokenSecret: credentials.accessTokenSecret
};
T.init(params, function(){
var timeline = fowl.storage.get('home_timeline') || [];
fowl.timeline.home.init( timeline );
fowl.timeline.home.fetch();
setInterval(function(){
fowl.timeline.home.fetch();
}, 60 * 1000);
});
}
init();
</script>
<!--
<script>
(function(){
if( !fowl.storage.get('access_token_key') ){
// show link to options page where user can authorize
}
else{
var params = {
consumerKey: fowl.storage.get('consumer_key'),
consumerSecret: fowl.storage.get('consumer_secret'),
accessTokenKey: fowl.storage.get('access_token_key'),
accessTokenSecret: fowl.storage.get('access_token_secret')
};
T.init(params, function(){
setTimeout(function(){
fowl.init();
}, 0);
});
}
})();
</script>
-->
</head>
</html>