Click to Search

Adds a clickable button to SE search

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

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 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.

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

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!)

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.

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

// ==UserScript==
// @name           Click to Search
// @author         Cameron Bernhardt (AstroCB)
// @version       3.0.1
// @namespace      http://github.com/AstroCB
// @description Adds a clickable button to SE search
// @include        http://*.stackexchange.com/*
// @include        http://stackoverflow.com/*
// @include        http://meta.stackoverflow.com/*
// @include        http://serverfault.com/*
// @include        http://meta.serverfault.com/*
// @include        http://superuser.com/*
// @include        http://meta.superuser.com/*
// @include        http://askubuntu.com/*
// @include        http://meta.askubuntu.com/*
// @include        http://stackapps.com/*
// ==/UserScript==
if (localStorage) {
	if (!localStorage.hasAsked) {
		var button = prompt("Would you like the search button to be a link (like the review and help links) or a button (like the 'Post Your Answer' button)? (type \"button\" or \"link\" without the quotes)").toLowerCase();
		localStorage.hasAsked = "true";
		if (button === "button") {
			localStorage.preference = "button";
		} else {
			localStorage.preference = "link";
		}
		window.location.reload();
	} else {
		var either = localStorage.preference;
		var reset = document.createElement("a");
		reset.setAttribute("href", "#");
		reset.setAttribute("onclick", "localStorage.removeItem('hasAsked'); alert('Your search button preferences have been reset. Click OK to reset the page and enter your new preferences.'); window.location.reload();");
		reset.textContent = "reset";
		document.getElementsByClassName("top-footer-links")[0].insertBefore(reset, document.getElementsByClassName("top-footer-links")[0].children[0]);

		document.getElementById("search").children[0].placeholder = "";

		if (either === "button") {
			button();
		} else {
			link();
		}
	}
} else {
	link();
}

function link() {
	var div = document.createElement("div");
	var span = document.createElement("span");
	var link = document.createElement("a");

	div.setAttribute("class", "links-container");
	span.setAttribute("class", "topbar-menu-links");
	link.setAttribute("href", "#");
	link.setAttribute("onclick", "document.getElementById('search').submit();");
	link.textContent = "search";

	div.appendChild(span);
	span.appendChild(link);

	document.getElementById("search").appendChild(div);
}

function button() {
	var button = document.createElement("input");
	button.setAttribute("type", "submit");
	button.setAttribute("value", "search");
	document.getElementById("search").appendChild(button);
}