diff --git a/common.js b/common.js index 12fbd85..5c2663a 100644 --- a/common.js +++ b/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' -}) diff --git a/data/icons/128.png b/data/icons/128.png index 39dc5a9..5a1728e 100644 Binary files a/data/icons/128.png and b/data/icons/128.png differ diff --git a/data/icons/16.png b/data/icons/16.png index 5e5227c..5f500f4 100644 Binary files a/data/icons/16.png and b/data/icons/16.png differ diff --git a/data/icons/18.png b/data/icons/18.png new file mode 100644 index 0000000..265595a Binary files /dev/null and b/data/icons/18.png differ diff --git a/data/icons/19.png b/data/icons/19.png new file mode 100644 index 0000000..c9b4803 Binary files /dev/null and b/data/icons/19.png differ diff --git a/data/icons/256.png b/data/icons/256.png index c1aa4df..6024c3a 100644 Binary files a/data/icons/256.png and b/data/icons/256.png differ diff --git a/data/icons/32.png b/data/icons/32.png index ce9a36a..d98aac4 100644 Binary files a/data/icons/32.png and b/data/icons/32.png differ diff --git a/data/icons/36.png b/data/icons/36.png new file mode 100644 index 0000000..6496212 Binary files /dev/null and b/data/icons/36.png differ diff --git a/data/icons/38.png b/data/icons/38.png new file mode 100644 index 0000000..4533c51 Binary files /dev/null and b/data/icons/38.png differ diff --git a/data/icons/48.png b/data/icons/48.png index 6687008..8643a43 100644 Binary files a/data/icons/48.png and b/data/icons/48.png differ diff --git a/data/icons/512.png b/data/icons/512.png index e8e74fa..d262332 100644 Binary files a/data/icons/512.png and b/data/icons/512.png differ diff --git a/data/icons/64.png b/data/icons/64.png index dc6ac1d..d005e4a 100644 Binary files a/data/icons/64.png and b/data/icons/64.png differ diff --git a/data/icons/active/128.png b/data/icons/active/128.png new file mode 100644 index 0000000..bac2a00 Binary files /dev/null and b/data/icons/active/128.png differ diff --git a/data/icons/active/16.png b/data/icons/active/16.png index 614b462..f4d5c6d 100644 Binary files a/data/icons/active/16.png and b/data/icons/active/16.png differ diff --git a/data/icons/active/18.png b/data/icons/active/18.png new file mode 100644 index 0000000..c820a17 Binary files /dev/null and b/data/icons/active/18.png differ diff --git a/data/icons/active/19.png b/data/icons/active/19.png new file mode 100644 index 0000000..b7b6c51 Binary files /dev/null and b/data/icons/active/19.png differ diff --git a/data/icons/active/256.png b/data/icons/active/256.png new file mode 100644 index 0000000..24da822 Binary files /dev/null and b/data/icons/active/256.png differ diff --git a/data/icons/active/32.png b/data/icons/active/32.png index d5d1260..57822fb 100644 Binary files a/data/icons/active/32.png and b/data/icons/active/32.png differ diff --git a/data/icons/active/36.png b/data/icons/active/36.png new file mode 100644 index 0000000..b87ea10 Binary files /dev/null and b/data/icons/active/36.png differ diff --git a/data/icons/active/38.png b/data/icons/active/38.png new file mode 100644 index 0000000..054e54a Binary files /dev/null and b/data/icons/active/38.png differ diff --git a/data/icons/active/48.png b/data/icons/active/48.png index d7c85a0..0ba8aa7 100644 Binary files a/data/icons/active/48.png and b/data/icons/active/48.png differ diff --git a/data/icons/active/512.png b/data/icons/active/512.png new file mode 100644 index 0000000..d88307d Binary files /dev/null and b/data/icons/active/512.png differ diff --git a/data/icons/active/64.png b/data/icons/active/64.png index 320d281..aebdf46 100644 Binary files a/data/icons/active/64.png and b/data/icons/active/64.png differ diff --git a/data/options/index.html b/data/options/index.html index aeca2cd..7388bcb 100644 --- a/data/options/index.html +++ b/data/options/index.html @@ -8,6 +8,10 @@ padding: 10px; } textarea { width: 100%; } + .h { + text-decoration: underline; + text-decoration-style: dashed; + } @@ -15,7 +19,7 @@ @@ -23,7 +27,7 @@ @@ -31,7 +35,7 @@ diff --git a/data/options/index.js b/data/options/index.js index 49e2736..c274b6f 100644 --- a/data/options/index.js +++ b/data/options/index.js @@ -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); }); diff --git a/data/popup/index.css b/data/popup/index.css index 0d71e90..66ea429 100644 --- a/data/popup/index.css +++ b/data/popup/index.css @@ -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; } diff --git a/data/popup/index.html b/data/popup/index.html index 8099d81..7b920ea 100644 --- a/data/popup/index.html +++ b/data/popup/index.html @@ -146,7 +146,8 @@
- + +
User-Agent String:  diff --git a/data/popup/index.js b/data/popup/index.js index 76bbcef..7737c05 100644 --- a/data/popup/index.js +++ b/data/popup/index.js @@ -182,5 +182,8 @@ document.addEventListener('click', ({target}) => { bypassCache: true })); } + else if (cmd === 'options') { + chrome.runtime.openOptionsPage(); + } } }); diff --git a/manifest.json b/manifest.json index 2f1c8d8..a7a2493 100755 --- a/manifest.json +++ b/manifest.json @@ -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" + } + } }
- +
- +
- Insert a sample JSON object. + Insert a sample JSON object.