-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
27 lines (27 loc) · 802 Bytes
/
background.js
File metadata and controls
27 lines (27 loc) · 802 Bytes
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
function getObjectivity(info, tab) {
var scores = [];
var urls = ['https://morning-harbor-96808.herokuapp.com', 'https://desolate-bastion-86556.herokuapp.com', 'https://secure-basin-62593.herokuapp.com']
$(urls).each(function() {
$.ajax({
type: 'POST',
url: this,
dataType: 'json',
data: {"text": info.selectionText},
success: function (data) {
scores.push(Math.round(data.objectivity * 100));
if (scores.length == urls.length) {
sum = 0;
for(var i = 0, len = scores.length; i < len; i++) {
sum += scores[i];
}
alert(sum/2 + "% objective");
}
}
});
});
}
chrome.contextMenus.create({
title: "Objectivity: %s",
contexts:["selection"],
onclick: getObjectivity,
});