mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Use Object.hasOwn instead of Object.prototype.hasOwnProperty
Reference: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn
This commit is contained in:
parent
0c8de6b550
commit
0fce659bb0
21 changed files with 52 additions and 84 deletions
|
|
@ -43,9 +43,6 @@ if ( vAPI.canWASM === false ) {
|
||||||
|
|
||||||
vAPI.supportsUserStylesheets = vAPI.webextFlavor.soup.has('user_stylesheet');
|
vAPI.supportsUserStylesheets = vAPI.webextFlavor.soup.has('user_stylesheet');
|
||||||
|
|
||||||
const hasOwnProperty = (o, p) =>
|
|
||||||
Object.prototype.hasOwnProperty.call(o, p);
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.app = {
|
vAPI.app = {
|
||||||
|
|
@ -190,7 +187,7 @@ vAPI.browserSettings = (( ) => {
|
||||||
|
|
||||||
set: function(details) {
|
set: function(details) {
|
||||||
for ( const setting in details ) {
|
for ( const setting in details ) {
|
||||||
if ( hasOwnProperty(details, setting) === false ) { continue; }
|
if ( Object.hasOwn(details, setting) === false ) { continue; }
|
||||||
switch ( setting ) {
|
switch ( setting ) {
|
||||||
case 'prefetching': {
|
case 'prefetching': {
|
||||||
const enabled = !!details[setting];
|
const enabled = !!details[setting];
|
||||||
|
|
@ -1220,7 +1217,7 @@ vAPI.Net = class {
|
||||||
{
|
{
|
||||||
const wrrt = browser.webRequest.ResourceType;
|
const wrrt = browser.webRequest.ResourceType;
|
||||||
for ( const typeKey in wrrt ) {
|
for ( const typeKey in wrrt ) {
|
||||||
if ( hasOwnProperty(wrrt, typeKey) ) {
|
if ( Object.hasOwn(wrrt, typeKey) ) {
|
||||||
this.validTypes.add(wrrt[typeKey]);
|
this.validTypes.add(wrrt[typeKey]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,6 @@ const obsoleteTemplateString = i18n$('3pExternalListObsolete');
|
||||||
const reValidExternalList = /^[a-z-]+:\/\/(?:\S+\/\S*|\/\S+)/m;
|
const reValidExternalList = /^[a-z-]+:\/\/(?:\S+\/\S*|\/\S+)/m;
|
||||||
const recentlyUpdated = 1 * 60 * 60 * 1000; // 1 hour
|
const recentlyUpdated = 1 * 60 * 60 * 1000; // 1 hour
|
||||||
|
|
||||||
// https://eslint.org/docs/latest/rules/no-prototype-builtins
|
|
||||||
const hasOwnProperty = (o, p) =>
|
|
||||||
Object.prototype.hasOwnProperty.call(o, p);
|
|
||||||
|
|
||||||
let listsetDetails = {};
|
let listsetDetails = {};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
@ -246,7 +242,7 @@ const renderFilterLists = ( ) => {
|
||||||
}
|
}
|
||||||
for ( const [ listkey, listDetails ] of Object.entries(response.available) ) {
|
for ( const [ listkey, listDetails ] of Object.entries(response.available) ) {
|
||||||
let groupkey = listDetails.group2 || listDetails.group;
|
let groupkey = listDetails.group2 || listDetails.group;
|
||||||
if ( hasOwnProperty(listTree, groupkey) === false ) {
|
if ( Object.hasOwn(listTree, groupkey) === false ) {
|
||||||
groupkey = 'unknown';
|
groupkey = 'unknown';
|
||||||
}
|
}
|
||||||
const groupDetails = listTree[groupkey];
|
const groupDetails = listTree[groupkey];
|
||||||
|
|
@ -603,7 +599,7 @@ const selectFilterLists = async ( ) => {
|
||||||
const toRemove = [];
|
const toRemove = [];
|
||||||
for ( const liEntry of qsa$('#lists .listEntry[data-role="leaf"]') ) {
|
for ( const liEntry of qsa$('#lists .listEntry[data-role="leaf"]') ) {
|
||||||
const listkey = liEntry.dataset.key;
|
const listkey = liEntry.dataset.key;
|
||||||
if ( hasOwnProperty(listsetDetails.available, listkey) === false ) {
|
if ( Object.hasOwn(listsetDetails.available, listkey) === false ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const listDetails = listsetDetails.available[listkey];
|
const listDetails = listsetDetails.available[listkey];
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ const hashFromAdvancedSettings = function(raw) {
|
||||||
const arrayFromObject = function(o) {
|
const arrayFromObject = function(o) {
|
||||||
const out = [];
|
const out = [];
|
||||||
for ( const k in o ) {
|
for ( const k in o ) {
|
||||||
if ( o.hasOwnProperty(k) === false ) { continue; }
|
if ( Object.hasOwn(o, k) === false ) { continue; }
|
||||||
out.push([ k, `${o[k]}` ]);
|
out.push([ k, `${o[k]}` ]);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,6 @@ let remoteServerFriendly = false;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
const hasOwnProperty = (o, p) =>
|
|
||||||
Object.prototype.hasOwnProperty.call(o, p);
|
|
||||||
|
|
||||||
const stringIsNotEmpty = s => typeof s === 'string' && s !== '';
|
const stringIsNotEmpty = s => typeof s === 'string' && s !== '';
|
||||||
|
|
||||||
const parseExpires = s => {
|
const parseExpires = s => {
|
||||||
|
|
@ -735,7 +732,7 @@ async function assetCacheRead(assetKey, updateReadTime = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bin instanceof Object === false ) { return reportBack(''); }
|
if ( bin instanceof Object === false ) { return reportBack(''); }
|
||||||
if ( hasOwnProperty(bin, internalKey) === false ) { return reportBack(''); }
|
if ( Object.hasOwn(bin, internalKey) === false ) { return reportBack(''); }
|
||||||
|
|
||||||
const entry = assetCacheRegistry[assetKey];
|
const entry = assetCacheRegistry[assetKey];
|
||||||
if ( entry === undefined ) { return reportBack(''); }
|
if ( entry === undefined ) { return reportBack(''); }
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,6 @@ const keysFromGetArg = arg => {
|
||||||
|
|
||||||
let fastCache = 'indexedDB';
|
let fastCache = 'indexedDB';
|
||||||
|
|
||||||
// https://eslint.org/docs/latest/rules/no-prototype-builtins
|
|
||||||
const hasOwnProperty = (o, p) =>
|
|
||||||
Object.prototype.hasOwnProperty.call(o, p);
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
*
|
*
|
||||||
* Extension storage
|
* Extension storage
|
||||||
|
|
@ -76,7 +72,7 @@ const cacheStorage = (( ) => {
|
||||||
if ( found.length === wanted.length ) { return; }
|
if ( found.length === wanted.length ) { return; }
|
||||||
const missing = [];
|
const missing = [];
|
||||||
for ( const key of wanted ) {
|
for ( const key of wanted ) {
|
||||||
if ( hasOwnProperty(outbin, key) ) { continue; }
|
if ( Object.hasOwn(outbin, key) ) { continue; }
|
||||||
missing.push(key);
|
missing.push(key);
|
||||||
}
|
}
|
||||||
return missing;
|
return missing;
|
||||||
|
|
@ -118,7 +114,7 @@ const cacheStorage = (( ) => {
|
||||||
if ( argbin instanceof Object === false ) { return; }
|
if ( argbin instanceof Object === false ) { return; }
|
||||||
if ( Array.isArray(argbin) ) { return; }
|
if ( Array.isArray(argbin) ) { return; }
|
||||||
for ( const key of wanted ) {
|
for ( const key of wanted ) {
|
||||||
if ( hasOwnProperty(argbin, key) === false ) { continue; }
|
if ( Object.hasOwn(argbin, key) === false ) { continue; }
|
||||||
outbin[key] = argbin[key];
|
outbin[key] = argbin[key];
|
||||||
}
|
}
|
||||||
}).then(( ) => {
|
}).then(( ) => {
|
||||||
|
|
@ -187,7 +183,7 @@ const cacheStorage = (( ) => {
|
||||||
},
|
},
|
||||||
|
|
||||||
select(api) {
|
select(api) {
|
||||||
if ( hasOwnProperty(cacheAPIs, api) === false ) { return fastCache; }
|
if ( Object.hasOwn(cacheAPIs, api) === false ) { return fastCache; }
|
||||||
fastCache = api;
|
fastCache = api;
|
||||||
for ( const k of Object.keys(cacheAPIs) ) {
|
for ( const k of Object.keys(cacheAPIs) ) {
|
||||||
if ( k === api ) { continue; }
|
if ( k === api ) { continue; }
|
||||||
|
|
@ -672,7 +668,7 @@ const idbStorage = (( ) => {
|
||||||
}
|
}
|
||||||
if ( argbin instanceof Object && Array.isArray(argbin) === false ) {
|
if ( argbin instanceof Object && Array.isArray(argbin) === false ) {
|
||||||
for ( const key of keys ) {
|
for ( const key of keys ) {
|
||||||
if ( hasOwnProperty(outbin, key) ) { continue; }
|
if ( Object.hasOwn(outbin, key) ) { continue; }
|
||||||
outbin[key] = argbin[key];
|
outbin[key] = argbin[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ let details = {};
|
||||||
|
|
||||||
let lists;
|
let lists;
|
||||||
for ( const rawFilter in response ) {
|
for ( const rawFilter in response ) {
|
||||||
if ( Object.prototype.hasOwnProperty.call(response, rawFilter) ) {
|
if ( Object.hasOwn(response, rawFilter) ) {
|
||||||
lists = response[rawFilter];
|
lists = response[rawFilter];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ function rulesToDoc(clearHistory) {
|
||||||
edit.startOperation();
|
edit.startOperation();
|
||||||
|
|
||||||
for ( const key in thePanes ) {
|
for ( const key in thePanes ) {
|
||||||
if ( thePanes.hasOwnProperty(key) === false ) { continue; }
|
if ( Object.hasOwn(thePanes, key) === false ) { continue; }
|
||||||
const doc = thePanes[key].doc;
|
const doc = thePanes[key].doc;
|
||||||
const rules = filterRules(key);
|
const rules = filterRules(key);
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import punycode from '../lib/punycode.js';
|
||||||
|
|
||||||
// Object.create(null) is used below to eliminate worries about unexpected
|
// Object.create(null) is used below to eliminate worries about unexpected
|
||||||
// property names in prototype chain -- and this way we don't have to use
|
// property names in prototype chain -- and this way we don't have to use
|
||||||
// hasOwnProperty() to avoid this.
|
// Object.hasOwn() to avoid this.
|
||||||
|
|
||||||
const supportedDynamicTypes = Object.create(null);
|
const supportedDynamicTypes = Object.create(null);
|
||||||
Object.assign(supportedDynamicTypes, {
|
Object.assign(supportedDynamicTypes, {
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ const decomposedSource = [];
|
||||||
|
|
||||||
// Object.create(null) is used below to eliminate worries about unexpected
|
// Object.create(null) is used below to eliminate worries about unexpected
|
||||||
// property names in prototype chain -- and this way we don't have to use
|
// property names in prototype chain -- and this way we don't have to use
|
||||||
// hasOwnProperty() to avoid this.
|
// Object.hasOwn() to avoid this.
|
||||||
|
|
||||||
const switchBitOffsets = Object.create(null);
|
const switchBitOffsets = Object.create(null);
|
||||||
Object.assign(switchBitOffsets, {
|
Object.assign(switchBitOffsets, {
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ if ( isBackgroundProcess !== true ) {
|
||||||
}
|
}
|
||||||
textout += textin.slice(0, match.index);
|
textout += textin.slice(0, match.index);
|
||||||
let prop = match[0].slice(2, -2);
|
let prop = match[0].slice(2, -2);
|
||||||
if ( Object.prototype.hasOwnProperty.call(dict, prop) ) {
|
if ( Object.hasOwn(dict, prop) ) {
|
||||||
textout += dict[prop].replace(/</g, '<')
|
textout += dict[prop].replace(/</g, '<')
|
||||||
.replace(/>/g, '>');
|
.replace(/>/g, '>');
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,6 @@ const tabIdFromAttribute = function(elem) {
|
||||||
return isNaN(tabId) ? 0 : tabId;
|
return isNaN(tabId) ? 0 : tabId;
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasOwnProperty = (o, p) =>
|
|
||||||
Object.prototype.hasOwnProperty.call(o, p);
|
|
||||||
|
|
||||||
const dispatchTabidChange = vAPI.defer.create(( ) => {
|
const dispatchTabidChange = vAPI.defer.create(( ) => {
|
||||||
document.dispatchEvent(new Event('tabIdChanged'));
|
document.dispatchEvent(new Event('tabIdChanged'));
|
||||||
});
|
});
|
||||||
|
|
@ -253,7 +250,7 @@ class LogEntry {
|
||||||
this.voided = false;
|
this.voided = false;
|
||||||
if ( details instanceof Object === false ) { return; }
|
if ( details instanceof Object === false ) { return; }
|
||||||
for ( const prop in this ) {
|
for ( const prop in this ) {
|
||||||
if ( hasOwnProperty(details, prop) === false ) { continue; }
|
if ( Object.hasOwn(details, prop) === false ) { continue; }
|
||||||
this[prop] = details[prop];
|
this[prop] = details[prop];
|
||||||
}
|
}
|
||||||
if ( details.aliasURL !== undefined ) {
|
if ( details.aliasURL !== undefined ) {
|
||||||
|
|
@ -1224,7 +1221,7 @@ dom.on(document, 'keydown', ev => {
|
||||||
const onColorsReady = function(response) {
|
const onColorsReady = function(response) {
|
||||||
dom.cl.toggle(dom.body, 'dirty', response.dirty);
|
dom.cl.toggle(dom.body, 'dirty', response.dirty);
|
||||||
for ( const url in response.colors ) {
|
for ( const url in response.colors ) {
|
||||||
if ( hasOwnProperty(response.colors, url) === false ) { continue; }
|
if ( Object.hasOwn(response.colors, url) === false ) { continue; }
|
||||||
const colorEntry = response.colors[url];
|
const colorEntry = response.colors[url];
|
||||||
const node = qs$(dialog, `.dynamic .entry .action[data-url="${url}"]`);
|
const node = qs$(dialog, `.dynamic .entry .action[data-url="${url}"]`);
|
||||||
if ( node === null ) { continue; }
|
if ( node === null ) { continue; }
|
||||||
|
|
@ -1291,7 +1288,7 @@ dom.on(document, 'keydown', ev => {
|
||||||
dom.cl.toggle(
|
dom.cl.toggle(
|
||||||
qs$(dialog, '#createStaticFilter'),
|
qs$(dialog, '#createStaticFilter'),
|
||||||
'disabled',
|
'disabled',
|
||||||
hasOwnProperty(createdStaticFilters, value) || value === ''
|
Object.hasOwn(createdStaticFilters, value) || value === ''
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1332,7 +1329,7 @@ dom.on(document, 'keydown', ev => {
|
||||||
const value = staticFilterNode().value
|
const value = staticFilterNode().value
|
||||||
.replace(/^((?:@@)?\/.+\/)(\$|$)/, '$1*$2');
|
.replace(/^((?:@@)?\/.+\/)(\$|$)/, '$1*$2');
|
||||||
// Avoid duplicates
|
// Avoid duplicates
|
||||||
if ( hasOwnProperty(createdStaticFilters, value) ) { return; }
|
if ( Object.hasOwn(createdStaticFilters, value) ) { return; }
|
||||||
createdStaticFilters[value] = true;
|
createdStaticFilters[value] = true;
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/1281#issuecomment-704217175
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/1281#issuecomment-704217175
|
||||||
// TODO:
|
// TODO:
|
||||||
|
|
@ -2835,7 +2832,7 @@ const loggerStats = (( ) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const setRadioButton = function(group, value) {
|
const setRadioButton = function(group, value) {
|
||||||
if ( hasOwnProperty(options, group) === false ) { return; }
|
if ( Object.hasOwn(options, group) === false ) { return; }
|
||||||
const groupEl = qs$(dialog, `[data-radio="${group}"]`);
|
const groupEl = qs$(dialog, `[data-radio="${group}"]`);
|
||||||
const buttonEls = qsa$(groupEl, '[data-radio-item]');
|
const buttonEls = qsa$(groupEl, '[data-radio-item]');
|
||||||
for ( const buttonEl of buttonEls ) {
|
for ( const buttonEl of buttonEls ) {
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,6 @@ import µb from './background.js';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
const hasOwnProperty = (o, p) =>
|
|
||||||
Object.prototype.hasOwnProperty.call(o, p);
|
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/710
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/710
|
||||||
// Listeners have a name and a "privileged" status.
|
// Listeners have a name and a "privileged" status.
|
||||||
// The nameless default handler is always deemed "privileged".
|
// The nameless default handler is always deemed "privileged".
|
||||||
|
|
@ -1095,7 +1092,7 @@ const restoreUserData = async function(request) {
|
||||||
// Discard unknown setting or setting with default value.
|
// Discard unknown setting or setting with default value.
|
||||||
for ( const key in hiddenSettings ) {
|
for ( const key in hiddenSettings ) {
|
||||||
if (
|
if (
|
||||||
hasOwnProperty(µb.hiddenSettingsDefault, key) === false ||
|
Object.hasOwn(µb.hiddenSettingsDefault, key) === false ||
|
||||||
hiddenSettings[key] === µb.hiddenSettingsDefault[key]
|
hiddenSettings[key] === µb.hiddenSettingsDefault[key]
|
||||||
) {
|
) {
|
||||||
delete hiddenSettings[key];
|
delete hiddenSettings[key];
|
||||||
|
|
@ -1147,7 +1144,7 @@ const resetUserData = async function() {
|
||||||
// Filter lists
|
// Filter lists
|
||||||
const prepListEntries = function(entries) {
|
const prepListEntries = function(entries) {
|
||||||
for ( const k in entries ) {
|
for ( const k in entries ) {
|
||||||
if ( hasOwnProperty(entries, k) === false ) { continue; }
|
if ( Object.hasOwn(entries, k) === false ) { continue; }
|
||||||
const entry = entries[k];
|
const entry = entries[k];
|
||||||
if ( typeof entry.supportURL === 'string' && entry.supportURL !== '' ) {
|
if ( typeof entry.supportURL === 'string' && entry.supportURL !== '' ) {
|
||||||
entry.supportName = hostnameFromURI(entry.supportURL);
|
entry.supportName = hostnameFromURI(entry.supportURL);
|
||||||
|
|
@ -1335,7 +1332,7 @@ const getSupportData = async function() {
|
||||||
let addedListset = {};
|
let addedListset = {};
|
||||||
let removedListset = {};
|
let removedListset = {};
|
||||||
for ( const listKey in lists ) {
|
for ( const listKey in lists ) {
|
||||||
if ( hasOwnProperty(lists, listKey) === false ) { continue; }
|
if ( Object.hasOwn(lists, listKey) === false ) { continue; }
|
||||||
const list = lists[listKey];
|
const list = lists[listKey];
|
||||||
if ( list.content !== 'filters' ) { continue; }
|
if ( list.content !== 'filters' ) { continue; }
|
||||||
const used = µb.selectedFilterLists.includes(listKey);
|
const used = µb.selectedFilterLists.includes(listKey);
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,6 @@ let cachedPopupHash = '';
|
||||||
const reCyrillicNonAmbiguous = /[\u0400-\u042b\u042d-\u042f\u0431\u0432\u0434\u0436-\u043d\u0442\u0444\u0446-\u0449\u044b-\u0454\u0457\u0459-\u0460\u0462-\u0474\u0476-\u04ba\u04bc\u04be-\u04ce\u04d0-\u0500\u0502-\u051a\u051c\u051e-\u052f]/;
|
const reCyrillicNonAmbiguous = /[\u0400-\u042b\u042d-\u042f\u0431\u0432\u0434\u0436-\u043d\u0442\u0444\u0446-\u0449\u044b-\u0454\u0457\u0459-\u0460\u0462-\u0474\u0476-\u04ba\u04bc\u04be-\u04ce\u04d0-\u0500\u0502-\u051a\u051c\u051e-\u052f]/;
|
||||||
const reCyrillicAmbiguous = /[\u042c\u0430\u0433\u0435\u043e\u043f\u0440\u0441\u0443\u0445\u044a\u0455\u0456\u0458\u0461\u0475\u04bb\u04bd\u04cf\u0501\u051b\u051d]/;
|
const reCyrillicAmbiguous = /[\u042c\u0430\u0433\u0435\u043e\u043f\u0440\u0441\u0443\u0445\u044a\u0455\u0456\u0458\u0461\u0475\u04bb\u04bd\u04cf\u0501\u051b\u051d]/;
|
||||||
|
|
||||||
const hasOwnProperty = (o, p) =>
|
|
||||||
Object.prototype.hasOwnProperty.call(o, p);
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
const cachePopupData = function(data) {
|
const cachePopupData = function(data) {
|
||||||
|
|
@ -89,7 +86,7 @@ const cachePopupData = function(data) {
|
||||||
return popupData;
|
return popupData;
|
||||||
}
|
}
|
||||||
for ( const hostname in hostnameDict ) {
|
for ( const hostname in hostnameDict ) {
|
||||||
if ( hasOwnProperty(hostnameDict, hostname) === false ) { continue; }
|
if ( Object.hasOwn(hostnameDict, hostname) === false ) { continue; }
|
||||||
let domain = hostnameDict[hostname].domain;
|
let domain = hostnameDict[hostname].domain;
|
||||||
let prefix = hostname.slice(0, 0 - domain.length - 1);
|
let prefix = hostname.slice(0, 0 - domain.length - 1);
|
||||||
// Prefix with space char for 1st-party hostnames: this ensure these
|
// Prefix with space char for 1st-party hostnames: this ensure these
|
||||||
|
|
@ -161,7 +158,7 @@ const formatNumber = function(count) {
|
||||||
});
|
});
|
||||||
if (
|
if (
|
||||||
intl.resolvedOptions instanceof Function &&
|
intl.resolvedOptions instanceof Function &&
|
||||||
hasOwnProperty(intl.resolvedOptions(), 'notation')
|
Object.hasOwn(intl.resolvedOptions(), 'notation')
|
||||||
) {
|
) {
|
||||||
intlNumberFormat = intl;
|
intlNumberFormat = intl;
|
||||||
}
|
}
|
||||||
|
|
@ -546,7 +543,7 @@ const renderPrivacyExposure = function() {
|
||||||
if ( des === '*' || desHostnameDone.has(des) ) { continue; }
|
if ( des === '*' || desHostnameDone.has(des) ) { continue; }
|
||||||
const hnDetails = hostnameDict[des];
|
const hnDetails = hostnameDict[des];
|
||||||
const { domain, counts } = hnDetails;
|
const { domain, counts } = hnDetails;
|
||||||
if ( hasOwnProperty(allDomains, domain) === false ) {
|
if ( Object.hasOwn(allDomains, domain) === false ) {
|
||||||
allDomains[domain] = false;
|
allDomains[domain] = false;
|
||||||
allDomainCount += 1;
|
allDomainCount += 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ export function runAt(fn, when) {
|
||||||
const tokens = Array.isArray(state) ? state : [ state ];
|
const tokens = Array.isArray(state) ? state : [ state ];
|
||||||
for ( const token of tokens ) {
|
for ( const token of tokens ) {
|
||||||
const prop = `${token}`;
|
const prop = `${token}`;
|
||||||
if ( targets.hasOwnProperty(prop) === false ) { continue; }
|
if ( Object.hasOwn(targets, prop) === false ) { continue; }
|
||||||
return targets[prop];
|
return targets[prop];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ const initWorker = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
for ( const listKey in µb.availableFilterLists ) {
|
for ( const listKey in µb.availableFilterLists ) {
|
||||||
if ( Object.prototype.hasOwnProperty.call(µb.availableFilterLists, listKey) === false ) {
|
if ( Object.hasOwn(µb.availableFilterLists, listKey) === false ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const entry = µb.availableFilterLists[listKey];
|
const entry = µb.availableFilterLists[listKey];
|
||||||
|
|
|
||||||
|
|
@ -306,9 +306,6 @@ const shouldCompress = (s, options) =>
|
||||||
options.compressThreshold <= s.length
|
options.compressThreshold <= s.length
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasOwnProperty = (o, p) =>
|
|
||||||
Object.prototype.hasOwnProperty.call(o, p);
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
*
|
*
|
||||||
* A large Uint is always a positive integer (can be zero), assumed to be
|
* A large Uint is always a positive integer (can be zero), assumed to be
|
||||||
|
|
@ -1155,7 +1152,7 @@ export const getConfig = ( ) => Object.assign({}, currentConfig);
|
||||||
|
|
||||||
export const setConfig = config => {
|
export const setConfig = config => {
|
||||||
for ( const key in Object.keys(config) ) {
|
for ( const key in Object.keys(config) ) {
|
||||||
if ( hasOwnProperty(defaultConfig, key) === false ) { continue; }
|
if ( Object.hasOwn(defaultConfig, key) === false ) { continue; }
|
||||||
const val = config[key];
|
const val = config[key];
|
||||||
if ( typeof val !== typeof defaultConfig[key] ) { continue; }
|
if ( typeof val !== typeof defaultConfig[key] ) { continue; }
|
||||||
if ( (validateConfig[key])(val) === false ) { continue; }
|
if ( (validateConfig[key])(val) === false ) { continue; }
|
||||||
|
|
|
||||||
|
|
@ -357,15 +357,15 @@ const onFirstFetchReady = (fetched, adminExtra) => {
|
||||||
|
|
||||||
const toFetch = (from, fetched) => {
|
const toFetch = (from, fetched) => {
|
||||||
for ( const k in from ) {
|
for ( const k in from ) {
|
||||||
if ( from.hasOwnProperty(k) === false ) { continue; }
|
if ( Object.hasOwn(from, k) === false ) { continue; }
|
||||||
fetched[k] = from[k];
|
fetched[k] = from[k];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fromFetch = (to, fetched) => {
|
const fromFetch = (to, fetched) => {
|
||||||
for ( const k in to ) {
|
for ( const k in to ) {
|
||||||
if ( to.hasOwnProperty(k) === false ) { continue; }
|
if ( Object.hasOwn(to, k) === false ) { continue; }
|
||||||
if ( fetched.hasOwnProperty(k) === false ) { continue; }
|
if ( Object.hasOwn(fetched, k) === false ) { continue; }
|
||||||
to[k] = fetched[k];
|
to[k] = fetched[k];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,6 @@ import µb from './background.js';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// https://eslint.org/docs/latest/rules/no-prototype-builtins
|
|
||||||
const hasOwnProperty = (o, p) =>
|
|
||||||
Object.prototype.hasOwnProperty.call(o, p);
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
µb.getBytesInUse = async function() {
|
µb.getBytesInUse = async function() {
|
||||||
const promises = [];
|
const promises = [];
|
||||||
let bytesInUse;
|
let bytesInUse;
|
||||||
|
|
@ -186,7 +180,7 @@ const hasOwnProperty = (o, p) =>
|
||||||
for ( const entry of adminSettings ) {
|
for ( const entry of adminSettings ) {
|
||||||
if ( entry.length < 1 ) { continue; }
|
if ( entry.length < 1 ) { continue; }
|
||||||
const name = entry[0];
|
const name = entry[0];
|
||||||
if ( hasOwnProperty(usDefault, name) === false ) { continue; }
|
if ( Object.hasOwn(usDefault, name) === false ) { continue; }
|
||||||
const value = entry.length < 2
|
const value = entry.length < 2
|
||||||
? usDefault[name]
|
? usDefault[name]
|
||||||
: this.settingValueFromString(usDefault, name, entry[1]);
|
: this.settingValueFromString(usDefault, name, entry[1]);
|
||||||
|
|
@ -215,8 +209,8 @@ const hasOwnProperty = (o, p) =>
|
||||||
|
|
||||||
const toRemove = [];
|
const toRemove = [];
|
||||||
for ( const key in this.userSettings ) {
|
for ( const key in this.userSettings ) {
|
||||||
if ( hasOwnProperty(this.userSettings, key) === false ) { continue; }
|
if ( Object.hasOwn(this.userSettings, key) === false ) { continue; }
|
||||||
if ( hasOwnProperty(toSave, key) ) { continue; }
|
if ( Object.hasOwn(toSave, key) ) { continue; }
|
||||||
toRemove.push(key);
|
toRemove.push(key);
|
||||||
}
|
}
|
||||||
if ( toRemove.length !== 0 ) {
|
if ( toRemove.length !== 0 ) {
|
||||||
|
|
@ -253,7 +247,7 @@ const hasOwnProperty = (o, p) =>
|
||||||
for ( const entry of advancedSettings ) {
|
for ( const entry of advancedSettings ) {
|
||||||
if ( entry.length < 1 ) { continue; }
|
if ( entry.length < 1 ) { continue; }
|
||||||
const name = entry[0];
|
const name = entry[0];
|
||||||
if ( hasOwnProperty(hsDefault, name) === false ) { continue; }
|
if ( Object.hasOwn(hsDefault, name) === false ) { continue; }
|
||||||
const value = entry.length < 2
|
const value = entry.length < 2
|
||||||
? hsDefault[name]
|
? hsDefault[name]
|
||||||
: this.hiddenSettingValueFromString(name, entry[1]);
|
: this.hiddenSettingValueFromString(name, entry[1]);
|
||||||
|
|
@ -287,8 +281,8 @@ const hasOwnProperty = (o, p) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( const key in hsDefault ) {
|
for ( const key in hsDefault ) {
|
||||||
if ( hasOwnProperty(hsDefault, key) === false ) { continue; }
|
if ( Object.hasOwn(hsDefault, key) === false ) { continue; }
|
||||||
if ( hasOwnProperty(hsAdmin, name) ) { continue; }
|
if ( Object.hasOwn(hsAdmin, name) ) { continue; }
|
||||||
if ( typeof hs[key] !== typeof hsDefault[key] ) { continue; }
|
if ( typeof hs[key] !== typeof hsDefault[key] ) { continue; }
|
||||||
this.hiddenSettings[key] = hs[key];
|
this.hiddenSettings[key] = hs[key];
|
||||||
}
|
}
|
||||||
|
|
@ -334,8 +328,8 @@ onBroadcast(msg => {
|
||||||
const matches = /^\s*(\S+)\s+(.+)$/.exec(line);
|
const matches = /^\s*(\S+)\s+(.+)$/.exec(line);
|
||||||
if ( matches === null || matches.length !== 3 ) { continue; }
|
if ( matches === null || matches.length !== 3 ) { continue; }
|
||||||
const name = matches[1];
|
const name = matches[1];
|
||||||
if ( hasOwnProperty(out, name) === false ) { continue; }
|
if ( Object.hasOwn(out, name) === false ) { continue; }
|
||||||
if ( hasOwnProperty(this.hiddenSettingsAdmin, name) ) { continue; }
|
if ( Object.hasOwn(this.hiddenSettingsAdmin, name) ) { continue; }
|
||||||
const value = this.hiddenSettingValueFromString(name, matches[2]);
|
const value = this.hiddenSettingValueFromString(name, matches[2]);
|
||||||
if ( value !== undefined ) {
|
if ( value !== undefined ) {
|
||||||
out[name] = value;
|
out[name] = value;
|
||||||
|
|
@ -347,7 +341,7 @@ onBroadcast(msg => {
|
||||||
µb.hiddenSettingValueFromString = function(name, value) {
|
µb.hiddenSettingValueFromString = function(name, value) {
|
||||||
if ( typeof name !== 'string' || typeof value !== 'string' ) { return; }
|
if ( typeof name !== 'string' || typeof value !== 'string' ) { return; }
|
||||||
const hsDefault = this.hiddenSettingsDefault;
|
const hsDefault = this.hiddenSettingsDefault;
|
||||||
if ( hasOwnProperty(hsDefault, name) === false ) { return; }
|
if ( Object.hasOwn(hsDefault, name) === false ) { return; }
|
||||||
let r;
|
let r;
|
||||||
switch ( typeof hsDefault[name] ) {
|
switch ( typeof hsDefault[name] ) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
|
|
@ -688,7 +682,7 @@ onBroadcast(msg => {
|
||||||
µb.autoSelectRegionalFilterLists = function(lists) {
|
µb.autoSelectRegionalFilterLists = function(lists) {
|
||||||
const selectedListKeys = [ this.userFiltersPath ];
|
const selectedListKeys = [ this.userFiltersPath ];
|
||||||
for ( const key in lists ) {
|
for ( const key in lists ) {
|
||||||
if ( hasOwnProperty(lists, key) === false ) { continue; }
|
if ( Object.hasOwn(lists, key) === false ) { continue; }
|
||||||
const list = lists[key];
|
const list = lists[key];
|
||||||
if ( list.content !== 'filters' ) { continue; }
|
if ( list.content !== 'filters' ) { continue; }
|
||||||
if ( list.off !== true ) {
|
if ( list.off !== true ) {
|
||||||
|
|
@ -941,7 +935,7 @@ onBroadcast(msg => {
|
||||||
let acceptedCount = snfe.acceptedCount + sxfe.acceptedCount;
|
let acceptedCount = snfe.acceptedCount + sxfe.acceptedCount;
|
||||||
let discardedCount = snfe.discardedCount + sxfe.discardedCount;
|
let discardedCount = snfe.discardedCount + sxfe.discardedCount;
|
||||||
µb.applyCompiledFilters(compiled, assetKey === µb.userFiltersPath);
|
µb.applyCompiledFilters(compiled, assetKey === µb.userFiltersPath);
|
||||||
if ( hasOwnProperty(µb.availableFilterLists, assetKey) ) {
|
if ( Object.hasOwn(µb.availableFilterLists, assetKey) ) {
|
||||||
const entry = µb.availableFilterLists[assetKey];
|
const entry = µb.availableFilterLists[assetKey];
|
||||||
entry.entryCount = snfe.acceptedCount + sxfe.acceptedCount -
|
entry.entryCount = snfe.acceptedCount + sxfe.acceptedCount -
|
||||||
acceptedCount;
|
acceptedCount;
|
||||||
|
|
@ -977,7 +971,7 @@ onBroadcast(msg => {
|
||||||
// content.
|
// content.
|
||||||
const toLoad = [];
|
const toLoad = [];
|
||||||
for ( const assetKey in lists ) {
|
for ( const assetKey in lists ) {
|
||||||
if ( hasOwnProperty(lists, assetKey) === false ) { continue; }
|
if ( Object.hasOwn(lists, assetKey) === false ) { continue; }
|
||||||
if ( lists[assetKey].off ) { continue; }
|
if ( lists[assetKey].off ) { continue; }
|
||||||
toLoad.push(
|
toLoad.push(
|
||||||
µb.getCompiledFilterList(assetKey).then(details => {
|
µb.getCompiledFilterList(assetKey).then(details => {
|
||||||
|
|
@ -1428,8 +1422,8 @@ onBroadcast(msg => {
|
||||||
const µbus = this.userSettings;
|
const µbus = this.userSettings;
|
||||||
const adminus = data.userSettings;
|
const adminus = data.userSettings;
|
||||||
for ( const name in µbus ) {
|
for ( const name in µbus ) {
|
||||||
if ( hasOwnProperty(µbus, name) === false ) { continue; }
|
if ( Object.hasOwn(µbus, name) === false ) { continue; }
|
||||||
if ( hasOwnProperty(adminus, name) === false ) { continue; }
|
if ( Object.hasOwn(adminus, name) === false ) { continue; }
|
||||||
bin[name] = adminus[name];
|
bin[name] = adminus[name];
|
||||||
binNotEmpty = true;
|
binNotEmpty = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1600,7 +1594,7 @@ onBroadcast(msg => {
|
||||||
if ( topic === 'before-asset-updated' ) {
|
if ( topic === 'before-asset-updated' ) {
|
||||||
if ( details.type === 'filters' ) {
|
if ( details.type === 'filters' ) {
|
||||||
if (
|
if (
|
||||||
hasOwnProperty(this.availableFilterLists, details.assetKey) === false ||
|
Object.hasOwn(this.availableFilterLists, details.assetKey) === false ||
|
||||||
this.selectedFilterLists.indexOf(details.assetKey) === -1 ||
|
this.selectedFilterLists.indexOf(details.assetKey) === -1 ||
|
||||||
this.badLists.get(details.assetKey)
|
this.badLists.get(details.assetKey)
|
||||||
) {
|
) {
|
||||||
|
|
@ -1615,7 +1609,7 @@ onBroadcast(msg => {
|
||||||
// Skip selfie-related content.
|
// Skip selfie-related content.
|
||||||
if ( details.assetKey.startsWith('selfie/') ) { return; }
|
if ( details.assetKey.startsWith('selfie/') ) { return; }
|
||||||
const cached = typeof details.content === 'string' && details.content !== '';
|
const cached = typeof details.content === 'string' && details.content !== '';
|
||||||
if ( hasOwnProperty(this.availableFilterLists, details.assetKey) ) {
|
if ( Object.hasOwn(this.availableFilterLists, details.assetKey) ) {
|
||||||
if ( cached ) {
|
if ( cached ) {
|
||||||
if ( this.selectedFilterLists.indexOf(details.assetKey) !== -1 ) {
|
if ( this.selectedFilterLists.indexOf(details.assetKey) !== -1 ) {
|
||||||
this.extractFilterListMetadata(
|
this.extractFilterListMetadata(
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ const textEncode = (( ) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
encode: function(charset, buf) {
|
encode: function(charset, buf) {
|
||||||
return encoders.hasOwnProperty(charset) ?
|
return Object.hasOwn(encoders, charset) ?
|
||||||
encoders[charset](buf) :
|
encoders[charset](buf) :
|
||||||
buf;
|
buf;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,7 @@ const matchBucket = function(url, hostname, bucket, start) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change -- but only if the user setting actually exists.
|
// Change -- but only if the user setting actually exists.
|
||||||
const mustSave = us.hasOwnProperty(name) && value !== us[name];
|
const mustSave = Object.hasOwn(us, name) && value !== us[name];
|
||||||
if ( mustSave ) {
|
if ( mustSave ) {
|
||||||
us[name] = value;
|
us[name] = value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ import µb from './background.js';
|
||||||
µb.getModifiedSettings = function(edit, orig = {}) {
|
µb.getModifiedSettings = function(edit, orig = {}) {
|
||||||
const out = {};
|
const out = {};
|
||||||
for ( const prop in edit ) {
|
for ( const prop in edit ) {
|
||||||
if ( orig.hasOwnProperty(prop) && edit[prop] !== orig[prop] ) {
|
if ( Object.hasOwn(orig, prop) && edit[prop] !== orig[prop] ) {
|
||||||
out[prop] = edit[prop];
|
out[prop] = edit[prop];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +102,7 @@ import µb from './background.js';
|
||||||
|
|
||||||
µb.settingValueFromString = function(orig, name, s) {
|
µb.settingValueFromString = function(orig, name, s) {
|
||||||
if ( typeof name !== 'string' || typeof s !== 'string' ) { return; }
|
if ( typeof name !== 'string' || typeof s !== 'string' ) { return; }
|
||||||
if ( orig.hasOwnProperty(name) === false ) { return; }
|
if ( Object.hasOwn(orig, name) === false ) { return; }
|
||||||
let r;
|
let r;
|
||||||
switch ( typeof orig[name] ) {
|
switch ( typeof orig[name] ) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue