Add links to Google

By JoeSimmons Last update Sep 18, 2008 — Installed 311 times.

There are 2 previous versions of this script.

// ==UserScript==
// @name           Add links to Google
// @namespace      addlinkstogoogle
// @description    Adds links to Google
// @include        http://www.google.com/*
// @copyright      JoeSimmons
// ==/UserScript==

function id(ID) {
if(ID) { return document.getElementById(ID); }
else { return false; }
}

// Syntax: addLink('link text', 'link href', 'class', 'target', 'id of node');
function addLink(arg1, arg2, arg3, arg4, arg5) {
if(arg1 && arg2) {
var n, a;
n=(arg5)?id(arg5):id('gbar');
a = document.createElement('a');
// Make the 1st argument the link text
if(arg1) {a.appendChild(document.createTextNode(arg1));}
// Make the 2nd argument the link href
if(arg2) {a.href = arg2;}
// Make the 3rd argument the link's class
if(arg3) {a.setAttribute('class', arg3);}
// Make the 4th argument the link's target
if(arg4) {a.setAttribute('target', arg4);}
// Add it to the variable gbar
n.appendChild(document.createTextNode(' '));
n.appendChild(a);
}
}



// ADD THE LINKS HERE
addLink('YouTube', 'http://www.youtube.com/', 'gb1', '_blank', 'gbar');
// ADD THE LINKS HERE