سؤال

I am trying to get the multi-parameter search working in Firefox.

This requires the use of Javascript code from here.

I have been trying to understand the code and to get it to work for the Maven Central Repository search. This is a sample search I am trying to perform via a keyword search. After replacing the ###INSERT YOUR KEYWORD SEARCH URL HERE### with my search URL : http://search.maven.org/#search|ga|1|g%3A%s%20a%3A%s I get the following bookmarklet code :

javascript:var%C2%A0s='%s';%20url='http://search.maven.org/#search|ga|1|g%3A%s%20a%3A%s';%20t='';%20qc=0;%20chunks=url.split('%s');%20for(i=0;%20i<s.length;%20i++){if(s.charAt(i)=='"')qc=qc^1;%20t+=((s.charAt(i)=='%20'&&qc)?'^':s.charAt(i));%20}args=t.split(/\s/);%20nurl='';%20for(i=0;%20i<chunks.length;%20i++){nurl+=chunks[i];%20if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,'%20');%20nurl+=args[i];%20}}location.replace(nurl,'<%20BR>');

But unfortunately, that does not seem to work. I have tried to debug the beautified, un-encoded code in Firebug but I cannot wrap my head around what it does :

var s = '%s';
url = 'http://search.maven.org/#search|ga|1|g:%s a:%s';
t = '';
qc = 0;
chunks = url.split('%s');
for (i = 0; i < s.length; i++) {
    if (s.charAt(i) == '"') qc = qc ^ 1;
    t += ((s.charAt(i) == ' ' && qc) ? '^' : s.charAt(i));
}
args = t.split(/\s/);
nurl = '';
for (i = 0; i < chunks.length; i++) {
    nurl += chunks[i];
    if (args[i] != undefined) {
        args[i] = args[i].replace(/\^/g, ' ');
        nurl += args[i];
    }
}
location.replace(nurl, '< BR>');

It seems that the apparent complexity of my search URL upsets the above bookmarklet. The bug 124237 referred to in the mozillaZine KB article also has a bookmarklet generator which generates the exact same code as above.

It would be great if I could get hints on what might be going wrong.

Thanks!

هل كانت مفيدة؟

المحلول

I think the problem is that newer versions of Firefox don't allow code to be executed from the location bar. Code executed from bookmarklets works, but the keyword substitution places the javascript url in the location bar (and nothing happens).

نصائح أخرى

These days I was wondering why my multi-parameter keyword searches were not working anymore. Then I figured out that they just don't work on a blank / new tab: https://superuser.com/questions/382631/multiple-parameter-keyword-searches-in-firefox-or-chrome#comment618307_396619

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top