diff --git a/src/content/options.js b/src/content/options.js index fb2edd9..813191e 100644 --- a/src/content/options.js +++ b/src/content/options.js @@ -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; } diff --git a/src/content/proxy.js b/src/content/proxy.js index 4e73989..b8a3117 100644 --- a/src/content/proxy.js +++ b/src/content/proxy.js @@ -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 diff --git a/src/content/sync.js b/src/content/sync.js index b5341d0..f099ef9 100644 --- a/src/content/sync.js +++ b/src/content/sync.js @@ -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 = {};