Skip to content

Commit 344485e

Browse files
committed
ci: Use Set.prototype.has to check domain by @AdamWr
1 parent a5a47b0 commit 344485e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Fs.copyFileSync('./sources/src/index.ts', IndexFilePath)
8484
Fs.chmodSync(IndexFilePath, 0o700)
8585
const Project = new TsMorph.Project({ tsConfigFilePath: './tsconfig.json' })
8686
const IndexFile = Project.getSourceFileOrThrow(IndexFilePath)
87-
const TargetedDomainsArray = IndexFile.getVariableDeclaration('TargetedDomains').getInitializerIfKindOrThrow(TsMorph.SyntaxKind.ArrayLiteralExpression)
87+
const TargetedDomainsArray = IndexFile.getVariableDeclarationOrThrow('TargetedDomains').getInitializerIfKindOrThrow(TsMorph.SyntaxKind.NewExpression).getArguments()[0]?.asKindOrThrow(TsMorph.SyntaxKind.ArrayLiteralExpression)
8888
for (const Domain of DomainsList) {
8989
TargetedDomainsArray.addElement(`'${Domain}'`)
9090
}

sources/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ export function RunTinyShieldUserscript(BrowserWindow: typeof window, Userscript
117117
})
118118
}
119119

120-
const TargetedDomains: string[] = []
121-
if (TargetedDomains.some(Domain => new URLPattern(`*://${Domain}/*`).test(window.location.href) || new URLPattern(`*://*.${Domain}/*`).test(window.location.href))) {
120+
const TargetedDomains: Set<string> = new Set([])
121+
if (TargetedDomains.has(location.hostname.replaceAll(/^www\./g, ''))) {
122122
console.debug('[tinyShield]: Targeted domain matched, running userscript')
123123
RunTinyShieldUserscript(Win)
124124
}

0 commit comments

Comments
 (0)