0

I have a question that may seem slightly vague, but I am not sure how to go about solving it.

Our office runs a headless machine that is a print server, connect via third party software. The issue that I am having, is that if for whatever reason, the system becomes disconnected from the host server, by means of connection issues on either our end, or theirs, an Alert dialog appears, and the printing will be halted until the dialog is dismissed.

The application is run through Internet Explorer, and appears with with the following dialog.

enter image description here

I originally tries using Java, and a Robot to blindly click the okay button, however the issue is that the dialog will appear in different places each time, and sometimes the message will appear multiple times if not dismissed immediately, so blindly clicking a screen coordinate will not work.

enter image description here

My next thought was to search for a PID, and kill each message by name, or PID, however because it is an Internet Explorer application, that is not a possibility.

enter image description here

Any thoughts as to how I could blindly dismiss these messages, either automatically, or through an external signal?

Edit

I have determined that the dialog is created using JavaScript, and I now have an alteration to the question, how can I dismiss this alert() call? I have read that using JavaScript, you can not dismiss the message, but would there be a way to inject a custom script, to overrride the call to alert?

i.e., a dead function that overrides the system alert?

function alert(){
    // do nothing
}

How could I append this to the already loaded page...?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Matt Clark
  • 27,671
  • 19
  • 68
  • 123
  • possible duplicate of [JavaScript: Overriding alert()](http://stackoverflow.com/questions/1729501/javascript-overriding-alert) – emerson.marini Dec 30 '14 at 20:28

1 Answers1

1

I suppose you don't have access to the source code of the print server app so the best way for you to do is add a bookmarklet which contains a javascript code overriding the alert.

A bookmarklet basically is a piece of code stored as a bookmark in a web browser

To create a bookmarklet, open up Notepad and create an HTML page with this content:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
  <a id="codeOut" href="javascript:(function(){ window.alert = function(){};})();">Your Bookmarklet</a>
</body>
</html>

Save the file as "Bookmarklet.html"

Open the file with Internet Explorer

Right-click on the "Your Bookmarklet" hyperlink, select "Add to favorites" and give it a name

Once your application is loaded and your bookmarklet added, in IE select Favorites->"Name of your bookmarklet"

securecodeninja
  • 2,497
  • 3
  • 16
  • 22