[RESOLVED BY OP]Google site search bookmarklet does not work
Posted: Fri Nov 18, 2011 2:45 am
I have, in my bookmarks toolbar, a little Javascript bookmarklet that should do a Google site search for whatever domain is serving the web page in the currently active tab. Instead, it doesn't work at all on real sites, even ones where I have enabled all the Javascript coming from the web page's domain, such as this one. Instead, the page just flickers, like it's trying to load the search page, but it stays right where it is. In fact, testing it now, the only pages I can confirm it to work on are about:blank and about:config.
As a further oddness, it does something to the little NoScript icon in the toolbar (yes, I have a toolbar while running Firefox 7.0.1, thank you very much): The script, in case you don't want to read the source, will first check to see if you have any selected text in the active tab; if you do not, it pops up a little window to ask you what terms to search for. While this window is up, the NoScript icon has a little red exclamation point (!) next to the blue-on-white S, as opposed to the usual 'just the blue-on-white S' or red slashed circle.
Here is the source code:
I have gone to about:config and enabled noscript.allowBookmarks, noscript.allowURLBarImports, and noscript.allowURLBarJS. I'm currently right now running Firefox 7.0.1 from the Ubuntu repos, but this also happens (essentially) the same way on the current Firefox from the Beta update channel.
As a further oddness, it does something to the little NoScript icon in the toolbar (yes, I have a toolbar while running Firefox 7.0.1, thank you very much): The script, in case you don't want to read the source, will first check to see if you have any selected text in the active tab; if you do not, it pops up a little window to ask you what terms to search for. While this window is up, the NoScript icon has a little red exclamation point (!) next to the blue-on-white S, as opposed to the usual 'just the blue-on-white S' or red slashed circle.
Here is the source code:
Code: Select all
javascript:q%20=%20""%20+%20(window.getSelection%20?%20window.getSelection()%20:%20document.getSelection%20?%20document.getSelection()%20:%20document.selection.createRange().text);%20if%20(!q)%20q%20=%20prompt("You%20didn't%20select%20any%20text.%20%20Enter%20a%20search%20phrase:",%20"");%20if%20(q!=null)%20location=("http://www.google.com/search?num=100&q=site:"%20+%20escape(location.hostname)%20+%20"%20\""%20+%20escape(q.replace(/\"/g,""))%20+%20"\"").replace(/%20/g,%20"+");%20void%200