The current domain priority controls are very useful, but could be made more powerful by allowing the user to, at clientside, decide if a link should be shown or not.
Your code would run, getting invoked multiple times by Kagi with an argument containing the details of each link, with their domain
, full URL
, title
and snippet
. Then, the function could return true
or false
to decide whether the link should be shown or not in the search view.
The filters could be coded in JavaScript, or preferentially, could be executed as WebAssembly blobs, permitting the use of any other languages that compile down to it, like Rust.
Use-case: Advanced users could integrate machine learning models or heuristics to exclude SEO or other unwanted links.
Pseudo-code in Lua:
1. user.lua:
-- block pinterest links
function pinterest_filter(link)
return not string.find(link.full_url, "pinterest")
end
-- use ml model to block links ...
function ml_filter(link)
return ml_filter_internal(link)
end
add_link_filter(pinterest_filter)
add_link_filter(ml_filter)
...
2. kagi_internal.lua:
-- dynamically generated from the backend search results ...
local links = {
{
title = "Pinterest - Wikipedia",
snippet = [[Pinterest is an American image sharing and social media service designed to enable saving and discovery of information (specifically "ideas") like recipes, home, style, motivation, and inspiration on the internet using images and, on a smaller scale, animated GIFs and videos, in the form of pinboards."]],
full_url = "https://en.wikipedia.org/wiki/Pinterest",
domain = "en.wikipedia.org",
tracker_count = 0,
},
...
}
-- internally, kagi would call the function like this:
for _, link in pairs(links) do
local link_blocked = false
for _, filter in pairs(registered_filters) do
if not filter(link) then
link_blocked = true
-- link blocked, don't check with any other filters
break
end
end
if not link_blocked then
show_link(link)
end
end