Add files via upload

This commit is contained in:
erosman 2023-11-10 14:52:08 +03:30 committed by GitHub
parent 8307d4a35a
commit dc48250aa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 9 deletions

View File

@ -192,7 +192,6 @@ class Options {
obj[i.dataset.id] = i.type === 'checkbox' ? i.checked : i.value.trim();
});
// --- check type: http | https | socks4 | socks5 | pac | direct
switch (true) {
// DIRECT
@ -386,7 +385,7 @@ class WebRTC {
// { "levelOfControl": "controllable_by_this_extension", "value": "default" }
this.result ||= await browser.privacy.network.webRTCIPHandlingPolicy.get({});
const def = this.result.value === 'default';
let value = def ? 'default_public_interface_only' : 'default';
const value = def ? 'default_public_interface_only' : 'default';
this.result.value = value;
this.webRTC.checked = def; // was default but now changed
browser.privacy.network.webRTCIPHandlingPolicy.set({value});
@ -522,7 +521,6 @@ class Proxies {
pxy.querySelector('button[data-i18n^="export"]').addEventListener('click', () =>
this.exportPattern(patternBox, elem[1].value.trim() || elem[3].value.trim()));
// from add button
if (!item) {
this.proxyDiv.appendChild(pxy); // insert blank proxy
@ -935,7 +933,7 @@ class ImportProxyList {
const pram = {type, hostname, port, username, password};
// prepare object, make parameter keys case-insensitive
for (let [key, value] of url.searchParams) {
for (const [key, value] of url.searchParams) {
pram[key.toLowerCase()] = value;
}

View File

@ -218,7 +218,7 @@ export class Proxy {
// isInNet(host, "192.0.2.172", "255.255.255.255")
const pacString =
`function FindProxyForURL(url, host) {
String.raw`function FindProxyForURL(url, host) {
const data = ${JSON.stringify(data)};
const passthrough = ${JSON.stringify(passthrough)};
const net = ${JSON.stringify(net)};
@ -257,7 +257,7 @@ export class Proxy {
const url = this.getURL(activeTab[0].url);
if (!url) { return; }
const pattern = '^' + url.origin.replaceAll('.', '\.') + '/';
const pattern = '^' + url.origin.replaceAll('.', '\\.') + '/';
const pat = {
active: true,
pattern,
@ -287,7 +287,7 @@ export class Proxy {
if (arr.includes(pattern)) { return; } // already added
arr.push(pattern);
pref.passthrough = [...new Set(arr)].join(separator); // remove duplicates
pref.passthrough = [...new Set(arr)].join(separator).trim(); // remove duplicates
browser.storage.local.set({passthrough: pref.passthrough});
this.set(pref); // update Proxy

View File

@ -11,14 +11,14 @@ export class Sync {
static async onChanged(changes) {
// no newValue on storage.local.clear()
if (!Object.values(changes)[0]?.hasOwnProperty('newValue')) { return; }
if (!Object.hasOwn(Object.values(changes)[0] || {}, 'newValue')) { return; }
const pref = await browser.storage.local.get();
if (!pref.sync) { return; }
// convert object to array + filter null newValue (deleted) + map to newValue
const data = Object.values(changes)
.filter(i => i.newValue?.hasOwnProperty('hostname') || i.newValue?.hasOwnProperty('pac'))
.filter(i => Object.hasOwn(i.newValue || {}, 'hostname'))
.map(i => i.newValue);
const obj = {};