You can do feature creep for a long time. If you just want a basic working version (that will probably drain your battery), that can be done really quickly.
This took me ~10 minutes:
#!/bin/sh
set -e
while true; do
URLS="$(xsel | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*")" &&
if [[ ! "${URLS}" = "${OLD_URLS}" ]]; then
echo "${URLS}" >> urls.txt
OLD_URLS="${URLS}"
fi
sleep 1
done;
This took me ~10 minutes: