-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutocloseCalibrationTabs.js
104 lines (91 loc) · 3.96 KB
/
AutocloseCalibrationTabs.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// ==UserScript==
// @name Autoclose Calibration Tabs
// @namespace https://github.com/LeightonSolo/IsensixScripts
// @version 1.1
// @description Automatically closes the calibration tab based on a custom number of seconds on Guardian 2.0, 2.1 and ARMS servers
// @author Leighton Solomon
// @match https://*/arms2/calibration/calreport.php*
// @match https://*/arms2/calibration//calreport.php*
// @match https://*/arms2/calsetup.php?*
// @match https://*/arms/calsetup.php?*
// @match https://*/arms/calreport.php?*
// @icon https://www.google.com/s2/favicons?sz=64&domain=isensix.com
// @downloadURL https://raw.githubusercontent.com/LeightonSolo/IsensixScripts/main/AutocloseCalibrationTabs.js
// @updateURL https://raw.githubusercontent.com/LeightonSolo/IsensixScripts/main/AutocloseCalibrationTabs.js
// @grant GM_getValue
// @grant GM.setValue
// ==/UserScript==
// .--. .--. .--. .--. .--. .--. .--. .--.
//:::::.\::::::::.\::::::::.\ Leighton's Tools \::::::::.\::::::::.\::::::::.\
//' `--' `--' `--' `--' `--' `--' `--' `
function closeWindow(){
//alert("window closing");
const timeInSeconds = getSliderValue();
if (timeInSeconds === parseInt(slider.max, 10)) {
console.log('Slider is at maximum value, window will not close.');
return;
}
console.log(`Window will close in ${timeInSeconds} seconds`);
setTimeout(() => {
window.close();
}, timeInSeconds * 1000);
}
function getSliderValue() {
return parseInt(slider.value, 10);
}
const slider = document.createElement('input');
slider.type = 'range';
slider.min = 5;
slider.max = 60;
slider.value = await GM.getValue("autocloseSlider");
//slider.value = 15;
slider.style.width = '100%';
slider.style.maxWidth = '400px';
slider.style.marginLeft = '30px';
function createSlider(append) {
// Create the value display element
const valueDisplay = document.createElement('div');
valueDisplay.style.fontSize = '1.2em';
valueDisplay.style.marginTop = '15px';
valueDisplay.style.marginLeft = '30px';
if(getSliderValue() === parseInt(slider.max, 10)){
valueDisplay.textContent = `Calibration tabs will not close. Adjust the slider below to have these tabs autoclose after calibration.`;
}
else{
valueDisplay.textContent = `Calibration tabs will close after ${slider.value} seconds. Drag the slider below to adjust the autoclose time.`;
}
// Function to update the display
function updateSliderValue() {
const value = slider.value;
GM.setValue("autocloseSlider", value);
if(getSliderValue() === parseInt(slider.max, 10)){
valueDisplay.textContent = `Calibration tabs will not close.`;
}
else{
valueDisplay.textContent = `Calibration tabs will close after ${slider.value} seconds.`;
}
}
// Add event listener to update the value when the slider is moved
slider.addEventListener('input', updateSliderValue);
// Insert the slider and value display into append variable
append.appendChild(valueDisplay);
append.appendChild(slider);
}
(function() {
'use strict';
if((document.URL).includes("/calreport.php") && (document.URL).includes("/arms2")){ //GUARDIAN 2.1 DONE
let div = document.querySelector("body > div.noprint.shadow");
createSlider(div);
closeWindow();
}
else if((document.URL).includes("/calsetup.php")){ //GUARDIAN 2.0 DONE
let div = document.querySelector("body > div.uc.noprint");
createSlider(div);
closeWindow();
}
else if((document.URL).includes("arms/calreport.php")){ //ARMS DONE
let div = document.querySelector("body > table:nth-child(1) > tbody > tr > td:nth-child(3) > table > tbody");
createSlider(div);
closeWindow();
}
})();