-
Notifications
You must be signed in to change notification settings - Fork 161
Added random select button. #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
[{"ua":"Mozilla/5.0 (Windows; U; Windows CE; Mobile; like Android; ko-kr) AppleWebKit/533.3 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.3 Dorothy","browser":{"name":"Android Browser","version":"4.0","major":"4"},"engine":{"name":"WebKit","version":"533.3"},"os":{"name":"Windows","version":"CE"},"device":{"type":"mobile"},"cpu":{}},{"ua":"Mozilla/5.0 (Android 2.2; Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4","browser":{"name":"Android Browser","version":"5.0.3","major":"5"},"engine":{"name":"WebKit","version":"533.19.4"},"os":{"name":"Windows","version":"7"},"device":{"model":"en-US","type":"tablet"},"cpu":{}}] | ||
[ | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows CE; Mobile; like Android; ko-kr) AppleWebKit/533.3 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.3 Dorothy", | ||
"browser": { "name": "Android Browser", "version": "4.0", "major": "4" }, | ||
"engine": { "name": "WebKit", "version": "533.3" }, | ||
"os": { "name": "Windows", "version": "CE" }, | ||
"device": { "type": "mobile" }, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Android 2.2; Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4", | ||
"browser": { "name": "Android Browser", "version": "5.0.3", "major": "5" }, | ||
"engine": { "name": "WebKit", "version": "533.19.4" }, | ||
"os": { "name": "Windows", "version": "7" }, | ||
"device": { "model": "en-US", "type": "tablet" }, | ||
"cpu": {} | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,122 @@ | ||
[{"ua":"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6 (Change: )","browser":{"name":"Arora","version":"0.6","major":"0"},"engine":{"name":"WebKit","version":"527"},"os":{"name":"Windows","version":"Vista"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6 (Change: )","browser":{"name":"Arora","version":"0.6","major":"0"},"engine":{"name":"WebKit","version":"527"},"os":{"name":"Windows","version":"XP"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: )","browser":{"name":"Arora","version":"0.4","major":"0"},"engine":{"name":"WebKit","version":"527"},"os":{"name":"Windows","version":"Vista"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 6.0; de-DE) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: )","browser":{"name":"Arora","version":"0.4","major":"0"},"engine":{"name":"WebKit","version":"527"},"os":{"name":"Windows","version":"Vista"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 5.2; pt-BR) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: )","browser":{"name":"Arora","version":"0.4","major":"0"},"engine":{"name":"WebKit","version":"527"},"os":{"name":"Windows","version":"XP"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: )","browser":{"name":"Arora","version":"0.4","major":"0"},"engine":{"name":"WebKit","version":"527"},"os":{"name":"Windows","version":"XP"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)","browser":{"name":"Arora","version":"0.3","major":"0"},"engine":{"name":"WebKit","version":"523.15"},"os":{"name":"Windows","version":"XP"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-BE) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)","browser":{"name":"Arora","version":"0.3","major":"0"},"engine":{"name":"WebKit","version":"523.15"},"os":{"name":"Windows","version":"XP"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)","browser":{"name":"Arora","version":"0.3","major":"0"},"engine":{"name":"WebKit","version":"523.15"},"os":{"name":"Windows","version":"XP"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 6.0; de-DE) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2","browser":{"name":"Arora","version":"0.2","major":"0"},"engine":{"name":"WebKit","version":"523.15"},"os":{"name":"Windows","version":"Vista"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 5.1; nl-NL) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2","browser":{"name":"Arora","version":"0.2","major":"0"},"engine":{"name":"WebKit","version":"523.15"},"os":{"name":"Windows","version":"XP"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2","browser":{"name":"Arora","version":"0.2","major":"0"},"engine":{"name":"WebKit","version":"523.15"},"os":{"name":"Windows","version":"XP"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 5.1; de-CH) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2","browser":{"name":"Arora","version":"0.2","major":"0"},"engine":{"name":"WebKit","version":"523.15"},"os":{"name":"Windows","version":"XP"},"device":{},"cpu":{}},{"ua":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) Arora/0.11.0 Safari/534.34","browser":{"name":"Arora","version":"0.11.0","major":"0"},"engine":{"name":"WebKit","version":"534.34"},"os":{"name":"Windows","version":"7"},"device":{},"cpu":{"architecture":"amd64"}},{"ua":"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-MY) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.10.0","browser":{"name":"Arora","version":"0.10.0","major":"0"},"engine":{"name":"WebKit","version":"527"},"os":{"name":"Windows","version":"Vista"},"device":{},"cpu":{}}] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These JSON files are created by an script. Do not modify them. |
||
[ | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6 (Change: )", | ||
"browser": { "name": "Arora", "version": "0.6", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "527" }, | ||
"os": { "name": "Windows", "version": "Vista" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6 (Change: )", | ||
"browser": { "name": "Arora", "version": "0.6", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "527" }, | ||
"os": { "name": "Windows", "version": "XP" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: )", | ||
"browser": { "name": "Arora", "version": "0.4", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "527" }, | ||
"os": { "name": "Windows", "version": "Vista" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 6.0; de-DE) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: )", | ||
"browser": { "name": "Arora", "version": "0.4", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "527" }, | ||
"os": { "name": "Windows", "version": "Vista" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 5.2; pt-BR) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: )", | ||
"browser": { "name": "Arora", "version": "0.4", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "527" }, | ||
"os": { "name": "Windows", "version": "XP" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: )", | ||
"browser": { "name": "Arora", "version": "0.4", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "527" }, | ||
"os": { "name": "Windows", "version": "XP" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)", | ||
"browser": { "name": "Arora", "version": "0.3", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "523.15" }, | ||
"os": { "name": "Windows", "version": "XP" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-BE) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)", | ||
"browser": { "name": "Arora", "version": "0.3", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "523.15" }, | ||
"os": { "name": "Windows", "version": "XP" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)", | ||
"browser": { "name": "Arora", "version": "0.3", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "523.15" }, | ||
"os": { "name": "Windows", "version": "XP" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 6.0; de-DE) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2", | ||
"browser": { "name": "Arora", "version": "0.2", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "523.15" }, | ||
"os": { "name": "Windows", "version": "Vista" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 5.1; nl-NL) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2", | ||
"browser": { "name": "Arora", "version": "0.2", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "523.15" }, | ||
"os": { "name": "Windows", "version": "XP" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2", | ||
"browser": { "name": "Arora", "version": "0.2", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "523.15" }, | ||
"os": { "name": "Windows", "version": "XP" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 5.1; de-CH) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2", | ||
"browser": { "name": "Arora", "version": "0.2", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "523.15" }, | ||
"os": { "name": "Windows", "version": "XP" }, | ||
"device": {}, | ||
"cpu": {} | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) Arora/0.11.0 Safari/534.34", | ||
"browser": { "name": "Arora", "version": "0.11.0", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "534.34" }, | ||
"os": { "name": "Windows", "version": "7" }, | ||
"device": {}, | ||
"cpu": { "architecture": "amd64" } | ||
}, | ||
{ | ||
"ua": "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-MY) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.10.0", | ||
"browser": { "name": "Arora", "version": "0.10.0", "major": "0" }, | ||
"engine": { "name": "WebKit", "version": "527" }, | ||
"os": { "name": "Windows", "version": "Vista" }, | ||
"device": {}, | ||
"cpu": {} | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,8 +187,8 @@ function update(ua) { | |
else { | ||
throw Error('OS is not found'); | ||
} | ||
// FF 55.0 does not support finally | ||
}).catch(() => {}).then(() => { | ||
// FF 55.0 does not support finally | ||
}).catch(() => { }).then(() => { | ||
parent.dataset.loading = false; | ||
}); | ||
} | ||
|
@@ -203,7 +203,7 @@ document.getElementById('sort').addEventListener('change', e => chrome.storage.l | |
'popup-sort': e.target.value | ||
})); | ||
|
||
document.addEventListener('change', ({target}) => { | ||
document.addEventListener('change', ({ target }) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not change formatting of files. |
||
if (target.closest('#filter')) { | ||
chrome.storage.local.get({ | ||
ua: '' | ||
|
@@ -250,7 +250,7 @@ document.addEventListener('DOMContentLoaded', () => fetch('./map.json').then(r = | |
}); | ||
})); | ||
|
||
document.getElementById('list').addEventListener('click', ({target}) => { | ||
document.getElementById('list').addEventListener('click', ({ target }) => { | ||
const tr = target.closest('tbody tr'); | ||
if (tr) { | ||
const input = tr.querySelector('input'); | ||
|
@@ -263,7 +263,7 @@ document.getElementById('list').addEventListener('click', ({target}) => { | |
} | ||
}); | ||
|
||
document.getElementById('custom').addEventListener('keyup', ({target}) => { | ||
document.getElementById('custom').addEventListener('keyup', ({ target }) => { | ||
const value = target.value; | ||
[...document.querySelectorAll('#list tbody tr')] | ||
.forEach(tr => tr.dataset.matched = tr.textContent.toLowerCase().indexOf(value.toLowerCase()) !== -1); | ||
|
@@ -281,9 +281,37 @@ function msg(msg) { | |
toast.textContent = msg; | ||
window.setTimeout(() => toast.textContent = '', 2000); | ||
} | ||
// get random elements | ||
function getRandomElement(array) { | ||
console.log(array); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the debugging logs. |
||
return array[Math.floor(Math.random() * array.length)]; | ||
} | ||
|
||
// gets random browser and os | ||
function getRandomBrowserAndOS() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The random UA, must be selected from well-known OS and browsers. Selecting a random OS breaks many websites. |
||
return fetch('./map.json') | ||
.then(response => response.json()) | ||
.then(map => { | ||
const randomBrowser = getRandomElement(map.browser); | ||
console.log(randomBrowser); | ||
const randomOS = getRandomElement(map.matching[randomBrowser.toLowerCase()]); | ||
return { randomBrowser, randomOS }; | ||
}); | ||
} | ||
|
||
// getRandomUserAgent: uses random browser and os to get random user agent | ||
function getRandomUserAgent() { | ||
return getRandomBrowserAndOS().then(({ randomBrowser, randomOS }) => { | ||
const path = `browsers/${randomBrowser.toLowerCase()}-${randomOS.toLowerCase().replace(/\//g, '-')}.json`; | ||
return get(path).then(response => response.json()).then(list => { | ||
const randomUserAgent = getRandomElement(list); | ||
return randomUserAgent; | ||
}); | ||
}); | ||
} | ||
|
||
// commands | ||
document.addEventListener('click', ({target}) => { | ||
document.addEventListener('click', ({ target }) => { | ||
const cmd = target.dataset.cmd; | ||
if (cmd) { | ||
if (cmd === 'apply') { | ||
|
@@ -325,6 +353,17 @@ document.addEventListener('click', ({target}) => { | |
} | ||
}); | ||
} | ||
else if (cmd === 'random') { | ||
getRandomUserAgent().then(randomUA => { | ||
document.getElementById('ua').value = randomUA.ua; | ||
document.getElementById('browser').value = randomUA.browser.name; | ||
document.getElementById('os').value = randomUA.os.name; | ||
document.getElementById('ua').dispatchEvent(new Event('input')); | ||
|
||
// document.getElementById('sort').value = randomUA['popup-sort']; | ||
msg(chrome.i18n.getMessage('msgRandomUASet')); | ||
}); | ||
} | ||
else if (cmd === 'reset') { | ||
const input = document.querySelector('#list :checked'); | ||
if (input) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removal is irrelevant to the merge request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting was done by vscode. Also some changes may have been mistake from my side sorry for that