-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonboarding.js
More file actions
51 lines (49 loc) · 2.15 KB
/
onboarding.js
File metadata and controls
51 lines (49 loc) · 2.15 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
document.addEventListener('DOMContentLoaded', function() {
document.documentElement.lang = chrome.i18n.getUILanguage();
document.querySelectorAll('[data-i18n]').forEach(function(el) {
var msg = chrome.i18n.getMessage(el.getAttribute('data-i18n'));
if (msg) el.textContent = msg;
});
document.querySelectorAll('[data-i18n-html]').forEach(function(el) {
var msg = chrome.i18n.getMessage(el.getAttribute('data-i18n-html'));
if (msg) el.innerHTML = msg;
});
var title = chrome.i18n.getMessage('onboardingTitle');
if (title) document.getElementById('pageTitle').textContent = title;
// Reflect the user's actual key bindings (handles per-platform manifest
// defaults and user remaps). When a command is bound, swap the embedded
// <kbd> text with the real binding. When it's unbound — Chrome couldn't
// auto-assign the suggested key because of a conflict with another
// extension or a system shortcut — hide the entire <li>. The tip below
// ("Want different keyboard shortcuts? Customize them here →") routes
// users to chrome://extensions/shortcuts where they can set the unbound
// ones; we don't need to litter the quick-actions list with stub rows.
if (chrome.commands && chrome.commands.getAll) {
var hintKeys = {
'suspend-current': 'actionAltS',
'suspend-others': 'actionAltShiftS',
'wake-all': 'actionAltW'
};
chrome.commands.getAll(function(commands) {
commands.forEach(function(cmd) {
var dataKey = hintKeys[cmd.name];
if (!dataKey) return;
var span = document.querySelector('[data-i18n-html="' + dataKey + '"]');
if (!span) return;
var li = span.closest('li');
if (cmd.shortcut) {
var kbd = span.querySelector('kbd');
if (kbd) kbd.textContent = cmd.shortcut;
if (li) li.style.display = '';
} else if (li) {
li.style.display = 'none';
}
});
});
}
document.getElementById('btnClose').addEventListener('click', function() {
chrome.tabs.getCurrent(function(tab) {
if (tab) chrome.tabs.remove(tab.id);
});
});
});