Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
fix: Ad-Shield anti-adblock popup at meeco.kr
Browse files Browse the repository at this point in the history
  • Loading branch information
piquark6046 committed Apr 6, 2024
1 parent aa7f5a0 commit f87dfae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions sources/src/adshield/resources.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {UnprotectedFetch} from '../utils/secret.js'
import {GetRandomAdShieldHost} from './validators.js'

export const GetCachableHtml = async (Url: string) => {
const ResponseRaw = await fetch(Url, {
const ResponseRaw = await UnprotectedFetch(Url, {
cache: 'force-cache'
})
const Text = await ResponseRaw.text()
Expand All @@ -14,7 +15,7 @@ export const GetCachableHtml = async (Url: string) => {
}

export const GetResourceToken = async (ScriptUrl: string) => {
const ResponseRaw = await fetch(ScriptUrl, {
const ResponseRaw = await UnprotectedFetch(ScriptUrl, {
cache: 'force-cache'
})
const Text = await ResponseRaw.text()
Expand Down
11 changes: 8 additions & 3 deletions sources/src/adshield/validators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cryptoRandomString from 'crypto-random-string'
import {JustifyCallStack} from '../utils/call-stack.js'
import {HasSubstringSetsInString} from '../utils/string.js'

export const AdshieldDomains = [
Expand Down Expand Up @@ -26,12 +27,16 @@ const AdshieldDomainsize = AdshieldDomains.length
// eslint-disable-next-line no-bitwise
export const GetRandomAdShieldHost = () => AdshieldDomains[(Number(cryptoRandomString({length: 16, type: 'numeric'})) * 0.0000000000000001 * AdshieldDomainsize) >>> 0]

export const IsAdShieldCall = (LastLine: string) => {
if (HasSubstringSetsInString(LastLine, AdshieldDomains)) {
export const IsAdShieldCall = (Trace = JustifyCallStack()) => {
if (Trace.length === 0) {
return false
}

if (HasSubstringSetsInString(Trace[Trace.length - 1], AdshieldDomains)) {
return true
}

const Url = new URL(LastLine)
const Url = new URL(Trace[Trace.length - 1])

if (Url.hostname !== location.hostname && Url.pathname === '/loader.min.js') {
return true
Expand Down
13 changes: 4 additions & 9 deletions sources/src/utils/secret.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cryptoRandomString from 'crypto-random-string'
import {AdshieldKeywords, IsAdShieldCall} from '../adshield/validators.js'
import {Config} from '../config.js'
import {GenerateCallStack, JustifyCallStack} from './call-stack.js'
import {GenerateCallStack} from './call-stack.js'
import {CreateDebug} from './logger.js'
import {HasSubstringSetsInString} from './string.js'

Expand Down Expand Up @@ -41,14 +41,7 @@ export const ProtectFunction = <F extends Fomulate>(F: F, Options: ProtectedFunc
throw new Error()
}

const JustifiedCallStack = JustifyCallStack()
const LastLine = JustifiedCallStack[JustifiedCallStack.length - 1]

if (LastLine === undefined || LastLine.startsWith('chrome') || LastLine.startsWith('webkit') || LastLine.startsWith('moz')) {
return false
}

if (IsAdShieldCall(LastLine)) {
if (IsAdShieldCall()) {
E()
}

Expand Down Expand Up @@ -89,6 +82,8 @@ export const ProtectFunction = <F extends Fomulate>(F: F, Options: ProtectedFunc
}
})

export const UnprotectedFetch = fetch

export const ProtectedDescriptors = new Set<unknown>()

export const ProtectDescriptors = <T extends ArbitaryObject, K extends keyof T>(O: T, Key: K, NewProperty: T[K]) => {
Expand Down

0 comments on commit f87dfae

Please sign in to comment.