[ES] Use JS script to export desktop control USB whitelist.
Problem Description
The customer has hundreds of USB whitelist entries and wants to export them, but currently ES does not support exporting.




// 1. Open F12 in Chrome.
// 2. Open the relevant page and find the relevant ajax request.
// 3. Save the response of the relevant network request as a global variable
// 4. Copy this code and execute it in the F12 console tab.
let downloadFile = function (content, fileName) {
var blob = new Blob([content], {type: 'text/plain'});
var url = URL.createObjectURL(blob);
```
var link = document.createElement('a');
link.href = url;
link.download = fileName;
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, false);
link.dispatchEvent(event);
URL.revokeObjectURL(url);
}
let last_var_name = undefined;
let var_name_no = 1;
while (true) {
let next_var_name = 'temp' + String(var_name_no);
if (window[next_var_name] === undefined) {
break;
}
last_var_name = next_var_name;
var_name_no++;
}
if (last_var_name === undefined) {
alert('Please save the network response as a global variable first!');
}
console.log(window[last_var_name]);
```
let res = 'Serial Number,Device ID,Note\r\n';
for (let [index, item] of window[last_var_name].data.desktop_control_setting.usb_controller.device_control_policy.id_info.msgs.entries()) {
let no = index + 1;
res += no + ',' + item.whiteListId + ',' + item.remarksId;
res += '\r\n';
}
downloadFile(res, 'DesktopControlWhitelist.csv');
Suggestions and Summary
This solution is not a standardized solution and does not promise to maintain this script.
Original Link
https://support.sangfor.com.cn/cases/list?product_id=16&type=1&category_id=23505&isOpen=true