-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBGLoader.js
More file actions
42 lines (38 loc) · 1.22 KB
/
BGLoader.js
File metadata and controls
42 lines (38 loc) · 1.22 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
/**
* Created by yonatan on 4/17/2015.
*/
var concurrentOpens = 1;
var counter = 1;
var shouldOpenInterval;
function openInBg(request){
var exID = request[0];
for (var i=0; i<concurrentOpens;i++) {
try {
var rowID = request[counter + i];
if (typeof rowID == 'undefined' ) {
clearInterval(shouldOpenInterval);
return;
}
var urlOfEdit =
"http://moodle2.cs.huji.ac.il/nu14/mod/assign/view.php?id=" + exID + "&rownum=" + rowID + "&action=grade";
chrome.tabs.create({url: urlOfEdit},function(tab){
setTimeout(function () {
chrome.tabs.remove(tab.id);
},20000);
});
}
catch (err) {
break;
}
}
counter += concurrentOpens;
//var ifrm = document.createElement("IFRAME");
//ifrm.setAttribute("src",
// "http://moodle2.cs.huji.ac.il/nu14/mod/assign/view.php?id="+ exID +"&rownum="+ rowID+"&action=grade");
//document.body.appendChild(ifrm);
}
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
shouldOpenInterval = setInterval(openInBg,1000,request);
}
);