Advanced Google Keys by N-Dream

By N-Dream Last update Aug 25, 2008 — Installed 19,191 times.

fix some small problems

in
Subscribe to fix some small problems 4 posts, 1 voice



dangoakachan Scriptwright
FirefoxWindows

This is a really good script, I like it very much. After reading the code carefully, howerver, I find some small problems, so I write here to share with all.

oh.. my english is not well enough..

First, in the replaceSelect() function

// find space position
for(i=0;i<value>
//FIX
if(value.charAt(i)==" " && value.charAt(i+1)!=" ") {
space[cspace++]=i;
}

in the if statement i add "value.charAt(i+1)!= """, so it will ignore continuous spaces between two search keywords, like "this is a test".

if you do not adding this , when press "r" to switch into replace mode and use left or right allow to move between spaces, it will not work correctly when there are more than one spaces.

2.

 
dangoakachan Scriptwright
FirefoxWindows

oh no , I can't edit the post..

Second, that's using j or k to browser results.
the former code is as below

    if(activeResult==-1) {
        activeResult=0;
    } else if (activeResult==results.length){
        return
    }else{
        activeResult++			
    }

    activateResult();

the code is not right, when i browser to the last result, and I still press j, there is an error in the "Error Console" in firefox , which shows "results[activeResult] is undefined".
If you look through these codes more carefully, you should find there is a problem in the if-else-if statement, when the variable activeResult is equal to "results.length-1", it will still do "activeResults++", and then activeResults is now "results.length", but the results array do not have results[results.length];

So i make some changes on the above code, and now it work correctory, and if you still press j when browser to the last result, it will go forhead to the first result, vice versa.

    // select the next result
    if(e.keyCode==40||e.keyCode==74) {//down / j
        e.preventDefault()
        e.stopPropagation()

        //FIXME
        if(activeResult==-1 || activeResult>=results.length-1) {
            activeResult=0;
        } else {
            activeResult++;			
        }

        activateResult();
    }

    // select the previous result
    if(e.keyCode==38||e.keyCode==75) {//up / k
        e.preventDefault()
        e.stopPropagation()

        //FIXME
        if(activeResult<=0) {
            activeResult=results.length-1;
        } else {
            activeResult--;
        }

        activateResult();
    }

 
dangoakachan Scriptwright
FirefoxWindows

Thirdly, the problem is about the "about" information in the top (near the navaigation)

    about=window.document.createElement("div");
    about.innerHTML="
<font> Advanced Google Keys active. Press (h) for advanced features.</font>
"; window.document.body.appendChild(about); about.style.position="absolute"; about.style.top= "0"; about.style.left="0"; about.style.width="100%"

The problem is , the "about" infomation is too wide , cover the other elements in the navigation.
And you will soon find you can't click the "link" like image(image.google.com) until you click it lower.

The simplist solution is to remove the "about" information. Another way is to modify the about style, change about.style.left, and remove the about.style.width

about.style.left= document.body.clientWidth/2- about.offsetWidth/2+"px";

 
dangoakachan Scriptwright
FirefoxWindows

also , i use DOMContentLoaded event instead of load, and remove the border when you select a result.

Where can i upload the modified script?

here:

http://pastebin.com/EZNC5a3R