Greasy Fork is available in English.

Kagi Search Token Enabler

Enables Kagi.com Search token with personalized user settings

// ==UserScript==
// @name         Kagi Search Token Enabler
// @namespace    https://violentmonkey.github.io/
// @version      1.0
// @description  Enables Kagi.com Search token with personalized user settings
// @author       Streampunk
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAR7UlEQVR4nO2deZRU1Z3HP/d1N70BDcrS1WyKoIIGjWtGk5hEVBCK4yQOI6LmzCSiCIKCgivI5i6KOAjRRJ1xSTBopHAZF3TEDY1RAgIKKmtXgwgIdje9VN/549GydfVS9e677926n3PqNFS997vf5ny5dd9dfj+Bz0iJIBa5BME4pDgSIVshRDZSZgGO33osnlCHEAmkrEWKaoT8GslMovEnhUD6KUSobkDOJ4u84hkIMQzorro9SyDZADxNZfwWMZSEyoaUGVouKh6JFFOAjqrasISSb5DcLobEH1AR3FNDSxDESh4EOdrLuBZjeZRofITAu2GJJ4aWEocXI9OQ3ORFPEuGIZhBRXyyF8ORtA0tX4icgsNH6caxWHCyfiIGbVqaToi0DC1jkU+BE9KJYbEcxGoRjfdJ9eaUDC3nd80nP7EDyE21YYulEapondtO/HLdnpbe2OJ5X7mweCAFiXKsmS3qyKW8qkLGOkdbemOLDC1jxRMQ4iWk+vlrS4YjEeAslIuKJ7bktmYbWi4smQLirpYrs1jSQIo7ZaxkanMvb1ZPKxcWX4cQ96SuymJJFzlRRMvubuqqJg0tXyoeSEK85I0oiyUNBAPE4Pj/Nn5JI8g3j8ijvKrCjpktgUAgcQrzxflrq5Jd0vgY+vuqndbMlsAgESTKv2vskqSGlrHICuzUnCV45MpYybJkHzZoaPl88WnAccokWSxpIfvJWPFpDX1yyHBCzieL/EitelEWS5pUxrMP3tB0aA+dH5nmmyCLJR0KIlMOfuuAHtrdzxyp80+RxZIm0biz/37qA3voWGSO74IslnSIlcze/68H9tCxiK8HGi0WLxDR+A8+/qGHlgtLrtYjx2JJDxkr/uHIn9j3ZmQr9kCrM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bDCXhAAhBHWCzJIeENnnw3gz17azc5FbxCgFbxFAScMDmJGHQFhXz6dERLv6p+nbufkF9G+kjp9f/6QdDi2jpQ3rEWFLl3svUpiloX+huKQg6Ilr2g3cP/OcQYo7vaixpcfswb+O1K4DLz4bSP8Bn98P1Q7yN7z3igI74kP1pmTQnbQpdrkhvwSg7C0adBxMv8E6Tb0Tjjtjv+fjQLyxhx9Jh47nrWn6PEDDpQvjiQdjwcEjNjJgmDprsObSHtlN4oeSYsU2XjnYE3DYUfnO6m/gy9Oydqtv/rQa3xMuFxacixIf+qLJ4QdlOOGnCoe/n5cC4wfAfv4TCPP91KUPK08SQso8OfjvpGQ8ZiywHjlcqyuIpP78V1m5xH+wu+blrZD9KeWhgmYjGT2zog0YPLclYZA8QgokbC+w7vW34oeEqEY0n/a5pfBbz68IihPIVVotHOMJwMwskWYVFjV3SqKHFmLVVSOccb1VZLCkixQBx/tpGM/M1uc4kopvfQMgUJoYsFi+RE0S09NWmrmrWwqkYXHYfiCnpi7JYUkCKqSJa1qwzNC0acclFxdchRRgP51hCi5woomV3N/fqFj9CyEWR84CXkS2/12JpNgKJEOeJQaWvtey2FJDz+7Yif8cu7JSeRQ1VZBUWNfUA2BBp9bIyFvkEaHCC22JJCckKMST+o1RvT2s3rYjGf4zAZmm2eIQ8PR0zgwfpdMXg+McMjmeBmJZuLEuGIsRUKuPZIlqW9v4hzx/sZKxkNsjRXse1GMlcEY2P9DKgspkKGYtciWQKgk6q2rCEki3AHSIan6UiuPKpNzmfLAoiU4HhSHqobs8SSNYjeYpo/Na9GQaU4ftcsptLr2QYQl5LneyNEK0QIhspszCgREaGUocQCaSsRcpqHLEGKe5ncOkzwufNbf8PgNerF6010iEAAAAASUVORK5CYII=
// @match        https://kagi.com/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

// Set your Kagi Search token here with personalized user settings
   var token = 'XXXXXXXXXX-your_token-XXXXXXXXXX';

// Set the custom settings value as activated for the script to work properly
   var user_settings = 'activated';

// A Function to Set a Cookie
function setCookie(cName, cValue) {
  const domain = "domain=kagi.com";
  document.cookie = cName + "=" + cValue + ";" + domain + ";";
}

// A Function to Get a Cookie
function getCookie(cName) {
  let Name = cName + "=";
  let ca = document.cookie.split(';');
  for(let i = 0; i < ca.length; i++) {
    let c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(Name) == 0) {
      return c.substring(Name.length, c.length);
    }
  }
  return "";
}

// A Function that Checks if a Cookie is set
function checkCookie() {
  let user = getCookie("user_settings");
  if (user != "") {
 // Remember to open the console (Press F12)
    console.error("Сookies with custom user settings are set!");
  } else {
 // Apply setCookie
    setCookie('kagi_session', token);
    setCookie('user_settings', user_settings);
    location.reload();
  }
}

// Check if Сookies are set and if not, set a Сookie with a user token
checkCookie();