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({
|
||||
ua: ''
|
||||
}, prefs => update(prefs.ua));
|
||||
chrome.storage.onChanged.addListener(prefs => {
|
||||
update(prefs.ua.newValue);
|
||||
chrome.storage.onChanged.addListener(prefs => prefs.ua && 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 {
|
||||
background-color: #fff;
|
||||
font-family: "Helvetica Neue",Helvetica,sans-serif;
|
||||
font-size: 13px;
|
||||
width: 700px;
|
||||
|
@ -40,6 +41,7 @@ input[type=text] {
|
|||
width: 100%;
|
||||
margin-right: 2px;
|
||||
text-indent: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
select,
|
||||
input {
|
||||
|
@ -57,6 +59,10 @@ input[type=button] {
|
|||
input[type=button]:active {
|
||||
opacity: 0.5;
|
||||
}
|
||||
input[type=button]:disabled {
|
||||
opacity: 0.2;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
#list {
|
||||
margin: 20px 0;
|
||||
|
@ -68,26 +74,26 @@ input[type=button]:active {
|
|||
background: url(loading.gif) top 120px center no-repeat;
|
||||
background-size: 64px;
|
||||
}
|
||||
#list table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
#list tr {
|
||||
cursor: pointer;
|
||||
}
|
||||
#list tr[data-matched=false] {
|
||||
opacity: 0.5;
|
||||
}
|
||||
#list tr:nth-child(even) {
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
#list tbody tr:nth-child(odd) {
|
||||
background-color: #fff;
|
||||
}
|
||||
#list td:nth-child(1) {
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
#list td:nth-child(2),
|
||||
#list td:nth-child(3) {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#list tr {
|
||||
height: 22px;
|
||||
#list td {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding: 3px 5px;
|
||||
}
|
||||
|
||||
#tools input {
|
||||
|
|
|
@ -5,54 +5,55 @@
|
|||
<link rel="stylesheet" href="index.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div hbox id="filter">
|
||||
<select id="os">
|
||||
<option value="skipped">All (OS)</option>
|
||||
<optgroup label="Populars">
|
||||
<option value="windows">Windows</option>
|
||||
<option value="mac os">Mac OS</option>
|
||||
<option value="linux">Linux</option>
|
||||
<option value="chromium os">Chromium OS</option>
|
||||
<option value="ubuntu">Ubuntu</option>
|
||||
<option value="debian">Debian</option>
|
||||
<option value="android">Android</option>
|
||||
<option value="ios>">iOS</option>
|
||||
<option value="windows">Windows</option>
|
||||
<option value="mac os">Mac OS</option>
|
||||
<option value="linux">Linux</option>
|
||||
<option value="chromium os">Chromium OS</option>
|
||||
<option value="ubuntu">Ubuntu</option>
|
||||
<option value="debian">Debian</option>
|
||||
<option value="android">Android</option>
|
||||
<option value="ios">iOS</option>
|
||||
</optgroup>
|
||||
<optgroup label="Others">
|
||||
<option value="amigaos">AmigaOS</option>
|
||||
<option value="openbsd">OpenBSD</option>
|
||||
<option value="beos">BeOS</option>
|
||||
<option value="haiku">Haiku</option>
|
||||
<option value="solaris">Solaris</option>
|
||||
<option value="netbsd">NetBSD</option>
|
||||
<option value="freebsd">FreeBSD</option>
|
||||
<option value="slackware">Slackware</option>
|
||||
<option value="suse">SUSE</option>
|
||||
<option value="gentoo">gentoo</option>
|
||||
<option value="fedora">Fedora</option>
|
||||
<option value="gentoo">Gentoo</option>
|
||||
<option value="mageia">Mageia</option>
|
||||
<option value="centos">CentOS</option>
|
||||
<option value="mint">Mint</option>
|
||||
<option value="dragonfly">DragonFly</option>
|
||||
<option value="kubuntu">Kubuntu</option>
|
||||
<option value="mandriva">Mandriva</option>
|
||||
<option value="zenwalk">Zenwalk</option>
|
||||
<option value="unix">Unix</option>
|
||||
<option value="gnu">GNU</option>
|
||||
<option value="os/2">OS/2</option>
|
||||
<option value="aix">AIX</option>
|
||||
<option value="qnx">QNX</option>
|
||||
<option value="beos">BEOS</option>
|
||||
<option value="risc os">RISC OS</option>
|
||||
<option value="symbian">Symbian</option>
|
||||
<option value="nintendo">Nintendo</option>
|
||||
<option value="opensolaris">OpenSolaris</option>
|
||||
<option value="kubuntu">kubuntu</option>
|
||||
<option value="amigaos">AmigaOS</option>
|
||||
<option value="openbsd">OpenBSD</option>
|
||||
<option value="beos">BeOS</option>
|
||||
<option value="haiku">Haiku</option>
|
||||
<option value="solaris">Solaris</option>
|
||||
<option value="netbsd">NetBSD</option>
|
||||
<option value="freebsd">FreeBSD</option>
|
||||
<option value="slackware">Slackware</option>
|
||||
<option value="suse">SUSE</option>
|
||||
<option value="gentoo">gentoo</option>
|
||||
<option value="fedora">Fedora</option>
|
||||
<option value="gentoo">Gentoo</option>
|
||||
<option value="mageia">Mageia</option>
|
||||
<option value="centos">CentOS</option>
|
||||
<option value="mint">Mint</option>
|
||||
<option value="dragonfly">DragonFly</option>
|
||||
<option value="kubuntu">Kubuntu</option>
|
||||
<option value="mandriva">Mandriva</option>
|
||||
<option value="zenwalk">Zenwalk</option>
|
||||
<option value="unix">Unix</option>
|
||||
<option value="gnu">GNU</option>
|
||||
<option value="os/2">OS/2</option>
|
||||
<option value="aix">AIX</option>
|
||||
<option value="qnx">QNX</option>
|
||||
<option value="beos">BEOS</option>
|
||||
<option value="risc os">RISC OS</option>
|
||||
<option value="symbian">Symbian</option>
|
||||
<option value="nintendo">Nintendo</option>
|
||||
<option value="opensolaris">OpenSolaris</option>
|
||||
<option value="kubuntu">kubuntu</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
<select id="browser">
|
||||
<optgroup label="Populars">
|
||||
<option value="skipped">All (Browser)</option>
|
||||
<optgroup label="Populars">
|
||||
<option value="ie">Internet Explorer</option>
|
||||
<option value="safari">Safari</option>
|
||||
<option value="chrome">Chrome</option>
|
||||
|
@ -118,6 +119,12 @@
|
|||
</div>
|
||||
<div id="list" data-loading=true>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40">
|
||||
<col width="100">
|
||||
<col width="100">
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
|
@ -138,8 +145,8 @@
|
|||
</table>
|
||||
</div>
|
||||
<div hbox>
|
||||
<input type="search" id="custom" placeholder="Filter">
|
||||
<input type="button" value="Update">
|
||||
<input type="search" id="custom" placeholder="Filter items">
|
||||
<input type="button" value="Update" disabled="true">
|
||||
</div>
|
||||
<div hbox id="agent" pack="center" align="center">
|
||||
User-Agent String:
|
||||
|
|
|
@ -6,7 +6,7 @@ var json = [];
|
|||
function filter(list) {
|
||||
return list.filter(o => {
|
||||
const browser = document.getElementById('browser').value;
|
||||
if (browser) {
|
||||
if (browser && browser !== 'skipped') {
|
||||
try {
|
||||
if (o.browser.name.toLowerCase().trim().indexOf(browser.trim()) === -1) {
|
||||
return false;
|
||||
|
@ -17,7 +17,7 @@ function filter(list) {
|
|||
}
|
||||
}
|
||||
const os = document.getElementById('os').value;
|
||||
if (os) {
|
||||
if (os && os !== 'skipped') {
|
||||
try {
|
||||
if (o.os.name.toLowerCase().trim().indexOf(os.trim()) === -1) {
|
||||
return false;
|
||||
|
@ -71,14 +71,22 @@ function update() {
|
|||
const tbody = parent.querySelector('tbody');
|
||||
tbody.textContent = '';
|
||||
parent.dataset.loading = true;
|
||||
list.forEach(o => {
|
||||
const clone = document.importNode(t.content, true);
|
||||
clone.querySelector('td:nth-child(2)').textContent = o.browser.name + ' ' + (o.browser.version || '-');
|
||||
clone.querySelector('td:nth-child(3)').textContent = o.os.name + ' ' + (o.os.version || '-');
|
||||
clone.querySelector('td:nth-child(4)').textContent = o.ua;
|
||||
tbody.appendChild(clone);
|
||||
});
|
||||
parent.dataset.loading = false;
|
||||
window.setTimeout(() => {
|
||||
const fragment = document.createDocumentFragment();
|
||||
list.forEach(o => {
|
||||
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;
|
||||
fragment.appendChild(clone);
|
||||
});
|
||||
tbody.appendChild(fragment);
|
||||
document.getElementById('custom').placeholder = `Filter among ${list.length} "User-Agent" strings`;
|
||||
parent.dataset.loading = false;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
document.addEventListener('change', ({target}) => {
|
||||
|
@ -122,14 +130,16 @@ chrome.storage.onChanged.addListener(prefs => {
|
|||
}
|
||||
});
|
||||
window.addEventListener('load', () => {
|
||||
var req = new XMLHttpRequest();
|
||||
req.onload = () => {
|
||||
parse(req.response);
|
||||
update();
|
||||
};
|
||||
req.open('GET', 'list.json');
|
||||
req.responseType = 'json';
|
||||
req.send();
|
||||
window.setTimeout(() => {
|
||||
const req = new XMLHttpRequest();
|
||||
req.onload = () => {
|
||||
parse(req.response);
|
||||
update();
|
||||
};
|
||||
req.open('GET', 'list.json');
|
||||
req.responseType = 'json';
|
||||
req.send();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
// commands
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "User-Agent Switcher",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
|
||||
"description": "Spoofs User-Agent strings of your browser",
|
||||
|
||||
|
@ -35,5 +35,6 @@
|
|||
"64": "data/icons/64.png"
|
||||
},
|
||||
"default_popup": "data/popup/index.html"
|
||||
}
|
||||
},
|
||||
"homepage_url": "http://add0n.com/useragent-switcher.html"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue