version 0.2.3

This commit is contained in:
Ray Lothian 2018-05-15 12:24:51 +04:30
parent 1213fff7b3
commit ce9223f342
29 changed files with 46 additions and 20 deletions

View file

@ -66,7 +66,11 @@ function match(url) {
} }
else { else {
const h = hostname(url); 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) { if (s) {
const o = {}; const o = {};
o.userAgent = s; o.userAgent = s;
@ -80,7 +84,7 @@ function match(url) {
return o; return o;
} }
else { 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 // FAQs & Feedback
chrome.storage.local.get({ chrome.storage.local.get({
'version': null, 'version': null,
'faqs': navigator.userAgent.indexOf('Firefox') === -1, 'faqs': true,
'last-update': 0, 'last-update': 0,
}, prefs => { }, prefs => {
const version = chrome.runtime.getManifest().version; 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.runtime.getManifest().homepage_url + '?rd=feedback&name=' + name + '&version=' + version
); );
} }
chrome.tabs.create({
url: 'data/popup/index.html'
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 474 B

After

Width:  |  Height:  |  Size: 1 KiB

BIN
data/icons/18.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
data/icons/19.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 991 B

After

Width:  |  Height:  |  Size: 2 KiB

BIN
data/icons/36.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
data/icons/38.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
data/icons/active/128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 482 B

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
data/icons/active/18.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
data/icons/active/19.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
data/icons/active/256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,015 B

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
data/icons/active/36.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
data/icons/active/38.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
data/icons/active/512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

@ -8,6 +8,10 @@
padding: 10px; padding: 10px;
} }
textarea { width: 100%; } textarea { width: 100%; }
.h {
text-decoration: underline;
text-decoration-style: dashed;
}
</style> </style>
</head> </head>
@ -15,7 +19,7 @@
<table width=100%> <table width=100%>
<tr> <tr>
<td> <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> </td>
</tr> </tr>
<tr> <tr>
@ -23,7 +27,7 @@
</tr> </tr>
<tr> <tr>
<td> <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> </td>
</tr> </tr>
<tr> <tr>
@ -31,7 +35,7 @@
</tr> </tr>
<tr> <tr>
<td> <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> </td>
</tr> </tr>
<tr> <tr>

View file

@ -59,7 +59,9 @@ document.getElementById('sample').addEventListener('click', e => {
document.getElementById('custom').value = JSON.stringify({ 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.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); }, null, 2);
}); });

View file

@ -69,6 +69,7 @@ select {
border: none; border: none;
user-select: none; user-select: none;
outline: none; outline: none;
color: #000;
background: rgba(255,255,255,.5) url(list.svg) no-repeat center right 4px; background: rgba(255,255,255,.5) url(list.svg) no-repeat center right 4px;
background-size: 8px; background-size: 8px;
font-size: 13px; font-size: 13px;
@ -147,6 +148,10 @@ select {
display: none; display: none;
} }
[data-cmd="refresh"] {
margin-left: 2px;
margin-right: 2px;
}
[data-cmd="apply"] { [data-cmd="apply"] {
color: #fff; color: #fff;
background-color: #3c923c; background-color: #3c923c;
@ -161,6 +166,7 @@ select {
border: solid 1px #ec9730; border: solid 1px #ec9730;
} }
[data-cmd="options"],
[data-cmd="refresh"] { [data-cmd="refresh"] {
background-color: #f5f5f5; background-color: #f5f5f5;
} }

View file

@ -146,7 +146,8 @@
</div> </div>
<div hbox> <div hbox>
<input type="search" id="custom" placeholder="Filter items"> <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>
<div hbox id="agent" pack="center" align="center"> <div hbox id="agent" pack="center" align="center">
User-Agent String:&nbsp; User-Agent String:&nbsp;

View file

@ -182,5 +182,8 @@ document.addEventListener('click', ({target}) => {
bypassCache: true bypassCache: true
})); }));
} }
else if (cmd === 'options') {
chrome.runtime.openOptionsPage();
}
} }
}); });

View file

@ -2,7 +2,7 @@
"manifest_version": 2, "manifest_version": 2,
"name": "User-Agent Switcher", "name": "User-Agent Switcher",
"short_name": "useragent-switcher", "short_name": "useragent-switcher",
"version": "0.2.0", "version": "0.2.3",
"description": "Spoofs User-Agent strings of your browser", "description": "Spoofs User-Agent strings of your browser",
@ -16,12 +16,16 @@
], ],
"icons": { "icons": {
"16": "data/icons/16.png", "16": "data/icons/active/16.png",
"32": "data/icons/32.png", "18": "data/icons/active/18.png",
"48": "data/icons/48.png", "19": "data/icons/active/19.png",
"64": "data/icons/64.png", "32": "data/icons/active/32.png",
"128": "data/icons/128.png", "36": "data/icons/active/36.png",
"256": "data/icons/256.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":{ "background":{
"scripts":[ "scripts":[
@ -49,5 +53,11 @@
"match_about_blank": true, "match_about_blank": true,
"matches": ["*://*/*"], "matches": ["*://*/*"],
"js": ["data/inject.js"] "js": ["data/inject.js"]
}] }],
"applications": {
"gecko": {
"id": "{a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7}",
"strict_min_version": "52.0"
}
}
} }