javascript - Userscript in inner #document elements -
this question has answer here:
i trying write tampermonkey script appends html body, reason, html dialog appears in ads. google chrome's inspect element shows this:
#document <!doctype html> <html> <body> <!-- body tag --> ... </body> </html>
as can see, there body tag, dialog appears in it, too. there way target main <body>
tag, , not inside #document
tag?
what happening because @match
quite greedy, runs on html documents on page. if want run on root page, can check if window "top" window.
if (window !== window.top) { // not root, return return; }
this may present problem when run on pages framesets, not common practice more, surprised if find problem.
Comments
Post a Comment