version 0.1.1
This commit is contained in:
parent
99ee6c0c6b
commit
cd6e645458
6 changed files with 119 additions and 75 deletions
24
common.js
24
common.js
|
@ -59,6 +59,26 @@ User-Agent String: ${ua || navigator.userAgent}`
|
||||||
chrome.storage.local.get({
|
chrome.storage.local.get({
|
||||||
ua: ''
|
ua: ''
|
||||||
}, prefs => update(prefs.ua));
|
}, prefs => update(prefs.ua));
|
||||||
chrome.storage.onChanged.addListener(prefs => {
|
chrome.storage.onChanged.addListener(prefs => prefs.ua && update(prefs.ua.newValue));
|
||||||
update(prefs.ua.newValue);
|
|
||||||
|
// FAQs & Feedback
|
||||||
|
chrome.storage.local.get({
|
||||||
|
'version': null,
|
||||||
|
'faqs': navigator.userAgent.indexOf('Firefox')
|
||||||
|
}, prefs => {
|
||||||
|
const version = chrome.runtime.getManifest().version;
|
||||||
|
|
||||||
|
if (prefs.version ? (prefs.faqs && prefs.version !== version) : true) {
|
||||||
|
chrome.storage.local.set({version}, () => {
|
||||||
|
chrome.tabs.create({
|
||||||
|
url: 'http://add0n.com/useragent-switcher.html?version=' + version +
|
||||||
|
'&type=' + (prefs.version ? ('upgrade&p=' + prefs.version) : 'install')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{
|
||||||
|
const {name, version} = chrome.runtime.getManifest();
|
||||||
|
chrome.runtime.setUninstallURL('http://add0n.com/feedback.html?name=' + name + '&version=' + version);
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
background-color: #fff;
|
||||||
font-family: "Helvetica Neue",Helvetica,sans-serif;
|
font-family: "Helvetica Neue",Helvetica,sans-serif;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
width: 700px;
|
width: 700px;
|
||||||
|
@ -40,6 +41,7 @@ input[type=text] {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
text-indent: 5px;
|
text-indent: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
}
|
}
|
||||||
select,
|
select,
|
||||||
input {
|
input {
|
||||||
|
@ -57,6 +59,10 @@ input[type=button] {
|
||||||
input[type=button]:active {
|
input[type=button]:active {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
input[type=button]:disabled {
|
||||||
|
opacity: 0.2;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
#list {
|
#list {
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
|
@ -68,26 +74,26 @@ input[type=button]:active {
|
||||||
background: url(loading.gif) top 120px center no-repeat;
|
background: url(loading.gif) top 120px center no-repeat;
|
||||||
background-size: 64px;
|
background-size: 64px;
|
||||||
}
|
}
|
||||||
|
#list table {
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
#list tr {
|
#list tr {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
#list tr[data-matched=false] {
|
#list tr[data-matched=false] {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
#list tr:nth-child(even) {
|
#list tbody tr:nth-child(odd) {
|
||||||
background-color: rgba(0, 0, 0, 0.05);
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
#list td:nth-child(1) {
|
#list td:nth-child(1) {
|
||||||
width: 20px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
#list td:nth-child(2),
|
#list td {
|
||||||
#list td:nth-child(3) {
|
white-space: nowrap;
|
||||||
width: 100px;
|
overflow: hidden;
|
||||||
}
|
text-overflow: ellipsis;
|
||||||
|
padding: 3px 5px;
|
||||||
#list tr {
|
|
||||||
height: 22px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#tools input {
|
#tools input {
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
<link rel="stylesheet" href="index.css">
|
<link rel="stylesheet" href="index.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div hbox id="filter">
|
<div hbox id="filter">
|
||||||
<select id="os">
|
<select id="os">
|
||||||
|
<option value="skipped">All (OS)</option>
|
||||||
<optgroup label="Populars">
|
<optgroup label="Populars">
|
||||||
<option value="windows">Windows</option>
|
<option value="windows">Windows</option>
|
||||||
<option value="mac os">Mac OS</option>
|
<option value="mac os">Mac OS</option>
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<option value="ubuntu">Ubuntu</option>
|
<option value="ubuntu">Ubuntu</option>
|
||||||
<option value="debian">Debian</option>
|
<option value="debian">Debian</option>
|
||||||
<option value="android">Android</option>
|
<option value="android">Android</option>
|
||||||
<option value="ios>">iOS</option>
|
<option value="ios">iOS</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<optgroup label="Others">
|
<optgroup label="Others">
|
||||||
<option value="amigaos">AmigaOS</option>
|
<option value="amigaos">AmigaOS</option>
|
||||||
|
@ -52,6 +52,7 @@
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
<select id="browser">
|
<select id="browser">
|
||||||
|
<option value="skipped">All (Browser)</option>
|
||||||
<optgroup label="Populars">
|
<optgroup label="Populars">
|
||||||
<option value="ie">Internet Explorer</option>
|
<option value="ie">Internet Explorer</option>
|
||||||
<option value="safari">Safari</option>
|
<option value="safari">Safari</option>
|
||||||
|
@ -118,6 +119,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="list" data-loading=true>
|
<div id="list" data-loading=true>
|
||||||
<table>
|
<table>
|
||||||
|
<colgroup>
|
||||||
|
<col width="40">
|
||||||
|
<col width="100">
|
||||||
|
<col width="100">
|
||||||
|
<col>
|
||||||
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
@ -138,8 +145,8 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div hbox>
|
<div hbox>
|
||||||
<input type="search" id="custom" placeholder="Filter">
|
<input type="search" id="custom" placeholder="Filter items">
|
||||||
<input type="button" value="Update">
|
<input type="button" value="Update" disabled="true">
|
||||||
</div>
|
</div>
|
||||||
<div hbox id="agent" pack="center" align="center">
|
<div hbox id="agent" pack="center" align="center">
|
||||||
User-Agent String:
|
User-Agent String:
|
||||||
|
|
|
@ -6,7 +6,7 @@ var json = [];
|
||||||
function filter(list) {
|
function filter(list) {
|
||||||
return list.filter(o => {
|
return list.filter(o => {
|
||||||
const browser = document.getElementById('browser').value;
|
const browser = document.getElementById('browser').value;
|
||||||
if (browser) {
|
if (browser && browser !== 'skipped') {
|
||||||
try {
|
try {
|
||||||
if (o.browser.name.toLowerCase().trim().indexOf(browser.trim()) === -1) {
|
if (o.browser.name.toLowerCase().trim().indexOf(browser.trim()) === -1) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -17,7 +17,7 @@ function filter(list) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const os = document.getElementById('os').value;
|
const os = document.getElementById('os').value;
|
||||||
if (os) {
|
if (os && os !== 'skipped') {
|
||||||
try {
|
try {
|
||||||
if (o.os.name.toLowerCase().trim().indexOf(os.trim()) === -1) {
|
if (o.os.name.toLowerCase().trim().indexOf(os.trim()) === -1) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -71,14 +71,22 @@ function update() {
|
||||||
const tbody = parent.querySelector('tbody');
|
const tbody = parent.querySelector('tbody');
|
||||||
tbody.textContent = '';
|
tbody.textContent = '';
|
||||||
parent.dataset.loading = true;
|
parent.dataset.loading = true;
|
||||||
|
window.setTimeout(() => {
|
||||||
|
const fragment = document.createDocumentFragment();
|
||||||
list.forEach(o => {
|
list.forEach(o => {
|
||||||
const clone = document.importNode(t.content, true);
|
const clone = document.importNode(t.content, true);
|
||||||
clone.querySelector('td:nth-child(2)').textContent = o.browser.name + ' ' + (o.browser.version || '-');
|
const second = clone.querySelector('td:nth-child(2)');
|
||||||
clone.querySelector('td:nth-child(3)').textContent = o.os.name + ' ' + (o.os.version || '-');
|
second.title = second.textContent = o.browser.name + ' ' + (o.browser.version || ' ');
|
||||||
clone.querySelector('td:nth-child(4)').textContent = o.ua;
|
const third = clone.querySelector('td:nth-child(3)');
|
||||||
tbody.appendChild(clone);
|
third.title = third.textContent = o.os.name + ' ' + (o.os.version || ' ');
|
||||||
|
const forth = clone.querySelector('td:nth-child(4)');
|
||||||
|
forth.title = forth.textContent = o.ua;
|
||||||
|
fragment.appendChild(clone);
|
||||||
});
|
});
|
||||||
|
tbody.appendChild(fragment);
|
||||||
|
document.getElementById('custom').placeholder = `Filter among ${list.length} "User-Agent" strings`;
|
||||||
parent.dataset.loading = false;
|
parent.dataset.loading = false;
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('change', ({target}) => {
|
document.addEventListener('change', ({target}) => {
|
||||||
|
@ -122,7 +130,8 @@ chrome.storage.onChanged.addListener(prefs => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
var req = new XMLHttpRequest();
|
window.setTimeout(() => {
|
||||||
|
const req = new XMLHttpRequest();
|
||||||
req.onload = () => {
|
req.onload = () => {
|
||||||
parse(req.response);
|
parse(req.response);
|
||||||
update();
|
update();
|
||||||
|
@ -130,6 +139,7 @@ window.addEventListener('load', () => {
|
||||||
req.open('GET', 'list.json');
|
req.open('GET', 'list.json');
|
||||||
req.responseType = 'json';
|
req.responseType = 'json';
|
||||||
req.send();
|
req.send();
|
||||||
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "User-Agent Switcher",
|
"name": "User-Agent Switcher",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
|
|
||||||
"description": "Spoofs User-Agent strings of your browser",
|
"description": "Spoofs User-Agent strings of your browser",
|
||||||
|
|
||||||
|
@ -35,5 +35,6 @@
|
||||||
"64": "data/icons/64.png"
|
"64": "data/icons/64.png"
|
||||||
},
|
},
|
||||||
"default_popup": "data/popup/index.html"
|
"default_popup": "data/popup/index.html"
|
||||||
}
|
},
|
||||||
|
"homepage_url": "http://add0n.com/useragent-switcher.html"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue