Skip to content

Commit 747fe06

Browse files
Updated README
Updated urlwatcher and screenshot script to use new element arguments
1 parent 856798b commit 747fe06

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Lists all commands and their descriptions
1111
Lists all entries including their areas
1212
`/listurls`
1313
Lists all entries including their websites
14+
`/info <name>`
15+
Shows more information about a specific entry
1416
`/myid`
1517
Returns your User ID
1618
`/add <name> <URL> [x y width height]`
@@ -21,8 +23,12 @@ Removes an entry from the list
2123
Updates the screenshot area of an entry
2224
`/setdelay <name> <delay>`
2325
Specifies a delay in seconds to wait after the website has been loaded
24-
`/setelement <name> [html element]`
26+
`/setcaptureelement <name> [html element]`
2527
Specifies which HTML element to capture
28+
`/setclickelement <name> [html element]`
29+
Specifies which HTML element to click before taking the screenshot
30+
`/setwaitelement <name> [html element]`
31+
Specifies which HTML element to wait for before taking the screenshot
2632
`/fetch <name>`
2733
Takes a screenshot with the stored settings and sends it into this chat
2834
`/fetchurl <URL> [x y width height]`

tools/screenshot.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
2-
# Arguments: URL, File, Delay, Element
2+
# Arguments: URL, File, Delay, CaptureElement, ClickElement, WaitElement
33

4-
capture-website "$1" --output="$2" --overwrite --full-page --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36" --delay="$3" --element="$4"
4+
capture-website "$1" --output="$2" --overwrite --full-page --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36" --delay="$3" --element="$4" --click-element="$5" --wait-for-element="$6"

urlwatcher/urlwatcher.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ function reportNew {
6767
function takeScreenshot {
6868
local URL="$1"
6969
local DELAY="$2"
70-
local ELEMENT="$3"
71-
"$SCREENSHOT_SCRIPT" "$URL" latest.png "$DELAY" "$ELEMENT"
70+
local CAPTURE_ELEMENT="$3"
71+
local CLICK_ELEMENT="$4"
72+
local WAIT_ELEMENT="$5"
73+
"$SCREENSHOT_SCRIPT" "$URL" latest.png "$DELAY" "$CAPTURE_ELEMENT" "$CLICK_ELEMENT" "$WAIT_ELEMENT"
7274

7375
# On Error, retry once
7476
if [ ! -f latest.png ]; then
7577
echo "Error taking screenshot. Retrying..."
7678
sleep 0.2
77-
"$SCREENSHOT_SCRIPT" "$URL" latest.png "$DELAY" "$ELEMENT"
79+
"$SCREENSHOT_SCRIPT" "$URL" latest.png "$DELAY" "$CAPTURE_ELEMENT" "$CLICK_ELEMENT" "$WAIT_ELEMENT"
7880
fi
7981
}
8082

@@ -119,7 +121,7 @@ function screenshotsMatch {
119121
# We first have to delete the changed screenshot (otherwise we cannot confirm that taking the second screenshot was a success)
120122
rm -f latest.png
121123
sleep 1
122-
takeScreenshot "$URL" "$DELAY" "$ELEMENT"
124+
takeScreenshot "$URL" "$DELAY" "$CAPTURE_ELEMENT" "$CLICK_ELEMENT" "$WAIT_ELEMENT"
123125
# If no luck taking the second screenshot, abort
124126
if [ ! -f latest.png ]; then
125127
# Roll back the screenshot and report an error
@@ -165,12 +167,14 @@ while IFS='' read -r line || [ -n "${line}" ]; do
165167
WIDTH=$(echo $line | cut -d ',' -f4)
166168
HEIGHT=$(echo $line | cut -d ',' -f5)
167169
DELAY=$(echo $line | cut -d ',' -f6)
168-
ELEMENT=$(echo $line | cut -d ',' -f7)
169-
CHAT_ID=$(echo $line | cut -d ',' -f8)
170-
URL=$(echo $line | cut -d ',' -f9-)
170+
CAPTURE_ELEMENT=$(echo $line | cut -d ',' -f7)
171+
CLICK_ELEMENT=$(echo $line | cut -d ',' -f8)
172+
WAIT_ELEMENT=$(echo $line | cut -d ',' -f9)
173+
CHAT_ID=$(echo $line | cut -d ',' -f10)
174+
URL=$(echo $line | cut -d ',' -f11-)
171175

172176
echo "Checking $URL"
173-
177+
174178
# As image directory, we use the name and chat id to create unique directories
175179

176180
# Create the image directory, if it does not exist yet
@@ -191,7 +195,7 @@ while IFS='' read -r line || [ -n "${line}" ]; do
191195
#######################
192196

193197
# Take the screenshot
194-
takeScreenshot "$URL" "$DELAY" "$ELEMENT"
198+
takeScreenshot "$URL" "$DELAY" "$CAPTURE_ELEMENT" "$CLICK_ELEMENT" "$WAIT_ELEMENT"
195199

196200
# If no luck taking the screenshot, abort
197201
if [ ! -f latest.png ]; then

0 commit comments

Comments
 (0)