问题
When I open a website that's not developed by me, it created a pop up of a DIV element. How can I find which code create that popup?
I tried to set the breakpoint, but it only show the popup in the first time.
Please note the key here are
It's a website that's not developed by me
The Popup is a DiV
The popup only show the first time. If I refresh the page, it's gone.
I'm not asking you to debug the site for me, I want to learn the ways to debug it by myself.
What I'm after is programmatically set up a break point based on a condition that I set. So if there are several methods to generate the DIV, then I can add those methods to the condition to catch all. Since the native debugger has the ability to break on DOM manipulation, I expect I can do the same, but in the programming way. That is, I can pause the execution by specifying a condition when a DIV that has some traits created.
In theory I think it's doable, if only the debugger can expose their function as API, I imagine there is a way to set a breakpoint when some conditions are satisfied. It's like below Attach the process with a condition, if the target element has some traits, break. Or if the code block is doing something that I specified, break.
But it seems the reality is debugging tools on web browsers are for UI users instead of programmers. I might be very wrong here. So Please correct me if you can.
Did anyone face the same challenge and did something?
It seems this is done and there are APIs, but I'm still not sure how I can use it to do what I want.
https://developer.mozilla.org/en-US/docs/Tools/Debugger-API
Do I need to create an add-on for this purpose?
Or probably GreaseMonkey is good enough for this quest?
It seems the document related to Firefox debug API are outdated, the scratchpad is disabled. It's not possible for me to go through the tutorial to learn the debugger API
https://developer.mozilla.org/en-US/docs/Tools/Debugger-API/Tutorial-Breakpoint
回答1:
Usually to create a popup I use Alert(message) maybe search in inspector for that
来源:https://stackoverflow.com/questions/62214028/is-there-a-way-to-find-where-the-code-creates-the-dynamically-popup-on-browsers