version 0.2.3
14
common.js
|
@ -66,7 +66,11 @@ function match(url) {
|
|||
}
|
||||
else {
|
||||
const h = hostname(url);
|
||||
const s = prefs.custom[h];
|
||||
let s = prefs.custom[h] || prefs.custom['*'];
|
||||
// if s is an array select a random string
|
||||
if (Array.isArray(s)) {
|
||||
s = s[Math.floor(Math.random() * s.length)];
|
||||
}
|
||||
if (s) {
|
||||
const o = {};
|
||||
o.userAgent = s;
|
||||
|
@ -80,7 +84,7 @@ function match(url) {
|
|||
return o;
|
||||
}
|
||||
else {
|
||||
return ua.userAgent ? false : true;
|
||||
return !ua.userAgent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +180,7 @@ User-Agent String: ${prefs.mode === 'custom' ? custom : prefs.ua || navigator.us
|
|||
// FAQs & Feedback
|
||||
chrome.storage.local.get({
|
||||
'version': null,
|
||||
'faqs': navigator.userAgent.indexOf('Firefox') === -1,
|
||||
'faqs': true,
|
||||
'last-update': 0,
|
||||
}, prefs => {
|
||||
const version = chrome.runtime.getManifest().version;
|
||||
|
@ -207,7 +211,3 @@ chrome.storage.local.get({
|
|||
chrome.runtime.getManifest().homepage_url + '?rd=feedback&name=' + name + '&version=' + version
|
||||
);
|
||||
}
|
||||
|
||||
chrome.tabs.create({
|
||||
url: 'data/popup/index.html'
|
||||
})
|
||||
|
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 1 KiB |
BIN
data/icons/18.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
data/icons/19.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 991 B After Width: | Height: | Size: 2 KiB |
BIN
data/icons/36.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
data/icons/38.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 3.9 KiB |
BIN
data/icons/active/128.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 482 B After Width: | Height: | Size: 1.1 KiB |
BIN
data/icons/active/18.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
data/icons/active/19.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
data/icons/active/256.png
Normal file
After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 1,015 B After Width: | Height: | Size: 2.2 KiB |
BIN
data/icons/active/36.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
data/icons/active/38.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.5 KiB |
BIN
data/icons/active/512.png
Normal file
After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 4.5 KiB |
|
@ -8,6 +8,10 @@
|
|||
padding: 10px;
|
||||
}
|
||||
textarea { width: 100%; }
|
||||
.h {
|
||||
text-decoration: underline;
|
||||
text-decoration-style: dashed;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
@ -15,7 +19,7 @@
|
|||
<table width=100%>
|
||||
<tr>
|
||||
<td>
|
||||
<label><input type="radio" name="mode" value="blacklist" id="mode-blacklist"> Black-list mode: Apply the custom user-agent string to all tabs except the tabs with the following top-level hostnames (comma-separated list of hostnames)</label>
|
||||
<label><input type="radio" name="mode" value="blacklist" id="mode-blacklist"> <span class="h">Black-list mode</span>: Apply the custom user-agent string to all tabs except the tabs with the following top-level hostnames (comma-separated list of hostnames)</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -23,7 +27,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label><input type="radio" name="mode" value="whitelist" id="mode-whitelist"> White-list mode: Only apply the custom user-agent string to the tabs with following top-level hostnames</label>
|
||||
<label><input type="radio" name="mode" value="whitelist" id="mode-whitelist"> <span class="h">White-list mode</span>: Only apply the custom user-agent string to the tabs with following top-level hostnames</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -31,7 +35,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label><input type="radio" name="mode" value="custom" id="mode-custom"> Custom mode: Try to resolve the user-agent string from the bellow JSON object; otherwise either use the default user-agent string or use the one that user is set from the popup.</label> <a href="#" id="sample">Insert</a> a sample JSON object.
|
||||
<label><input type="radio" name="mode" value="custom" id="mode-custom"> <span class="h">Custom mode</span>: Try to resolve the user-agent string from a JSON object; otherwise either use the default user-agent string or use the one that user is set from the popup. Use "*" as the hostname to match all domains. You can randomly select from multiple user-agent strings by providing an array instead of a string.</label> <a href="#" id="sample">Insert</a> a sample JSON object.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -59,7 +59,9 @@ document.getElementById('sample').addEventListener('click', e => {
|
|||
|
||||
document.getElementById('custom').value = JSON.stringify({
|
||||
'www.google.com': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36',
|
||||
'www.bing.com': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0'
|
||||
'www.bing.com': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0',
|
||||
'www.example.com': ['random-useragent-1', 'random-user-agent-2'],
|
||||
'*': 'useragent-for-all-hostnames'
|
||||
}, null, 2);
|
||||
});
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ select {
|
|||
border: none;
|
||||
user-select: none;
|
||||
outline: none;
|
||||
color: #000;
|
||||
background: rgba(255,255,255,.5) url(list.svg) no-repeat center right 4px;
|
||||
background-size: 8px;
|
||||
font-size: 13px;
|
||||
|
@ -147,6 +148,10 @@ select {
|
|||
display: none;
|
||||
}
|
||||
|
||||
[data-cmd="refresh"] {
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
[data-cmd="apply"] {
|
||||
color: #fff;
|
||||
background-color: #3c923c;
|
||||
|
@ -161,6 +166,7 @@ select {
|
|||
border: solid 1px #ec9730;
|
||||
}
|
||||
|
||||
[data-cmd="options"],
|
||||
[data-cmd="refresh"] {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
|
|
@ -146,7 +146,8 @@
|
|||
</div>
|
||||
<div hbox>
|
||||
<input type="search" id="custom" placeholder="Filter items">
|
||||
<input type="button" value="Refresh Tab" title="Refresh the current page" style="margin-left: 2px;" data-cmd="refresh">
|
||||
<input type="button" value="Refresh Tab" title="Refresh the current page" data-cmd="refresh">
|
||||
<input type="button" value="Options" title="Open options page" style="margin-left: 2px;" data-cmd="options">
|
||||
</div>
|
||||
<div hbox id="agent" pack="center" align="center">
|
||||
User-Agent String:
|
||||
|
|
|
@ -182,5 +182,8 @@ document.addEventListener('click', ({target}) => {
|
|||
bypassCache: true
|
||||
}));
|
||||
}
|
||||
else if (cmd === 'options') {
|
||||
chrome.runtime.openOptionsPage();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"manifest_version": 2,
|
||||
"name": "User-Agent Switcher",
|
||||
"short_name": "useragent-switcher",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.3",
|
||||
|
||||
"description": "Spoofs User-Agent strings of your browser",
|
||||
|
||||
|
@ -16,12 +16,16 @@
|
|||
],
|
||||
|
||||
"icons": {
|
||||
"16": "data/icons/16.png",
|
||||
"32": "data/icons/32.png",
|
||||
"48": "data/icons/48.png",
|
||||
"64": "data/icons/64.png",
|
||||
"128": "data/icons/128.png",
|
||||
"256": "data/icons/256.png"
|
||||
"16": "data/icons/active/16.png",
|
||||
"18": "data/icons/active/18.png",
|
||||
"19": "data/icons/active/19.png",
|
||||
"32": "data/icons/active/32.png",
|
||||
"36": "data/icons/active/36.png",
|
||||
"38": "data/icons/active/38.png",
|
||||
"48": "data/icons/active/48.png",
|
||||
"64": "data/icons/active/64.png",
|
||||
"128": "data/icons/active/128.png",
|
||||
"256": "data/icons/active/256.png"
|
||||
},
|
||||
"background":{
|
||||
"scripts":[
|
||||
|
@ -49,5 +53,11 @@
|
|||
"match_about_blank": true,
|
||||
"matches": ["*://*/*"],
|
||||
"js": ["data/inject.js"]
|
||||
}]
|
||||
}],
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "{a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7}",
|
||||
"strict_min_version": "52.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|