Keyboard Shortcuts to Startpage via Greasemonkey


Here’s a little script. It will let you hit CTRL-1 through 9 to load up whichever StartPage search result.

// ==UserScript==
// @name        Startpage Helper
// @namespace   10pm
// @include     https://www.startpage.com/do/*
// @version     1
// @grant       none
// @require     https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// ==/UserScript==

jQuery.noConflict();

(function($) {
  
  //console.log('$',$);
  
  $(document).on('keydown',function(e){
    d('e',e)
    if( e && e.ctrlKey && e.keyCode>=49 && e.keyCode<=57 ) {
      var i = e.keyCode-49; // 49 = 1
      // ctrl-shift-x
      if( e.shiftKey ) {
	      location.href= $('a.w-gl__result-title:eq('+i+')').get(0).href;
      } else {
	      $('a.w-gl__result-title:eq('+i+')').get(0).click();
      }
    }
  });
  
  $('a.w-gl__result-title').each(function(i,a){
    //$(a).append('<span style="border:solid #555 1px;background:#eee;border-radius:2px;font-size:.7em">CTRL-'+(i+1)+'</span>');
    var span = document.createElement('span');
    span.innerHTML='<span style="border:solid #555 1px;background:#eee;border-radius:3px;font-size:.7em;padding:0 2px;position:absolute;margin-left:-50px;margin-top:10px">CTRL-'+(i+1)+'</span>';
    a.parentNode.prepend(span)
  });
  
  function d(){try{console.log.apply(this, arguments);}catch(e){}}
})(jQuery);