Kagi redirection to Google for free tier

The script clicks the search on google button when the max free searches on kagi are reached.

  1. // ==UserScript==
  2. // @name Kagi redirection to Google for free tier
  3. // @namespace https://kagi.com/
  4. // @match https://kagi.com/?q=*
  5. // @description The script clicks the search on google button when the max free searches on kagi are reached.
  6. // @version 1.0
  7. // @noframes
  8. // @grant none
  9. // @license GNU GPLv3
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14. var googButton = document.querySelectorAll('form.search-form button[formaction*="google"]');
  15.  
  16. if(googButton.length != 1) {
  17. console.error('googButton is more than 1 selected element, ' + googButton.length);
  18.  
  19. if(googButton.length == 0) {
  20. throw 'No button found';
  21. }
  22. }
  23.  
  24. console.error('googButton is more than 1 selected element, ' + googButton.length);
  25. googButton[0].click();
  26. }());