Search Kongregate Forum

Adds Forum & Thread-Specific Searching

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           Search Kongregate Forum
// @namespace      http://userscripts.org/user100
// @include        http://www.kongregate.com/forums/*
// @version 0.0.1.20160306135440
// @description Adds Forum & Thread-Specific Searching
// ==/UserScript==

addSearchBox();
changeTarget(document.body);
document.addEventListener("DOMNodeInserted",function(e){changeTarget(e.target);},false);

function addSearchBox()
{
	var form=document.createElement("form");
	form.id="search";
	form.method="GET";
	form.target="_blank";
	form.action="http://www.google.com/search";
	form.setAttribute("style","border:1px solid black;padding:1px;");
	form.innerHTML="<dl><dt><input type='text' name='q' tabindex='1' class='hintable' style='font-size:11px;'/><input type='hidden' name='as_q' value='site:"+location.host+location.pathname+"' /><input type='hidden' name='num' value='100'/><input type='hidden' name='newwindow' value='1'/></dt><dd><input type='submit' value='Search' tabindex='2' class='spritesite'/></dd></dl>";
	var el=document.getElementById("sidebar");
	el.insertBefore(form,el.firstChild);
}

function changeTarget(container)
{
	var text=location.host+location.pathname;
	Array.forEach(container.getElementsByTagName("a"),function(l){if (l.href.indexOf(text)!=-1) l.target="_blank";});
}