1

I wrote a Web Extension which starts surfing specified websites automatically (to simulate/train user profiles by "collecting" website cookies) after the Chrome browser is opened.

I know that you can disable the popup by whitelisting it for your own Web Extension:

Disable developer mode extensions pop up in Chrome

But: My Web Extension has to run automatically on 8-16 virtual machines on Linux without a GUI and i don't know whether it is possible and how to do it.

My Extension opens the first URL as expected, but then the popup comes into play and stops further surfing. If i open another tab per hand it continues to work, but opening a tab via Javascript doesn't do the trick. My code usually doesn't have to handle multiple tabs, because everything is done with one tab. Maybe i'm executing the code at the wrong time. The code works perfectly, when the popup doesn't come.

My code without tab opening:

background.js

var shouldMessageBeSent = true;

chrome.windows.onCreated.addListener(function() {
  chrome.tabs.update({url:"https://stackoverflow.com/"}); // placeholder URL
});

chrome.webNavigation.onCompleted.addListener(function() {
  if (shouldMessageBeSent == true) {
    chrome.tabs.query({"currentWindow": true}, function(tabs) {
      shouldMessageBeSent = false;
      chrome.tabs.sendMessage(tabs[0].id, {txt: "newURLvisited"}, function(response) {});
    });
  } 
});


chrome.runtime.onMessage.addListener(gotMessage);

function gotMessage(message) {
  if (Array.isArray(message)) { // It's an array in my code
    linksToVisit = message;
  }
  visitLinks(linksToVisit); // visits all the given links (the links are filtered in my code)
}

Content.js (highly simplified)

chrome.runtime.onMessage.addListener(gotMessage);

function gotMessage(message) {
  if (message.txt === "newURLvisited") {
    var allLinks = document.getElementsByTagName("a");
    chrome.runtime.sendMessage(allLinks);
  }
}

Any ideas what to fix? It may have to do something with active window/tab focus.

aj93
  • 83
  • 2
  • 7
  • A browser test automation tool like Selenium might be a better fit for your use case. – lgaud Dec 26 '19 at 22:45
  • 1
    I found that opening subsequent sessions of Chrome don't show the popup as long as the first session is still open. Next step was to hide the initial session in the notification area using the free tool RBTray found here http://rbtray.sourceforge.net/ I know it's not perfect but I don't think the Chromium devs will allow any way to block this going forward so hiding is our best bet. This will work on any Chromium version and practically all Windows versions. CPU/RAM usage seems negligible. – VST Feb 14 '20 at 20:06

1 Answers1

0

Apparently you can install a policy for Chrome, provided as a template from Google, which you can edit to your taste before that; I suppose you can do a similar thing on Mac and Linux just in a JSON editor.

9000
  • 39,899
  • 9
  • 66
  • 104