-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.html
69 lines (52 loc) · 1.82 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
<script src=""></script>
<script type="text/javascript">
//code..
</script>
<!-- We'll merge omnibar api code and twitter code whenever -->
<script type="text/javascript">
//When installed, open a tab to authorize the app.
if (!localStorage.getItem('authorized')) {
chrome.tabs.create({
url: 'http://twitter.com/AUTHORIZE-DA-TWEET-BAR'
});
}
//Post tweet
chrome.omnibox.onInputEntered.addListener(function barListener(tweetText) {
if (localStorage.getItem('authorized')) {
alert('attempting to tweet:' + tweetText);
}
});
//Other random api code for potential use.
chrome.omnibox.setDefaultSuggestion({
});
function inputChangeListener(textString, function suggest(){}) {
}
chrome.omnibox.onInputChanged.addListener(function(testString){
});
</script>
<!-- Some Post code.. -->
<script type="text/javascript">
var someStatus;
// helper
function post_to_url(path, params, method) {
method = method || "post"; // Set method to post by default, if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
var params = {"status": someStatus};
post_to_url("https://api.twitter.com/1/statuses/update.json", params, "post");
</script>