简体   繁体   中英

Find out what code triggered a change in input

I have Chrome auto password filling disabled.

In one particular login page of a website, right after the load event, the password input goes from being empty to have a string as its value (not reflected in the DOM). If I take a look through console.dir() I can read its value, and is a password I've never use or would use, so I never typed that. Nothing I've searched or asked has been of any help.

I've debugged the page and with an eventListener I can pinpoint the exact moment that value is introduced, just listening for the change event. But that is not really useful, I just see the input changed with that weird password but know nothing about why it's appearing there. AFAIK the event object doesn't have a clue of who's behind the change.

I want to know what function or snippet or code is acting on that input and inserting that useless string.

How can I accomplish that?

EDIT : I appreciate the side help but I'm only really interested in the answer to the question asked

In the change event you could log a error ( console.error(..) ) which shows the stacktrace.

 function iChangedTheValue() { $("#id1").val("value").trigger("change") } $("input").on("change", function(event){ console.error("value of " + event.currentTarget.id + " has been changed") }); iChangedTheValue();
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input id="id1" />

In Chrome devtools ( F12 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM