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

Commit

Permalink
fix: prevent onload event in Ad-Shield script
Browse files Browse the repository at this point in the history
  • Loading branch information
piquark6046 committed Feb 10, 2024
1 parent 958ccbc commit 193fedf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
11 changes: 6 additions & 5 deletions microShield.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microshield",
"version": "3.14.2",
"version": "3.15.0",
"description": "",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion sources/banner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// @downloadURL https://cdn.jsdelivr.net/gh/List-KR/microShield@latest/microShield.user.js
// @license Apache-2.0
//
// @version 3.14.2
// @version 3.15.0
// @author PiQuark6046 and contributors
//
// @match *://algumon.com/*
Expand Down
1 change: 1 addition & 0 deletions sources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const bootstrap = () => {
win.Element.prototype.removeChild = makeUnsafeProxy(win.Element.prototype.removeChild, 'Element.prototype.removeChild');
win.Element.prototype.insertAdjacentHTML = makeProxy(win.Element.prototype.insertAdjacentHTML, 'Element.prototype.insertAdjacentHTML');
win.Element.prototype.setAttribute = makeProxy(win.Element.prototype.setAttribute, 'Element.prototype.setAttribute');
win.alert = makeUnsafeProxy(win.alert, 'alert');
win.HTMLScriptElement.prototype.setAttribute = new Proxy(win.HTMLScriptElement.prototype.setAttribute, {
apply(target, thisArg, argArray: [string, string]) {
if (argArray[0] === 'src' && typeof argArray[1] === 'string') {
Expand Down
6 changes: 5 additions & 1 deletion sources/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isNotResourceInfectedByAdShield} from './call-validators/analyzers';
import {isNotResourceInfectedByAdShield, knownAdShieldOrigins} from './call-validators/analyzers';
import {adShieldOriginCheck, adShieldStrictCheck} from './call-validators/suites';

// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -168,6 +168,10 @@ export const makeUnsafeProxy = <F extends Function>(f: F, name = f.name) => {
throw new Error('microShield');
}

if (argArray.length > 0 && knownAdShieldOrigins.some(Origin => argArray.join('\n').includes(Origin))) {
throw new Error('microShield');
}

return Reflect.apply(target, thisArg, argArray) as F;
},
// Prevent ruining the call stack with "explicit" checks
Expand Down

0 comments on commit 193fedf

Please sign in to comment.