A stealth JavaScript hook library with automatic iframe detection and function toString spoofing.
npm install @wulu007/stealth-hooktoString() checks
bash
npm install stealth-hook
`
$3
`bash
pnpm add stealth-hook
`
$3
`javascript
// @require https://unpkg.com/@wulu007/stealth-hook@latest/dist/index.global.js
// @grant unsafeWindow
// @run-at document-start
`
Usage
$3
`javascript
import { hookScope } from 'stealth-hook'
hookScope(({ hookMethod }, win) => {
// Note: use the win parameter
hookMethod(win.console, 'log', (target, args, thisArg) => {
console.log('[Hooked]', ...args)
return target(...args)
})
}, rootWindow)
`
$3
`javascript
// ==UserScript==
// @name StealthHook Example
// @namespace https://example.com/
// @version 0.1.0
// @description Hook Example
// @author You
// @match :///*
// @require https://unpkg.com/@wulu007/stealth-hook@latest/dist/index.global.js
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
(function () {
StealthHook.hookScope(({ hookMethod }, win) => {
// Note: use the win parameter
hookMethod(win.console, 'log', (target, args, thisArg) => {
console.log('[Custom Log]', ...args)
return target(...args)
})
hookMethod(win.console, 'table', (target, args, thisArg) => {
console.log('[Custom Table]', args)
return target(...args)
})
}, unsafeWindow)
})()
`
#### Parameters
| Parameter | Type | Description |
| --------- | ------------ | ---------------------------------------------- |
| target | Function | Original function with this auto-bound |
| args | Array | Arguments array of the original function |
| thisArg | this type | Current this` context (caller) |