#!/bin/bash
# Generate gallery from screenshot files for easy review

generate_screenshot_report() {

domain=$1
cd "./screenshots" || { echo "Something went wrong"; exit 1; }

if [ -e screenshotReport.html ]
then
    rm screenshotReport.html
fi

cat >> ../screenshotReport.html << HEADER
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./dist/github-markdown.css">
<title>Screenshots for $domain</title>
<style>
    .markdown-body {
        box-sizing: border-box;
        min-width: 200px;
        max-width: 980px;
        margin: 0 auto;
        padding: 45px;
    }

    @media (max-width: 767px) {
        .markdown-body {
            padding: 15px;
        }
    }
</style>
</head>
<body>
<div class="markdown-body">
  <h1>Screenshots for <code>$domain</code></h1>
  <h2>Note: This report has been deprecated in favor of Aquatone. Please check out <a href="./aquatone_report.html">the Aquatone report</a> instead.</h2>
HEADER

for i in *.png
do 
caption="$i"
cat >> ../screenshotReport.html << HTML
<div id="img_$i" class="screenshot">
  <a href="./screenshots/$i">
  <p>$caption</p>
  <img src="./screenshots/$i" alt="$caption"/>
  </a>
  <br>
  <br>
</div>
HTML

done

cat >> ../screenshotReport.html << FOOTER
<hr>
<p>Report generated by <a href="https://github.com/chvancooten/BugBountyScanner">BugBountyScanner</a></p>
</div>
</body>
</html>
FOOTER

cd ..
}

