-- compatibility functions function open(url) NavigateTo(url, OPEN_NORMAL) end function opennew(url) NavigateTo(url, OPEN_NEWTAB) end function openbg(url) NavigateTo(url, OPEN_BACKGROUNDTAB) end function statusbar(text) SetStatusBarText(text) end function setcheck(id, mark) SetCheck(id, mark) end function togglepref(type, pref, ...) local v, i, n, arg v = getpref(type, pref) if type == TYPE_BOOL then setpref(type, pref, not v) else arg = {...} i = 1 while i <= #arg do if v == arg[i] then i = i + 1 if i <= #arg then setpref(type, pref, arg[i]) else setpref(type, pref, arg[1]) end break end i = i + 1 end end end function gensub(r, s, h, t) local i, j, l i = 1 l = string.len(s) while true do i, j = string.find(r, t, i, true) if i then r = string.sub(r, 1, i - 1) .. s .. string.sub(r, j + 1, -1) i = i + l if type(h) == "number" then h = h - 1 if h == 0 then break end end else break end end return r; end function gsub(r, s, t) gensub(r, s, "G", t) end function sub(r, s, t) gensub(r, s, 1, t) end function index(s, t) local i i = string.find(s, t, 1, true) if i then return i else return -1 end end function substr(s, i, n) local l if type(n) == "number" then l = i + n - 1 else l = -1 end return string.sub(s, i, l) end function macros(macro) plugin("macros", macro) end