Giter Site home page Giter Site logo

nicaicaii / js-hook-event-listener Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jsrei/js-hook-event-listener

0.0 0.0 0.0 5 KB

JavaScript逆向脚本开发基础组件:hook事件监听器,侵入接管事件触发逻辑

License: MIT License

JavaScript 82.78% HTML 17.22%

js-hook-event-listener's Introduction

JavaScript Hook Event Listener

JavaScript逆向开发基础组件系列:Hook事件监听器函数,一般用在编写JavaScript逆向的油猴脚本中,作为基础组件提高开发效率。

Example

油猴脚本中使用方式大概是这样:

// 提前埋伏好,后面增加事件监听的时候会把给定的逻辑放进去,通常情况下是借助油猴脚本等之类的工具注入到正常页面的头部先执行
(() => {
    const fooBtnElement = document.getElementById("foo-btn");
    const hookFunc = function () {
        alert("执行了Hook逻辑!");
        return true;
        // return false;
    };
    new HookEventListener(fooBtnElement, "onclick", "addEventListener", ["click"], hookFunc).addHook();
})();

页面中网站开发者的代码是这样,就会被前面的代码Hook到:

// 正常的代码,就正常添加事件,但是会被前面添加的Hook给捕捉到先悄悄执行Hook逻辑,然后才会执行此处指定的事件回调方法
const elementById = document.getElementById("foo-btn");
const eventFunc = function () {
    alert("按钮被单击!");
};
// elementById.addEventListener("click", eventFunc);
elementById.onclick = eventFunc;

TODO

对于DOM元素直接在标签中绑定时间的情况也要能够Hook得到

js-hook-event-listener's People

Contributors

cc11001100 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.