Home

Custom search on iOS

I like to use a combination of Brave and Kagi searches, however on iOS you can't install your own search engines. This article describes how I managed to set up search behavior in Safari on iOS to my own liking.

Here is how it works:

Instructions

Modificator

window.stop();
document.body.innerHTML = "";
var w = ((/q=([^&#=]*)/.exec(window.location.search))[1]).split("+");
if (w[0] === "k") {
    w.shift();
    window.location.replace("https://kagi.com/search?q=" + w.join("+"));
} else {
    window.location.replace("https://search.brave.com/search?q=" + w.join("+"));
}
var swke = document.getElementById("searchWithKagi");
if (!swke) {
    var q = /q=([^&#=]*)/.exec(window.location.search)[1];
    var body = document.getElementsByTagName("body")[0];
    var kagi = document.createElement("div");
    var link = document.createElement("a");
    link.href = "https://kagi.com/search?q=" + q;
    link.innerHTML = "Search with Kagi";
    kagi.appendChild(link);
    kagi.style.background = "yellow";
    kagi.style.textAlign = "center";
    kagi.style.padding = "10px";
    kagi.id = "searchWithKagi";
    body.insertBefore(kagi, body.firstChild);
}

You should be good to go now.