-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowbutton.js
More file actions
74 lines (58 loc) · 1.69 KB
/
showbutton.js
File metadata and controls
74 lines (58 loc) · 1.69 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var commits = [];
var owner, repo;
function makePayment(venmo_email, venmo_note, venmo_amount) {
chrome.storage.local.get(['venmoKey'], function(result) {
jQuery.ajax({
url: "https://api.venmo.com/payments",
type: "POST",
data: {
access_token: result.venmoKey,
email: venmo_email,
note: venmo_note,
amount: venmo_amount
},
success: function() {
alert("Charged $2.00!");
console.log("Payment successful");
},
error: function() {
console.log("Payment failed.");
}
});
});
}
function callback(id)
{
chrome.storage.local.get(['githubKey'], function(result) {
jQuery.ajax({
url: "https://api.github.com/repos/"+owner+"/"+repo+"/git/commits/"+commits[id]['commitCode'],
type: "GET",
data: {
access_token: result.githubKey
},
success: function(data) {
var email = data.committer.email;
var msg = prompt('Blame ' + email, "FFS WHAT DO YOU THINK YOU'RE DOING?!");
makePayment(email, msg + "["+commits[id]['commitCode']+"]", -2);
}
});
});
}
jQuery(document).ready(function() {
var url = window.location.href.split('/');
owner = url[3]; repo = url[4];
jQuery('.section-first .commitinfo').each(
function(index, element) {
var line = {};
line['index'] = index;
line['ownerId'] = jQuery(this).find('[rel="author"]').text();
var commitUrl = jQuery(this).find('a').first().attr('href').split('/');
line['commitCode'] = commitUrl[commitUrl.length-1];
commits.push(line);
jQuery(this).append('<a class="minibutton blamed" data-id='+ index +'>Blame</a>');
}
);
jQuery('.blamed').click(function() {
callback(jQuery(this).data('id'));
});
});