Search code examples
javascriptgoogle-chromegoogle-chrome-extensiontampermonkey

Can a tampermonkey script run in a Chrome pop-up window?


I am writing a little tampermonkey script to click a button called "Close Contact" in the Amazon AWS Connect softphone (used for customer service) if it appears because I keep forgetting to do it after calls at work. The problem is, the softphone is in a popup window. I can see the URL (although I will not disclose it for privacy reasons of my work), but as with most pop-up windows, you cannot even see the installed extensions. Is it possible for tampermonkey to detect / run scripts in pop-up windows like this, and if so, is anything special needed to do so? (I am mostly a python/java developer and am not particularly familiar with the DOM/front-end development beyond basics).


Solution

  • As wOxxOm said in his comment: Yes, it can.

    The most common problems can often be solved by wrapping your script in a setTimeout or using Brock's waitForKeyElements utility. Or, if you prefer, mutationObserver.

    Links:

    https://stackoverflow.com/a/11197969/1447509

    https://stackoverflow.com/a/17872564/1447509

    https://stackoverflow.com/a/39332340/1447509

    https://stackoverflow.com/a/72667050/1447509