This commit is contained in:
Ray Lothian 2022-11-13 06:26:32 -05:00
parent 2e4a330263
commit 4d968b7bc5
3 changed files with 34 additions and 17 deletions

View file

@ -1,2 +1,2 @@
ua-parser.min.js: ua-parser.min.js:
https://github.com/faisalman/ua-parser-js/releases/tag/0.7.28 https://github.com/faisalman/ua-parser-js/releases/tag/1.0.32

View file

@ -264,14 +264,34 @@ const ua = {
o.productSub = '20030107'; o.productSub = '20030107';
if (p.browser && p.browser.major) { if (p.browser && p.browser.major) {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-UA-Platform
let platform = 'Unknown';
if (p.os && p.os.name) {
const name = p.os.name.toLowerCase();
if (name.includes('mac')) {
platform = 'macOS';
}
else if (name.includes('debian')) {
platform = 'Linux';
}
else {
platform = p.os.name;
}
}
o.userAgentData = { o.userAgentData = {
brands: [ brands: [{
{brand: ' Not A;Brand', version: '99'}, brand: 'Not=A?Brand',
{brand: 'Chromium', version: p.browser.major}, version: '99'
{brand: 'Google Chrome', version: p.browser.major} }, {
], brand: p.browser.name === 'Chrome' ? 'Google Chrome' : p.browser.name,
version: p.browser.major
}, {
brand: 'Chromium',
version: p.browser.major
}],
mobile: /Android|webOS|iPhone|iPad|Mac|Macintosh|iPod|BlackBerry|IEMobile|Opera Mini/i.test(s), mobile: /Android|webOS|iPhone|iPad|Mac|Macintosh|iPod|BlackBerry|IEMobile|Opera Mini/i.test(s),
platform: o.platform platform
}; };
} }
} }
@ -553,6 +573,8 @@ const onCommitted = d => {
} }
const o = cache[tabId] || ua.object(tabId, undefined, cookieStoreId); const o = cache[tabId] || ua.object(tabId, undefined, cookieStoreId);
if (o && o.userAgent) { if (o && o.userAgent) {
const s = btoa(unescape(encodeURIComponent(JSON.stringify(o))));
chrome.tabs.executeScript(tabId, { chrome.tabs.executeScript(tabId, {
runAt: 'document_start', runAt: 'document_start',
frameId, frameId,
@ -560,7 +582,7 @@ const onCommitted = d => {
const script = document.createElement('script'); const script = document.createElement('script');
script.textContent = \`{ script.textContent = \`{
document.currentScript.dataset.injected = true; document.currentScript.dataset.injected = true;
const o = JSON.parse('${JSON.stringify(o)}'); const o = JSON.parse(decodeURIComponent(escape(atob('${s}'))));
for (const key of Object.keys(o)) { for (const key of Object.keys(o)) {
if (o[key] === '[delete]') { if (o[key] === '[delete]') {

File diff suppressed because one or more lines are too long