@@ -0,0 +1,2684 @@
+package asdff;%0A%0Aimport com.google.common.base.Function;%0Aimport com.google.common.base.Predicate;%0A%0Aimport org.openqa.selenium.OutputType;%0Aimport org.openqa.selenium.TakesScreenshot;%0Aimport org.openqa.selenium.TimeoutException;%0Aimport org.openqa.selenium.WebDriver;%0Aimport org.openqa.selenium.firefox.FirefoxDriver;%0Aimport org.openqa.selenium.remote.Augmenter;%0Aimport org.openqa.selenium.support.ui.WebDriverWait;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.StandardOpenOption;%0Aimport java.util.Date;%0A%0Apublic class ScreenshotRunner implements Runnable %7B%0A  private final String tempFileURI;%0A  private byte%5B%5D oldData;%0A  private final int intervalSeconds;%0A%0A  private static File createIframeHtml(int height, int width, String url) throws IOException %7B%0A    String data = String.format(%0A        %22%3Chtml%3E%3Cbody%3E%3Ciframe style=%5C%22height: %25dpx; width: %25dpx;%5C%22 src=%5C%22%25s%5C%22%3E%3C/iframe%3E%3Cbody%3E%3C/html%3E%22,%0A        height, width, url);%0A%0A    // Write iframe html%0A    File tempFile = File.createTempFile(%22iframe%22, %22.html%22);%0A    Files.write(tempFile.toPath(), data.getBytes(), StandardOpenOption.TRUNCATE_EXISTING);%0A    return tempFile;%0A  %7D%0A%0A  private final Function%3CScreenshotDiff, ScreenshotDiff%3E work;%0A  private final WebDriver driver;%0A%0A  public ScreenshotRunner(String url, int imageHeight, int imageWidth, int intervalSeconds,%0A      Function%3CScreenshotDiff, ScreenshotDiff%3E work) throws IOException %7B%0A    File tempFile = createIframeHtml(imageHeight, imageWidth, url);%0A    this.intervalSeconds = intervalSeconds;%0A    tempFileURI = tempFile.toURI().toString();%0A    this.work = work;%0A    WebDriver ffDriver = new FirefoxDriver();%0A    driver = new Augmenter().augment(ffDriver);%0A  %7D%0A%0A  public void run() %7B%0A    while (true) %7B%0A      // Launch driver%0A      driver.get(tempFileURI);%0A%0A      // Wait for the page to load%0A      try %7B%0A        (new WebDriverWait(driver, intervalSeconds))%0A            .until(new Predicate%3CWebDriver%3E() %7B%0A              public boolean apply(WebDriver arg0) %7B%0A                return false;%0A              %7D%0A            %7D);%0A      %7D catch (TimeoutException e) %7B%0A      %7D%0A%0A      // Generate diff%0A      if (oldData == null) %7B%0A        System.out.println(%22Taking initial screenshot at %22 + (new Date()).toString()); %0A        oldData = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);%0A      %7D else %7B%0A        System.out.println(%22Taking diff screenshot at %22 + (new Date()).toString());%0A        byte%5B%5D newData = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);%0A        ScreenshotDiff diff = new ScreenshotDiff(oldData, newData);%0A        if (diff.isDifferent()) %7B%0A          work.apply(diff);%0A        %7D%0A      %7D%0A    %7D%0A  %7D%0A%7D%0A

Create ScreenshotRunner.java