function RewindPage() local titles, urls, index = km.GetMozillaSessionHistory() if not titles then return end titles = nil -- prune local host = string.match(urls[index], "[^/:]+://([^/]+).*") local i = index while i > 1 do i = i - 1 if string.match(urls[i], "[^/:]+://([^/]+).*") ~= host then i = i + 1; break end end if i < index then km.GotoHistoryIndex(i - 1) -- Index of GetMozillaSessionHistory starts 1. -- Index of GotoHistoryIndex starts 0. end end