feat: run prettier

This commit is contained in:
JellyBrick
2023-11-30 11:59:27 +09:00
parent 44c42310f1
commit a3104fda4b
116 changed files with 2928 additions and 1254 deletions

View File

@ -30,19 +30,19 @@ export const loadAdBlockerEngine = async (
if (!fs.existsSync(cacheDirectory)) {
fs.mkdirSync(cacheDirectory);
}
const cachingOptions
= cache && additionalBlockLists.length === 0
? {
path: path.join(cacheDirectory, 'adblocker-engine.bin'),
read: promises.readFile,
write: promises.writeFile,
}
: undefined;
const cachingOptions =
cache && additionalBlockLists.length === 0
? {
path: path.join(cacheDirectory, 'adblocker-engine.bin'),
read: promises.readFile,
write: promises.writeFile,
}
: undefined;
const lists = [
...(
(disableDefaultLists && !Array.isArray(disableDefaultLists)) ||
(Array.isArray(disableDefaultLists) && disableDefaultLists.length > 0) ? [] : SOURCES
),
...((disableDefaultLists && !Array.isArray(disableDefaultLists)) ||
(Array.isArray(disableDefaultLists) && disableDefaultLists.length > 0)
? []
: SOURCES),
...additionalBlockLists,
];
@ -72,4 +72,5 @@ export const unloadAdBlockerEngine = (session: Electron.Session) => {
}
};
export const isBlockerEnabled = (session: Electron.Session) => blocker !== undefined && blocker.isBlockingEnabled(session);
export const isBlockerEnabled = (session: Electron.Session) =>
blocker !== undefined && blocker.isBlockingEnabled(session);

View File

@ -1,6 +1,10 @@
import { blockers } from './types';
import { createPlugin } from '@/utils';
import { isBlockerEnabled, loadAdBlockerEngine, unloadAdBlockerEngine } from './blocker';
import {
isBlockerEnabled,
loadAdBlockerEngine,
unloadAdBlockerEngine,
} from './blocker';
import injectCliqzPreload from './injectors/inject-cliqz-preload';
import { inject, isInjected } from './injectors/inject';
@ -22,7 +26,7 @@ interface AdblockerConfig {
* Which adblocker to use.
* @default blockers.InPlayer
*/
blocker: typeof blockers[keyof typeof blockers];
blocker: (typeof blockers)[keyof typeof blockers];
/**
* Additional list of filters to use.
* @example ["https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt"]
@ -86,7 +90,10 @@ export default createPlugin({
},
async onConfigChange(newConfig) {
if (this.mainWindow) {
if (newConfig.blocker === blockers.WithBlocklists && !isBlockerEnabled(this.mainWindow.webContents.session)) {
if (
newConfig.blocker === blockers.WithBlocklists &&
!isBlockerEnabled(this.mainWindow.webContents.session)
) {
await loadAdBlockerEngine(
this.mainWindow.webContents.session,
newConfig.cache,
@ -117,5 +124,5 @@ export default createPlugin({
}
}
},
}
},
});

View File

@ -73,8 +73,7 @@ export const inject = () => {
}
case 'noopFunc': {
cValue = function () {
};
cValue = function () {};
break;
}
@ -103,7 +102,7 @@ export const inject = () => {
return;
}
if (Math.abs(cValue) > 0x7F_FF) {
if (Math.abs(cValue) > 0x7f_ff) {
return;
}
} else {
@ -119,12 +118,12 @@ export const inject = () => {
return true;
}
aborted
= v !== undefined
&& v !== null
&& cValue !== undefined
&& cValue !== null
&& typeof v !== typeof cValue;
aborted =
v !== undefined &&
v !== null &&
cValue !== undefined &&
cValue !== null &&
typeof v !== typeof cValue;
return aborted;
};
@ -272,8 +271,7 @@ export const inject = () => {
}
case 'noopFunc': {
cValue = function () {
};
cValue = function () {};
break;
}
@ -302,7 +300,7 @@ export const inject = () => {
return;
}
if (Math.abs(cValue) > 0x7F_FF) {
if (Math.abs(cValue) > 0x7f_ff) {
return;
}
} else {
@ -318,12 +316,12 @@ export const inject = () => {
return true;
}
aborted
= v !== undefined
&& v !== null
&& cValue !== undefined
&& cValue !== null
&& typeof v !== typeof cValue;
aborted =
v !== undefined &&
v !== null &&
cValue !== undefined &&
cValue !== null &&
typeof v !== typeof cValue;
return aborted;
};