MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / isAllowHook

Method isAllowHook

scripts/libs/js-hook/index.js:322–328  ·  view source on GitHub ↗

* Determine whether a value under the object meets the conditions for hooking * Note: Having hook conditions and being able to directly modify the value are two different things. * When hooking, also check whether descriptor.writable is false. * If it is false, it must be changed to true

(parentObj, keyName)

Source from the content-addressed store, hash-verified

320 * @returns {boolean}
321 */
322 isAllowHook (parentObj, keyName) {
323 /* Some objects will set getters so that an error will be thrown when reading the value,
324 so try catch is needed to determine whether the attribute can be read normally */
325 try { if (!parentObj[keyName]) return false } catch (e) { return false }
326 const descriptor = Object.getOwnPropertyDescriptor(parentObj, keyName)
327 return !(descriptor && descriptor.configurable === false)
328 }
329
330 /**
331 * hook core function

Callers 2

hookMethod · 0.80
unHookMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected