// 📘 Guam Phone Lookup with Telegram Support
// Ray’s Scriptable version – no Python needed
// Config section – edit this!
const TELEGRAM_BOT_TOKEN = ‘123456789:ABCdefGHIjkLmnopQRStuvWxYZ’; // <– Replace with your bot token
const TELEGRAM_CHAT_ID = ‘987654321’; // <– Replace with your target chat ID (user/group/channel)
// Prompt user
let name = await Prompt.text(“Search name”)
let pageCount = parseInt(await Prompt.text(“Number of pages to search (1–5)”), 10) if (!name || isNaN(pageCount)) return new Alert(“Missing input”).present()
let results = []
let baseURL = “https://www.guamphonebook.com/whitepages”
for (let p = 1; p <= pageCount; p++) {
let url = `${baseURL}?name=${encodeURIComponent(name)}&page=${p}` let req = new Request(url)
req.headers = { “User-Agent”: “ScriptableBot/1.0” }
let html = await req.loadString()
let matches = […html.matchAll(/listing-name[^>]*>(.*?)<\/.*?listing-phone[^>]*>(.*?))] for (let m of matches) results.push({ name: m[1].trim(), phone: m[2].trim() }) }
if (results.length === 0) return new Alert(“No results found.”).present()
QuickLook.present(results, true)
// Save JSON to iCloud
let fm = FileManager.iCloud()
let folder = fm.joinPath(fm.documentsDirectory(), “GuamScraper”) if (!fm.fileExists(folder)) fm.createDirectory(folder)
let outPath = fm.joinPath(folder, `${name}_lookup.json`)
await fm.writeString(outPath, JSON.stringify(results, null, 2)) console.log(“Saved to: ” + outPath)
// Send to Telegram (optional)
let msgBody = results.map(r => `• ${r.name} — ${r.phone}`).join(‘\n’)
let tgReq = new Request(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage`) tgReq.method = “POST”
tgReq.headers = { “Content-Type”: “application/json” }
tgReq.body = JSON.stringify({
chat_id: TELEGRAM_CHAT_ID,
text: `📇 Guam Results for “${name}”:\n${msgBody}`,
parse_mode: “Markdown”
})
let response = await tgReq.loadJSON()
console.log(“Telegram response:”, response)