forked from noitcudni/google-search-console-bulk-url-removal
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbg.js
61 lines (56 loc) · 1.73 KB
/
bg.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
54
55
56
57
58
59
60
61
var executionInProgress = false;
var removalMethod = null;
var victimUrlArray = null;
var initUrl = null;
chrome.runtime.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
if (msg.type === 'initVictims') {
executionInProgress = true;
victimUrlArray = msg.rawTxt.replace(/^\s+|\s+$/g, '').split('\n');
removalMethod = msg.removalMethod;
initUrl = msg.initUrl;
console.log ("initUrl: " + initUrl);
var victimUrl = victimUrlArray[0];
port.postMessage({
'type' : 'removeUrl',
'victim': victimUrl,
'removalMethod': removalMethod
});
} else if (msg.type === 'nextVictim') {
// find the next victim
if (executionInProgress) {
victimUrlArray.shift();
var victimUrl = victimUrlArray[0];
if (victimUrl !== undefined) {
port.postMessage({
'type' : 'removeUrl',
'victim': victimUrl,
'removalMethod': removalMethod
});
} else {
executionInProgress = false; //done
removalMethod = null;
victimUrlArray = null;
// Artifically trigger a quota exceed event to test
// port.postMessage({ //xxx
// 'type' : 'triggerQuota'
// });
}
} else {
console.log("no victim to be executed.");
}
} else if (msg.type === 'reload') {
console.log("reloading initUrl: " + initUrl);
port.postMessage({
'type' : 'doReload',
'url' : initUrl
});
} else if (msg.type == 'askState') {
port.postMessage({
'type' : 'state',
'executionInProgress' : executionInProgress,
'removalMethod' : removalMethod
});
}
});
});