-
Notifications
You must be signed in to change notification settings - Fork 0
/
invalidateSession.js
47 lines (39 loc) · 1.06 KB
/
invalidateSession.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
/*
* Component GenericSessionManager
* Click on "View" button to list active sessions
* Run the script below to invalidate one by one automaticaly
*/
count = 0;
stop = 3;
tasks = Array.from(document.querySelector('table').querySelectorAll('a'));
performTask = () => {
let item = tasks.shift();
if (count < stop) {
let url = item.href + '?shouldInvokeMethod=invalidate';
let page = window.open(url, '_blank');
try {
let interval = setInterval(() => {
if (page && page.document) {
let btn = page.document.querySelector('input[name=submit]');
if (btn) {
clearInterval(interval);
btn.click();
interval = setInterval(() => {
page.document.querySelectorAll('h1').forEach((item) => {
if (item.textContent.indexOf('invoked') > 0 || item.textContent.indexOf('not found') > 0) {
clearInterval(interval);
page.close();
count++;
setTimeout(performTask, 250);
}
});
}, 250);
}
}
}, 250);
} catch (e) {
console.log(e);
}
}
};
setTimeout(performTask, 25);