randomfox (randomfox) wrote,
randomfox
randomfox

K-Meleon Lua macros for Shadows

Shadows is a social bookmarks manager.

In accel.cfg:
%ifplugin luamacros
VK_F7 = luamacros(ShadowsTagIt)
SHIFT VK_F7 = luamacros(ShadowsShowPage)
%endif
Lua code:
-- Lua macros for Shadows

local function encode2(url)
   return string.gsub(url, "([^a-zA-Z0-9_%.%-])", function (s)
       return string.format("%%%02X", string.byte(s))
   end)
end

local function EE2(str)
   return encode2(EncodeUTF8(str))
end

local function GotoNew(hwnd, url)
    NavigateTo(url, OPEN_NEW, hwnd)
end

function ShadowsTagIt(hwnd)
   local title, url = GetDocInfo(hwnd)
   url = url or ""
   if title == nil or title == "" then
       title = url
   end
   GotoNew(hwnd, "http://www.shadows.com/features/tcr.htm?url=" .. EE2(url) ..
       "&title=" .. EE2(title))
end

function ShadowsShowPage(hwnd)
   local title, url = GetDocInfo(hwnd)
   url = url or ""
   GotoNew(hwnd, "http://www.shadows.com/shadows.aspx?url=" .. EE2(url))
end

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments