aboutsummaryrefslogtreecommitdiff
path: root/config.dot/luakit.link/webview_wm.lua
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-09-21 21:39:54 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-09-21 21:39:54 -0300
commitfc24ecca542a10deefc789342f373e8d6a4a43cb (patch)
treef3e11c3a14e156a145778c200219c86058e9805c /config.dot/luakit.link/webview_wm.lua
parent562adce657add8aaf2c80597fc54fa0a906c2287 (diff)
downloadluakit-fc24ecca542a10deefc789342f373e8d6a4a43cb.tar.gz
luakit-fc24ecca542a10deefc789342f373e8d6a4a43cb.tar.bz2
Stable config
Diffstat (limited to 'config.dot/luakit.link/webview_wm.lua')
-rw-r--r--config.dot/luakit.link/webview_wm.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/config.dot/luakit.link/webview_wm.lua b/config.dot/luakit.link/webview_wm.lua
new file mode 100644
index 0000000..0d7b5dd
--- /dev/null
+++ b/config.dot/luakit.link/webview_wm.lua
@@ -0,0 +1,21 @@
+local ui = ipc_channel("webview_wm")
+
+ui:add_signal("load-finished", function(_, page)
+ local doc = page.document
+
+ -- do nothing if loaded document is not HTML
+ if not doc.body then return end
+
+ if page.uri:find("luakit://", 1, true) == 1 then
+ doc.body:add_event_listener("click", true, function (event)
+ if event.button ~= 0 then return end
+ if event.target.tag_name ~= "A" then return end
+ if (event.target.attr.href or ""):find("file://", 1, true) ~= 1 then return end
+
+ ui:emit_signal("navigate", page.id, event.target.attr.href)
+ end)
+ end
+
+end)
+
+-- vim: et:sw=4:ts=8:sts=4:tw=80