viernes, 19 de febrero de 2010

Google - moreplusplus - Scrip para greasemonkey

// ==UserScript==
// @author jazdian
// @version 1.0.0
// @namespace http://programadoresmx.blogspot.com/
// @description Google - Agrega un link al menu de google, con un submenu con links a paginas web reconocidas.
// @name moreplusplus
// @namespace http://programadoresmx.blogspot.com/
// @include http://www.google.tld/webhp?*
// @include http://www.google.tld/search?*
// @include http://www.google.tld/ig?*
// @include http://www.google.tld/
// @include http://www.google.tld/#*
// @include http://www.google.com*
// @include http://*.google.*
// @include https://*.google.*
// @include https://mail.google.com*
// ==/UserScript==

//alert('');
//Variable de posición X para colocar el menu en la posicion requerida
var PosX;
var PosY;

//acceder a el elemento Id 'gbar'
var MenuGoogle = document.getElementById('gbar');

var ElBody = document.getElementById('body');
ElBody.addEventListener("click", OcultarDiv, false);


//Función para mostrar el DIV con los links
function MostrarDiv() {
//alert(PosX);
EleDiv.style.left = PosX + "px";
EleDiv.style.top = PosY + 21 + "px";
EleDiv.style.right = "auto";
EleDiv.style.visibility = "visible";
}

function OcultarDiv() {
//alert(PosX);
EleDiv.style.left = PosX + "px";
EleDiv.style.top = PosY + 21 + "px";
EleDiv.style.right = "auto";
EleDiv.style.visibility = "hidden";
}

//Crear elemento
var a = document.createElement('A');
a.className = ('gb3');
a.setAttribute('aria-haspopup', true);
a.addEventListener("click", MostrarDiv, false);
a.style.marginLeft = "5px";
a.setAttribute('href', '#');



//Crear elemento u
var u = document.createElement('U');
var txtU = document.createTextNode('more');
u.appendChild(txtU);
u.style.marginRight = "5px";

a.appendChild(u);


//Crear elemento Small
var Small = document.createElement('SMALL');
var txtSmall = document.createTextNode('++');
Small.appendChild(txtSmall);

a.appendChild(Small);

MenuGoogle.firstChild.appendChild(a);

var EleDiv = document.createElement('DIV');
EleDiv.className = ('gbm');
EleDiv.style.backgroundColor = "#FE9A2E";

//******Obtener la posición del DIV**********
PosX = u.offsetLeft;
PosY = u.offsetTop;


var CrearLink = new Array();
var TextoLink = new Array();
//Para agregar las etiquetas del link
var VarEtiqueta = new Array('Yahoo Search', 'Bing', 'Ask', 'Altavista', 'Mooter', 'Clusty', 'Dogpile', 'Turbo10', 'Lycos',
                            '.....', 'Facebook', 'Twitter', 'Yahoo Answers', 'Hi5', 'MySpace', 'Orkut',
                            '.....', 'Yahoo', 'AOL');
//Para agregar la direccion url a la que va dirigida la etiqueta
var VarURL = new Array('http://www.search.yahoo.com/', 'http://www.bing.com/', 'http://www.ask.com/',
                    'http://www.altavista.com/', 'http://mooter.com/', 'http://clusty.com/',
                    'http://www.dogpile.com/', 'http://turbo10.com/', 'http://www.lycos.com/',
                    '#', 'http://www.facebook.com/', 'http://twitter.com/', 'http://answers.yahoo.com/',
                    'http://www.hi5.com/', 'http://www.myspace.com/', 'http://www.orkut.com/Main#Home',
                    '#', 'http://www.yahoo.com/', 'http://www.aol.com/');
//La cantidad de links

var i = VarEtiqueta.length - 1;

var x;
for (x = 0; x <= i; x++) {
    CrearLink[x] = document.createElement('A');
    TextoLink[x] = document.createTextNode(VarEtiqueta[x]);
    CrearLink[x].appendChild(TextoLink[x]);
    CrearLink[x].setAttribute('href', VarURL[x]);
    CrearLink[x].className = ('gb2');
    EleDiv.appendChild(CrearLink[x]);
}



//*********************************

MenuGoogle.firstChild.appendChild(EleDiv);

//*****************************

No hay comentarios:

Publicar un comentario