Greasy Fork 还支持 简体中文。

Search Selected text on Google with Ctrl+Q shortcut

Simple script to search google for results of a selected text with shortcut or hotkey Ctrl+Q (like ctrl+query). The mechanism is the same as the "Search Google for ..." in the right click menu

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           Search Selected text on Google with Ctrl+Q shortcut
// @copyright      2021 - Balazs Zubak
// @description    Simple script to search google for results of a selected text with shortcut or hotkey Ctrl+Q (like ctrl+query). The mechanism is the same as the "Search Google for ..." in the right click menu
// @version        1.2
// @namespace      *
// @include        *
// @website	       https://greasyfork.org/en/scripts/428030-search-selected-text-on-google-with-ctrl-q-shortcut
// ==/UserScript==

document.addEventListener("keyup", function(e){
    // get selected text
    var seltext = getSelectedText();
    if(seltext && e.code == "KeyQ" && e.ctrlKey)
    {
        window.open('http://www.google.co.in/search?hl=en&q='+seltext , '_blank');
    }
});

function getSelectedText()
{
	// For Firefox, Safari and other non-IE browsers
	if(window.getSelection)
    {
		return window.getSelection();
    }
	else if(document.getSelection)
    {
		return document.getSelection();
    }
	else
	{
		// For IE
		var selection = document.selection && document.selection.createRange();
		if(selection.text)
        {
			return selection.text;
        }
		return false;
	}
	return false;
}