ui
This commit is contained in:
parent
400ca5ae66
commit
80823ddf65
4 changed files with 49 additions and 50 deletions
|
@ -93,8 +93,7 @@ select {
|
|||
}
|
||||
#list {
|
||||
overflow: auto;
|
||||
height: 268px;
|
||||
margin-bottom: 16px;
|
||||
height: 240px;
|
||||
color: #000;
|
||||
background-position: top 120px center;
|
||||
background-repeat: no-repeat;
|
||||
|
@ -177,7 +176,7 @@ select {
|
|||
#agent {
|
||||
white-space: nowrap;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
grid-gap: 1px;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,12 +121,13 @@
|
|||
</table>
|
||||
</div>
|
||||
<div id="explore" data-cols=4></div>
|
||||
<div hbox id="agent" align="center">
|
||||
<div id="agent" align="center">
|
||||
<input type="button" value="Options" title="Open options page" style="margin-left: 2px;" data-cmd="options">
|
||||
<input type="button" value="Restart" title="Click to reload the extension. This will cause all the window-based user-agent strings to be cleared" data-cmd="reload">
|
||||
<input type="button" value="Refresh Tab" title="Refresh the current page" data-cmd="refresh">
|
||||
<input type="button" value="Reset" title="Reset User-Agent string to the default one. This will not reset window-based UA strings. To reset them, use the 'Restart' button" data-cmd="reset">
|
||||
<input type="button" value="Test" title="Test your user-agent string" data-cmd="test">
|
||||
<span></span>
|
||||
<input type="button" value="Window" title="Set this string as this window's User-Agent string" data-cmd="window">
|
||||
<input type="button" value="Apply" title="Set this string as the browser's User-Agent string" data-cmd="apply">
|
||||
</div>
|
||||
|
|
|
@ -43,45 +43,46 @@ function update(ua) {
|
|||
tbody.textContent = '';
|
||||
|
||||
parent.dataset.loading = true;
|
||||
fetch('browsers/' + browser.toLowerCase() + '-' + os.toLowerCase().replace(/\//g, '-') + '.json').then(r => r.json()).catch(e => {
|
||||
console.error(e);
|
||||
return [];
|
||||
}).then(list => {
|
||||
if (list) {
|
||||
const fragment = document.createDocumentFragment();
|
||||
let radio;
|
||||
for (const o of sort(list)) {
|
||||
const clone = document.importNode(t.content, true);
|
||||
const second = clone.querySelector('td:nth-child(2)');
|
||||
second.title = second.textContent = o.browser.name + ' ' + (o.browser.version || ' ');
|
||||
const third = clone.querySelector('td:nth-child(3)');
|
||||
third.title = third.textContent = o.os.name + ' ' + (o.os.version || ' ');
|
||||
const forth = clone.querySelector('td:nth-child(4)');
|
||||
forth.title = forth.textContent = o.ua;
|
||||
if (o.ua === ua) {
|
||||
radio = clone.querySelector('input[type=radio]');
|
||||
fetch('browsers/' + browser.toLowerCase() + '-' + os.toLowerCase().replace(/\//g, '-') + '.json')
|
||||
.then(r => r.json()).catch(e => {
|
||||
console.error(e);
|
||||
return [];
|
||||
}).then(list => {
|
||||
if (list) {
|
||||
const fragment = document.createDocumentFragment();
|
||||
let radio;
|
||||
for (const o of sort(list)) {
|
||||
const clone = document.importNode(t.content, true);
|
||||
const second = clone.querySelector('td:nth-child(2)');
|
||||
second.title = second.textContent = o.browser.name + ' ' + (o.browser.version || ' ');
|
||||
const third = clone.querySelector('td:nth-child(3)');
|
||||
third.title = third.textContent = o.os.name + ' ' + (o.os.version || ' ');
|
||||
const forth = clone.querySelector('td:nth-child(4)');
|
||||
forth.title = forth.textContent = o.ua;
|
||||
if (o.ua === ua) {
|
||||
radio = clone.querySelector('input[type=radio]');
|
||||
}
|
||||
fragment.appendChild(clone);
|
||||
}
|
||||
fragment.appendChild(clone);
|
||||
}
|
||||
tbody.appendChild(fragment);
|
||||
if (radio) {
|
||||
radio.checked = true;
|
||||
radio.scrollIntoView({
|
||||
block: 'center',
|
||||
inline: 'nearest'
|
||||
tbody.appendChild(fragment);
|
||||
if (radio) {
|
||||
radio.checked = true;
|
||||
radio.scrollIntoView({
|
||||
block: 'center',
|
||||
inline: 'nearest'
|
||||
});
|
||||
}
|
||||
document.getElementById('custom').placeholder = `Filter among ${list.length}`;
|
||||
[...document.getElementById('os').querySelectorAll('option')].forEach(option => {
|
||||
option.disabled = (map.matching[browser.toLowerCase()] || []).indexOf(option.value.toLowerCase()) === -1;
|
||||
});
|
||||
}
|
||||
document.getElementById('custom').placeholder = `Filter among ${list.length}`;
|
||||
[...document.getElementById('os').querySelectorAll('option')].forEach(option => {
|
||||
option.disabled = (map.matching[browser.toLowerCase()] || []).indexOf(option.value.toLowerCase()) === -1;
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw Error('OS is not found');
|
||||
}
|
||||
}).finally(() => {
|
||||
parent.dataset.loading = false;
|
||||
});
|
||||
else {
|
||||
throw Error('OS is not found');
|
||||
}
|
||||
}).finally(() => {
|
||||
parent.dataset.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('browser').addEventListener('change', e => chrome.storage.local.set({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue