Ray Lothian 2018-08-17 10:46:10 +04:30
parent 3006da5319
commit fdfc5c63df
5 changed files with 17 additions and 5 deletions

View file

@ -21,9 +21,11 @@ chrome.storage.local.get(prefs, ps => {
ts.forEach(t => tabs[t.id] = t.windowId); ts.forEach(t => tabs[t.id] = t.windowId);
ua.update(); ua.update();
}); });
if (chrome.browserAction.setBadgeBackgroundColor) { // FF for Android
chrome.browserAction.setBadgeBackgroundColor({ chrome.browserAction.setBadgeBackgroundColor({
color: prefs.color color: prefs.color
}); });
}
}); });
chrome.storage.onChanged.addListener(ps => { chrome.storage.onChanged.addListener(ps => {
Object.keys(ps).forEach(key => prefs[key] = ps[key].newValue); Object.keys(ps).forEach(key => prefs[key] = ps[key].newValue);
@ -127,7 +129,9 @@ User-Agent String: ${prefs.mode === 'custom' ? custom : str || navigator.userAge
} }
}; };
// make sure to clean on window removal // make sure to clean on window removal
chrome.windows.onRemoved.addListener(windowId => delete ua._obj[windowId]); if (chrome.windows) { // FF on Android
chrome.windows.onRemoved.addListener(windowId => delete ua._obj[windowId]);
}
function hostname(url) { function hostname(url) {
const s = url.indexOf('//') + 2; const s = url.indexOf('//') + 2;

View file

@ -181,3 +181,8 @@ select {
#explore:not([data-loaded="true"]) { #explore:not([data-loaded="true"]) {
height: 16px; height: 16px;
} }
body[data-android="true"] [data-cmd="reload"],
body[data-android="true"] [data-cmd="window"] {
display: none;
}

View file

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="index.css"> <link rel="stylesheet" href="index.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head> </head>
<body> <body>
<div id="list" data-loading=true> <div id="list" data-loading=true>

View file

@ -1,6 +1,8 @@
/* globals UAParser */ /* globals UAParser */
'use strict'; 'use strict';
document.body.dataset.android = navigator.userAgent.indexOf('Android') !== -1;
var json = []; var json = [];
function filter(list) { function filter(list) {

View file

@ -2,7 +2,7 @@
"manifest_version": 2, "manifest_version": 2,
"name": "User-Agent Switcher and Manager", "name": "User-Agent Switcher and Manager",
"short_name": "useragent-switcher", "short_name": "useragent-switcher",
"version": "0.2.4", "version": "0.2.5",
"description": "Spoofs User-Agent strings of your browser with a new one globally, randomly or per hostname", "description": "Spoofs User-Agent strings of your browser with a new one globally, randomly or per hostname",