# ==============================================================================================
# GET LINKS FROM SAFARI USING A REGULAR _expression_
# ==============================================================================================
on SAFARI_LINKS(regexStr, tagName, tagType)
set js to "function in_array (array, item) {
for (var i=0; i < array.length; i++) {
if (array[i] == item) {
return true;}}
return false;}
var a_tags = document.getElementsByTagName('" & tagName & "');
var href_array = new Array();
var reg = new RegExp(" & regexStr & ");
for (var i = a_tags.length - 1; i >= 0; i--) {
var href = "" style="color: #000000"> & tagType & ";
if (reg.test(href)) {
if (!in_array(href_array, href)) {
href_array.push(href);}}}
href_array;"
try
tell application "Safari"
set linkList to do _javascript_ js in document 1
end tell
return linkList
on error
return false
end try
end SAFARI_LINKS
set linkList to SAFARI_LINKS("/.*\\d+.*\\.jpg/i", "a", "href")
set linkList to reverse of linkList