Js injection problem, let's have a big cow.

1. Demand, js injection, other platforms to promote to us, from our platform links to users who have registered in the past, we can make a profit, so I want to add our own js, to the js of their page when users click to register, but only to the end;
2. Problem: when I click on the event, I get the information of the form and pass the data into my database through ajax, but js is single-threaded. When their click event is triggered, the link is jumped, and the js we injected will not take effect.
3. Address to be injected: https://promotion.crfchina.co.
4. Your own injection code

let TYPE = 1;
let APPID = 1000000;
let token = document.getElementsByTagName("body")[0].getAttribute("datetoken");
let channelName = document.title;
let applyUserName = 0;
let applyIdCard = 0;


/**
 * 
 */
$(".btn_next").click(() => {

  var applyUserMobile = $(".phone").val();
  console.log(applyUserMobile)
  if (checkpage()) {
    console.log(2)
    $.ajax({
      async: false,
      type: "GET",
      dataType: "json",
      url: "URL",
      beforeSend: function (request) {
        request.setRequestHeader("appId", APPID);
        request.setRequestHeader("token", "token");
      },
      data: "",
      timeout: 3000,
      success: function (msg) {
      },
      error: function (e) {
      }
    });
  }
})

/**
 * 
 */
function checkpage() {
  let telValue = $(".phone").val();
  let passValue = $(".password").val();
  let codeInput1 = $(".verification").val();
  let smsCode = $.trim(codeInput1);
  if (!telValue) {
    showPoint("");
    return;
  }
  if (!passValue) {
        showPoint("");
        return;
    }
    var checkTel = checkPhone(telValue);
    if (!checkTel) {
        return;
    }
    var checkPass = checkWord(passValue);
    if (!checkPass) {
        return;
    }
    if (!smsCode) {
        showPoint("");
        return;
    }
    var regFirm;
    if ($(".choose").is(":checked") == true) {
        regFirm = 1;
    } else {
        regFirm = 0;
        showPoint("");
        return;
    }
}
Mar.10,2021

you use js to get the click event, and then rewrite it, or let him disable
jquery remove, bind, trigger element event using examples to explain


what you are triggering is an asynchronous method, so you can't really let him click on the original element.
you can add an invisible mask, or hide the original dom and replace your dom. In short, do not let the original dom trigger, waiting for your callback to trigger the original dom event.


There are many

methods, here is an example for reference.

< H2 > blindfold < / H2 >

Clone the original button and replace it.

< H2 > sample code < / H2 >
<html>
    <head></head>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <body>
        <input class="btn_next" type="button" value="" />

        <!--  js  -->
        <script>
            $(".btn_next").click(function() {
                alert("");
            })
        </script>

        <!--  js  -->
        <script>
            // 
            $(".btn_next").parent().prepend('<input class="btn_next_clone" type="button" value="" />');
            // 
            $(".btn_next").css("display", "none");
            $(".btn_next_clone").click(function() {
                alert("");
                $(".btn_next").click();
            });
        </script>
    </body>
</html>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9f587-691bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9f587-691bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?