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,54 +5,55 @@
|
||||||
<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>
|
||||||
<option value="linux">Linux</option>
|
<option value="linux">Linux</option>
|
||||||
<option value="chromium os">Chromium OS</option>
|
<option value="chromium os">Chromium OS</option>
|
||||||
<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>
|
||||||
<option value="openbsd">OpenBSD</option>
|
<option value="openbsd">OpenBSD</option>
|
||||||
<option value="beos">BeOS</option>
|
<option value="beos">BeOS</option>
|
||||||
<option value="haiku">Haiku</option>
|
<option value="haiku">Haiku</option>
|
||||||
<option value="solaris">Solaris</option>
|
<option value="solaris">Solaris</option>
|
||||||
<option value="netbsd">NetBSD</option>
|
<option value="netbsd">NetBSD</option>
|
||||||
<option value="freebsd">FreeBSD</option>
|
<option value="freebsd">FreeBSD</option>
|
||||||
<option value="slackware">Slackware</option>
|
<option value="slackware">Slackware</option>
|
||||||
<option value="suse">SUSE</option>
|
<option value="suse">SUSE</option>
|
||||||
<option value="gentoo">gentoo</option>
|
<option value="gentoo">gentoo</option>
|
||||||
<option value="fedora">Fedora</option>
|
<option value="fedora">Fedora</option>
|
||||||
<option value="gentoo">Gentoo</option>
|
<option value="gentoo">Gentoo</option>
|
||||||
<option value="mageia">Mageia</option>
|
<option value="mageia">Mageia</option>
|
||||||
<option value="centos">CentOS</option>
|
<option value="centos">CentOS</option>
|
||||||
<option value="mint">Mint</option>
|
<option value="mint">Mint</option>
|
||||||
<option value="dragonfly">DragonFly</option>
|
<option value="dragonfly">DragonFly</option>
|
||||||
<option value="kubuntu">Kubuntu</option>
|
<option value="kubuntu">Kubuntu</option>
|
||||||
<option value="mandriva">Mandriva</option>
|
<option value="mandriva">Mandriva</option>
|
||||||
<option value="zenwalk">Zenwalk</option>
|
<option value="zenwalk">Zenwalk</option>
|
||||||
<option value="unix">Unix</option>
|
<option value="unix">Unix</option>
|
||||||
<option value="gnu">GNU</option>
|
<option value="gnu">GNU</option>
|
||||||
<option value="os/2">OS/2</option>
|
<option value="os/2">OS/2</option>
|
||||||
<option value="aix">AIX</option>
|
<option value="aix">AIX</option>
|
||||||
<option value="qnx">QNX</option>
|
<option value="qnx">QNX</option>
|
||||||
<option value="beos">BEOS</option>
|
<option value="beos">BEOS</option>
|
||||||
<option value="risc os">RISC OS</option>
|
<option value="risc os">RISC OS</option>
|
||||||
<option value="symbian">Symbian</option>
|
<option value="symbian">Symbian</option>
|
||||||
<option value="nintendo">Nintendo</option>
|
<option value="nintendo">Nintendo</option>
|
||||||
<option value="opensolaris">OpenSolaris</option>
|
<option value="opensolaris">OpenSolaris</option>
|
||||||
<option value="kubuntu">kubuntu</option>
|
<option value="kubuntu">kubuntu</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
<select id="browser">
|
<select id="browser">
|
||||||
<optgroup label="Populars">
|
<option value="skipped">All (Browser)</option>
|
||||||
|
<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>
|
||||||
<option value="chrome">Chrome</option>
|
<option value="chrome">Chrome</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;
|
||||||
list.forEach(o => {
|
window.setTimeout(() => {
|
||||||
const clone = document.importNode(t.content, true);
|
const fragment = document.createDocumentFragment();
|
||||||
clone.querySelector('td:nth-child(2)').textContent = o.browser.name + ' ' + (o.browser.version || '-');
|
list.forEach(o => {
|
||||||
clone.querySelector('td:nth-child(3)').textContent = o.os.name + ' ' + (o.os.version || '-');
|
const clone = document.importNode(t.content, true);
|
||||||
clone.querySelector('td:nth-child(4)').textContent = o.ua;
|
const second = clone.querySelector('td:nth-child(2)');
|
||||||
tbody.appendChild(clone);
|
second.title = second.textContent = o.browser.name + ' ' + (o.browser.version || ' ');
|
||||||
});
|
const third = clone.querySelector('td:nth-child(3)');
|
||||||
parent.dataset.loading = false;
|
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}) => {
|
document.addEventListener('change', ({target}) => {
|
||||||
|
@ -122,14 +130,16 @@ chrome.storage.onChanged.addListener(prefs => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
var req = new XMLHttpRequest();
|
window.setTimeout(() => {
|
||||||
req.onload = () => {
|
const req = new XMLHttpRequest();
|
||||||
parse(req.response);
|
req.onload = () => {
|
||||||
update();
|
parse(req.response);
|
||||||
};
|
update();
|
||||||
req.open('GET', 'list.json');
|
};
|
||||||
req.responseType = 'json';
|
req.open('GET', 'list.json');
|
||||||
req.send();
|
req.responseType = 'json';
|
||||||
|
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