0

I am working on a Google Chrome extension. We need to display a pop-up login window for users to enter credentials, then handle logins. My extension project consists of three pages: extension, background and options. Options html and JavaScript pieces handle login, however reference to a window opened from options.html is always null. Therefore, I tried sending a message from options to background scripts, and have the background script open the login window. That part is working, however I never receive any events from that popup, and therefore cannot process the results of login.

    case 'openSignInWindow':
      let loginWindowRef = window.open('https://myurl.com/client/signin.html', 'signinpopup', 'width=400,height=400,resizeable,scrollbars');
      console.log('login window ref:', loginWindowRef);
      loginWindowRef.onload = () => { alert("message one "); };
      loginWindowRef.addEventListener('DOMAttrModified', event => {
        console.log('event:', event);
      });
      break;

Tried onsubmit - the one that I am interested in, as well as other events. My ultimate goal is to catch the "DOM Mutation events."

What am I doing wrong?

Moshe Shmukler
  • 1,116
  • 2
  • 18
  • 35
  • it's same site, right? not cross origin (just making sure) – Jaromanda X Oct 06 '17 at 08:23
  • it is a Chrome extension - hence, no. The extension is local and the window is off a remote site. – Moshe Shmukler Oct 06 '17 at 08:25
  • oops, yeah, sorry, didn't read properly :p – Jaromanda X Oct 06 '17 at 08:26
  • Possible duplicate of [How to access the webpage DOM rather than the extension page DOM?](https://stackoverflow.com/questions/4532236/how-to-access-the-webpage-dom-rather-than-the-extension-page-dom) – wOxxOm Oct 06 '17 at 10:18
  • I don't see the direct connection, expect that both issues have to do with Chrome extensions. Still, thank you for trying. – Moshe Shmukler Oct 06 '17 at 11:08
  • 2
    The direct connection is that the page you open is a website so to access its DOM stuff (events included) you need to use a content script. – wOxxOm Oct 06 '17 at 13:31

0 Answers0