-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtess_sed_plotter_tweak.user.js
More file actions
51 lines (47 loc) · 2.02 KB
/
Copy pathtess_sed_plotter_tweak.user.js
File metadata and controls
51 lines (47 loc) · 2.02 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
42
43
44
45
46
47
48
49
50
51
// ==UserScript==
// @name SED Plotter UI tweak
// @namespace astro.tess
// @match http*://cdsportal.u-strasbg.fr/gadgets/ifr?url=http://cdsportal.unistra.fr/widgets/SED_plotter.xml&*
// @match https://cdsportal.u-strasbg.fr/gadgets/ifr?url=https://cdsportal.unistra.fr/widgets/SED_plotter.xml&*
// @grant GM_addStyle
// @version 0.9.2
// @author -
// @description
// @icon https://cdsportal.u-strasbg.fr/widgets/img/hub-disconnected.png
// ==/UserScript==
// Hide data points that do not have error (could be very unreliable, e.g., for ALLWISE, values with no error is only the upper limit)
function hideNoErrorValues() {
const trNoErrorValueList = Array.from(
document.querySelectorAll(
'table#SED_plot_results_table_dataTable tr:nth-of-type(n+2)',
),
).filter((tr) => {
return (
tr.querySelector('td:nth-of-type(2)') && // ignore subsection rows (that only has 1 td)
!tr.querySelector('td:nth-of-type(9)')?.textContent // those has no value in flux error
);
});
trNoErrorValueList.forEach((tr, i) => {
/// console.debug('i: ', i, tr.querySelector('td:nth-of-type(9)')?.textContent, tr.querySelector('td:nth-of-type(10)')?.textContent);
const elCheckBox = tr.querySelector('input[type="checkbox"]');
if (elCheckBox?.checked) {
elCheckBox.click(); // needed to trigger the update on the plot
elCheckBox.checked = false; // needed to make the checkbox visually unchecked
}
});
}
function addUIOfHideNoErrorValues() {
// wanted to append to document.getElementById('SED_plot_results_opt_a')
// but it is rendered asynchronously
// to keep things simple, I just add it to body instead
document.body.insertAdjacentHTML(
'beforeend',
`
<div style="position:fixed; right: 5px; top: 30px; padding: 6px 6px; background-color:rgba(255, 255, 0, 0.3);">
<button id="ctlHideNoErrorValues">Hide No-error values</button>
</div>
`,
);
document.getElementById('ctlHideNoErrorValues').onclick = hideNoErrorValues;
}
addUIOfHideNoErrorValues();