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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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;
}