Javascripts to help browsing Gentoo Wikis

From Gentoo Wiki
Jump to: navigation, search
Article status
Cross icon This article is marked for deletion by yngwin (talk | contribs).

Search two wikis

With the following html and firefox "smart keyword" (= keyword to specify search engine), you can search two Gentoo wikis at once.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text-html; charset=utf-8">
<!--
Description:
    Search two gentoo wikis, using firefox "smart keyword".
    For example, if you type "gw emerge" in the location bar,
    the word "emerge" will be searched for in the official wiki,
    and a new tab / window is opened and there, the old wiki is searched.

Usage:
    1. Save this file to /foo/bar/baz.html
    2. Make a new bookmark, URI being file:///foo/bar/baz.html?%s
    3. Add a keyword to this bookmark, say "gw"
    4. Done. Input in the location bar "gw words-you-want-to-search-for".

Author: Teika kazura
License: Donated to the Public Domain
ChangeLog:
    2012-08-05: Initial release.

-->
<script type="text/javascript">
function focusOnload(){
    // Rip off up to the first question mark
    var str=decodeURIComponent(location.search.replace(/^[^?]*\?/,""));

    // This only asks the browser to open in a new window.
    // JS can't choose if it's a new window or a tab; it's up to the
    // user's preference.
    window.open("http://en.gentoo-wiki.com/w/index.php?title=Special%3ASearch&search=" + str,'_blank'); // old gentoo wiki

    location.href = "https://wiki.gentoo.org/index.php?title=Special%3ASearch&search=" + str; // the official wiki
}
</script>
</head><body onload="focusOnload()">
</body></html>

No focus in the search result

In the search result page of the both Gentoo Wikis, the search terms field is focused. This is annoying if you manipulate the browser with the keyboard. The follwing GreaseMonkey script stops it.

GreaseMonkey is a firefox extension to add user scripts.

If you don't use https, then fix a line containing that phrase.

// ==UserScript==
// @license 	  Donated to the Public Domain
// @name          Cancel autofocus
// @namespace     https://gitorious.org/at-home-modifier
// @description   Some websites give automatically focus an input field on load. This script fixes it.
// @include       http://en.gentoo-wiki.com/w/index.php?title=Special*Search&search=*
// @include       https://wiki.gentoo.org/index.php?title=Special*Search&search=*
// ==/UserScript==

(function () {
    var i = document.getElementById("searchText");
    if(! i){
	return;
    }
    // This doesn't have any effect. Blur is correct.
    //  i.removeAttribute("autofocus");

    i.blur();

})();
Personal tools
Namespaces

Variants
Actions
Gentoo Websites logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Navigation
Toolbox
Categories