-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
51 lines (45 loc) · 2.37 KB
/
options.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
chrome.storage.local.get(function(result) {
document.getElementById('ytDlpPathInput').value = result.ytDlpPath ?? '';
document.getElementById('ffmpegPathInput').value = result.ffmpegPath ?? '';
document.getElementById('enableLogsInput').checked = result.enableLogs ?? false;
document.getElementById('ytDlpArgumentsInput').value = result.ytDlpArguments ?? '';
document.getElementById('ffmpegSegmentArgumentsInput').value = result.ffmpegSegmentArguments ?? '';
document.getElementById('fileNameTemplateInput').value = result.fileNameTemplate ?? '';
document.getElementById('segmentFileNameTemplateInput').value = result.segmentFileNameTemplate ?? '';
});
optionsForm.addEventListener('submit', e => {
let ytDlpPath = document.getElementById('ytDlpPathInput').value;
let ffmpegPath = document.getElementById('ffmpegPathInput').value;
let enableLogs = document.getElementById('enableLogsInput').checked;
let ytDlpArguments = document.getElementById('ytDlpArgumentsInput').value;
let ffmpegSegmentArguments = document.getElementById('ffmpegSegmentArgumentsInput').value;
let fileNameTemplate = document.getElementById('fileNameTemplateInput').value;
let segmentFileNameTemplate = document.getElementById('segmentFileNameTemplateInput').value;
chrome.storage.local.set({
ytDlpPath: ytDlpPath,
ffmpegPath: ffmpegPath,
enableLogs: enableLogs,
ytDlpArguments: ytDlpArguments,
ffmpegSegmentArguments: ffmpegSegmentArguments,
fileNameTemplate: fileNameTemplate,
segmentFileNameTemplate: segmentFileNameTemplate
}, function() {
console.log('Set ytDlpPath: ' + ytDlpPath);
console.log('Set ffmpegPath: ' + ffmpegPath);
console.log('Set enableLogs: ' + enableLogs);
console.log('Set ytDlpArguments: ' + ytDlpArguments);
console.log('Set ffmpegSegmentArguments: ' + ffmpegSegmentArguments);
console.log('Set fileNameTemplate: ' + fileNameTemplate);
console.log('Set segmentFileNameTemplate: ' + segmentFileNameTemplate);
document.getElementById('saveBtn').innerText = 'Saved!';
setTimeout(function() {
document.getElementById('saveBtn').innerText = "Save";
}, 3000);
});
e.preventDefault();
});
configureShortcutsBtn.addEventListener('click', () => {
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
chrome.tabs.create({ url: 'chrome://extensions/shortcuts', active: true, index: tabs[0].index + 1, openerTabId: tabs[0].id });
});
});