Last active
July 25, 2025 03:05
-
-
Save andelink/3425e3e4d1df2f3c5f05e95fd79cd3e1 to your computer and use it in GitHub Desktop.
UserScript to set model selection query parameters in Kagi Quick Answer Assistant link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name kagi-quick-answer-assistant.user.js | |
// @match https://kagi.com/search* | |
// @author andelink | |
// @namespace andelink | |
// @description append model selection query parameters to kagi quick answer assistant link | |
// @run-at document-end | |
// @version 0.1 | |
// @homepageURL https://gist.github.com/andelink/3425e3e4d1df2f3c5f05e95fd79cd3e1 | |
// @downloadURL https://gist.github.com/andelink/3425e3e4d1df2f3c5f05e95fd79cd3e1/raw/kagi-quick-answer-assistant.user.js | |
// ==/UserScript== | |
// Optionally specify an assistant to use e.g. a base profile like o4-mini or a custom assistant uuid. | |
// Left blank it uses the default assistant configured at https://kagi.com/settings/assistant | |
const profile = ""; | |
function updateLink(event) { | |
let lens = document.querySelector('.filter-item .--active span')?.textContent.trim().toLocaleLowerCase(); | |
let link = event.currentTarget; | |
let url = URL.parse(link.href); | |
console.log(`Original link: ${link.href}`); | |
// See: https://help.kagi.com/kagi/ai/assistant.html#url-parameters | |
if (true) { | |
url.searchParams.set('internet', true); | |
} | |
if (profile) { | |
url.searchParams.set('profile', profile); | |
} | |
if (lens) { | |
url.searchParams.set('lens', encodeURIComponent(lens)); | |
} | |
link.href = url.href; | |
console.log(`Updated link: ${link.href}`); | |
} | |
(function () { | |
let link = document.querySelector('.results_summary_text_box > [class*="summary_link"] a'); | |
link.addEventListener('pointerenter', updateLink, { once: true }); | |
link.addEventListener('focus', updateLink, { once: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment