Extra caution is recommended when installing recently uploaded/updated scripts (read more)
Be sure you trust any scripts you install

LookItUp

Quickly look something up in wikipedia, a dictionary or whatever you like (its easy to add custom sites!). The result is displayed directly on the page.

Note: I published a new script called LookItUp2

I will give it a week or so, before I let the autoupdate inform about the update (so potential bugs won't hurt too many people)

Description

You select a word, and it will be looked up immediately. Which dictionary is selected depends on customizable keystrokes

Screenshot of settings:

Quick Start

1. Install the script.
2. Try it out, by selecting some text, and pressing "w".
3. Wikipedia will open in the right side of the page.
4. While the text is still hightlighted, press "v", and the text will now be looked up in Wictionary
5. While the text is still hightlighted, press "?", and you will see a popup with a textarea showing the highlighted word, and a button for each site. Click on a button to look the word up in that engine
6. Click on the page, or press Esc key to make the popups go away
7. Customize the script by pressing '#' while some text is hightlighted

There are different ways a lookup can be triggered:
SELECT: The lookup will be performed immidiately when a text is selected
SHIFT-SELECT,ALT-SELECT and CTRL-SELECT: Like SELECT, but only when SHIFT/ALT/CTRL key is hold down.
And finally, by pressing a custom key while there is a selection.

Extra features

Pressing '?' while text is highlighted displays a search menu. From this menu you can enter a word (the highlighted word is shown per default), and select which site you want to look the word(s) up in. Pressing '!' while text is hightlighted temporarily sets the SELECT action to the last action. This is usefull if you are on a page where the text is hard to understand, and you want to look up a lot of words quickly.

Example:
- Select some text
- press 'w' to look it up in wikipedia
- press '!' to temporarily make wikipedia your quick-lookup engine
- Select some text.
- The text will be looked up immediately when its selected. The assignment is not saved. It only lasts while on page.

Pressing Esc key closes the boxes

Pressing 'q' while text is highlighted disables the script

Example: Adding custom site (GET)

- Decide which site you want to add. In this example, we will add a google image search
- Make a search for "words", and copy the address line.
- Open settings, by selecting something and pressing "#"
- Click "Add site"
- In the first column, you freely choose a proper name. Ie "Images - google"
- In the next column, you paste the address line from the search: http://images.google.com/images?svnum=10&hl=en&...
- Now, find the place in the url where it says "words", and replace it with "[words]"
- It will now be: http://images.google.com/images?svnum=10&hl=en&...
- Choose a shortcut that makes sence to you. Ie "i" for "images". Make sure that there are no other sites that uses this shortcut.
- Choose a style. You have to enter the exact name of a style (these a defined below). The predefined styles are "narrowbar" and "widebar". I choose "widebar".
- Click "Save"

Adding custom site (POST)

Most search forms puts all the options in the url (GET), but some does not. Even though a form uses POST, the engine might accept GET requests anyway. In this case, I recommend the post-interceptor script for easily seeing what is posted: http://www.oreilly.com/pub/h/4132

V1.4 features

- Multiple search results can be displayed at once by assigning same shortcut key
- You can open the first n sites in a grid, by pressing a number key, while text is selected
- Added cleanup features, so cleanup instructions can be placed in the url
- Changed default site url's, so they use the new cleanup features
- Added "merge default sites into sites" feature, so you can easily use those new urls, without loosing your own site definitions
- Changed encoding of urls

Note: Its still possible to use separate cleanup scripts, but beware that you dont have an old cleanup script running while using these new urls. It will fail misserably

Quick v1.4 tour

1. Go to settings, click "merge default sites into sites", and click "Save". The urls are now magic: The search results are cleaned up
2. Select some text and click "3". Then click "4". Then click "8".

Multiple search results can be displayed at once

- If you assign the same key to several sites, they will all be opened.
- Number keys open the first n sites in a grid

Grouping sites, by assigning the same key:
Be aware that the sites will overlap, if they use the same style. You will have to make new style definitions.
Example of usage: I have three dictionaries assigned the same key. I copied the "widebar" style into 3 styles, and named them "1of3", "2of3" and "3of3". I then changed the height and top attributes of all of them:
1of3: width:672px;height:33%;top:0%;...
2of3: width:672px;height:33%;top:33%;...
3of3: width:672px;height:34%;top:66%;...

Number keys open the first n sites in a grid:
Try pressing '3' while text is selected. The first 3 search engines will open. Now, try pressing '4'. Another search engine will open, leaving the first 3. Now, press '5'. I find that moving up the numbers this way, starting from '1' is a quite effective: You can read the previous, while the new one is loading. The ordering is ofcourse important. It should match your preferences. You can order the sites by clicking the new "move up" buttons in settings.

Cleanup features

The major change from between 1.3 and 1.4 is that its no longer neccessary to build separate cleanup scripts. Cleanup instructions can be appended to the urls. Thanks to alien_scum for this idea, and his "xStripper" script. Note: You don't actually have to read more about the cleanup features, unless you want to write cleanup scripts yourself. Several ways to clean up are implemented:

xcrop: Selects nodes to keep, using xpath (this is what xStripper does)
xremove: Selects nodes to destroy, using xpath
css: Applies css to the document
eval: Run any script.
replace: Replace content using regexp
crop: Select content between two strings in the sourcecode (in the innerHTML)

The actions can be combined. They will be performed in the order that they appear in the url. Its possible to have the same type of action multiple times

Notes:
  • Some sites respond to extra params in a bad way (ie freedictionary: It tries to look up all words passed as params). To handle this, I expanded the syntax: the url is scanned for "lookitup". The character that follows this string is choosen as the command separator. Usually the separator is "&", but I have given you the option to redefine this. This syntax could also come handi if need to use "&"'s in the command values. Example: http://www.thefreedictionary.com/dict.asp?Word=...') (note: this feature was not in the original version of this beta)

  • The actions are only triggered if the url contains "lookitup". Reason: the script runs on *, so it should be able to quickly decide if it should spent time examining the parameters - and some sites might use the same parameter names, which would have unintentional effects.

  • I would appreciate tips on new urls. Also without cleanup.

xcrop

Selects the specified nodes, and deletes the rest. The code is taken from xStripper. The only difference is that I don't wrap each node in a div.
Note: I can highly recommend the XPath Checker plugin for creating xpath expressions.
Example: Selecting images and inputs: http://www.google.com/webhp?lookitup&xcrop=//im...
LookItUp Example: Selecting all unordered lists in google define: http://www.google.com/search?lookitup&q=define:...

xremove

Removes all nodes that are specified by the xpath.
Example: Removing the 4'th button on google (I don't feel lucky) http://www.google.com/webhp?lookitup&xremove=//...]
LookItUp Example: Removing the footer in wictionary: http://en.wiktionary.org/w/index.php?lookitup&t...

css

Applies css to the document

Examples:
Setting the background color and input height of google. css=body{background-color:yellow}input{height:200px;margin:10px}
LookItUp Examples:
Hiding the footer in wikipedia

eval

Allows you to run any script you want.
Example: Saying hi: eval=alert('hi')
LookItUp example: Adding "Next" button to google define - such that the new page is also clean: url

replace

Replaces text, using regexp. It takes 3 arguments: Search-string, modifiers and replace-string. They are separated with this character: "|". If you skip the modifiers, they default to "gi".
Examples:
Giving a new meaning to an article: replace=superman|Bill Gates&replace=DC Comics|Microsoft
Removing the "From Wikipedia, the free encyclopedia" tagline from wikipedia articles: replace=From.*pedia|

crop

Crops the document. The action takes two parameters: Text that identifies where the crop should begin, and text that identifies where it should end. The first is included, the second is not. It also takes two additional optional arguments, that allow you to adjust the positions. This "crop" feature is maybe a little dogdy. There is for example a problem: The text is taken from documen.body.innerHTML - but this is actually not the same as document source, and I think its browser dependent. Note: in most cases you can use xcrop instead, by using the "following-sibling" and/or "preceding-sibling" axis (example here)
LookItUp Example: Getting the content between the to horizontal rulers in Chambers:
url

Note: The content is shown in an iframe. This means that its also possible to create a dedicated userscript for a resultpage. I only recommend doing that if the cleanup is very complicated, which it appears that it never is. The cleanup features of lookitup are very powerful, and will usually be sufficient.

Other changes:

Encoding changed:
The whole url was encoded with encodeURI. Now I only encode the selected words, and its encoded using "escape" instead. encodeURI was encoding danish letters wrong. Ie: 'å' is %E5, but encodeURI encodes it as %C3%A5. I only encode the words now, because I experienced a case where the encoding had a negative effect. If you want the url encoded, simply enter the encoded url. If not, then don't. Now the choice is yours. There are online url-encoders available here and here

Added "merge default sites into sites" feature:
The default sites are examined. If you already have a site with the same name as the default site, then the url is changed to that of the default site. If you don't, then the default site will be added to your sites. The changes does not take effect until you press "save". Note: Make sure that the styles of the sites that are added exists (Note to self: Maybe nonexistant styles should be added automatically?)

Note for danish users

Here are some usefull urls (including cleanup):
Sprogteknologisk ordbase: url
Retskrivningsordbogen (New url, because they changed their url): url
Ideomordbogen: url
Engelsk - Dansk: url

Features under consideration

Feedback on these ideas will be appreciated
- Automatic update of default site urls.
- Possibility to load site definitions. (Ie danish sites)
- A way to open grouped sites one by one (for example by clicking the assigned key multiple times)
- Assign several shortcuts to one site (not sure if this is useful: If you want several shortcuts, its probably because you want it in a group - which means the style should be changed anyway)
- Splitting sites and shortcuts: Sites: (name and url), Shortcuts: ref to sitename, shortcut and ref to style
- Groups: A group could be a commaseparated list of site names, a shortcut and... maybe list of stylenames, or maybe they should be layed out using the same scheme as with the number-keys
- Separating the settings into another script that are loaded and evaluated on demand. Purpose: To make the script smaller. Not sure if its worth it, though. Should first examine if there is a performance gain at all.

Version history

09 MAY 2007 - V1.4.4 crop now takes two additional arguments that allows adjusting the positions
08 MAY 2007 - V1.4.3 added exclude on gmail editor, and fixed bug on "?" feature
07 MAY 2007 - V1.4.2 Added "1of3", "2of3" and "3of4" styles (but they will only show up for new users, because i have not made a "merge styles" feature). Changed "!", so it works better with multiple sites
06 MAY 2007 - V1.4.1 Fixed autoupdate, so it doesn't increase install counter
05 MAY 2007 - V1.4 Added cleanup features and support for opening multiple sites
17 MAR 2007 - V1.3 Fix: If ctrl or alt is hold down while a key is pressed, no site will be opened... anymore.
17 MAR 2007 - V1.2 Added '?', '!', 'q', '#' and Ecs key functions. urls are encoded using encodeURI.
28 FEB 2007 - V1.1 Oops. The "Save button" was not available on small screens. There are now scrollbars.
28 FEB 2007 - V1.0 Created

Credits

I started out with the "QuickiWiki" script by Tarmle (http://www.ruinsofmorning.net/greasemonkey/)



Jun 16, 2008
Ryuji5864 User

I love this script, but I wish I could use the search feature without having to highlight text.

 
Nov 27, 2007
Joseph Urban User

Bjørn, is there a way in which one could copy, clip what information one retrieves? For example using a program such as Evernote or Surfulater, or simply selecting the area one wishes to copy, etc...?

I've just started using LookItUp2 the other day. Like it lots! :-)

Thanks for your time,

Joseph

 
Sep 14, 2007
Volkan User

Hey Bjørn,

I noticed that the cleanup features are not working. When I try to use xcrop in my urls, or click on the links you placed above, the pages show up in the usual way. Not cleaned up like I expect them to. Although, I am using Lookitup2, but I don't think that makes much of a difference, because they're basically the same script. How can I fix this issue?

 
Sep 13, 2007
brasilius Scriptwright

thanx for a great script
it really makes browsing very comfort
решение задач

 
Jul 31, 2007
m.clizzle User

can you tell me where the file is located (winxp) that contains all the websites and keep mappings. I have set my computer up the way i want, and now need to implement to other computers. I would like to do this without rewriting all the entries.

Thank you for the great script.

 
Jun 29, 2007
Bjørn Rosell Script's author

Hi katelin,

This script does not work in IE7Pro.
Fortunately, someone has made a version that works in IE7Pro. Its available here: http://userscripts.org/scripts/show/8439

 
Jun 29, 2007
katelin User

Hello I've installed it to IE7 pro. It doesn't react for pressing ? or # . ( SHIFT + . and ALTGR or ALT + CTRL + x ). Maybe a one key shortkey would work. But I can't do any settings. And I would like a right click menu and that the "popup" dictionary to be not just at the top of the page, because when I'm for example at the bottom I have to srcoll to it.I'm not good at srcipting. I'm just asking maybe you could help.

 
Jun 24, 2007
Bjørn Rosell Script's author

The autoupdate is fixed. It was due to a change on userscripts.org: http://userscripts.org/forums/3/topics/622?page...

 
Jun 23, 2007
Mio20 User

Thank you Bjorn Rosell for an excellent script.
The only thing missing from LookItUp2 that functioned in LookItUp is the pronunciation speaker on theFreeDictionary no longer works however Merriam Webster pronunciation does except that it opens a new tab. I use your script daily.

 
Jun 22, 2007
billybob Scriptwright

Nevermind - it's uninstalled.

 
Jun 22, 2007
billybob Scriptwright

Okay - I'm getting "new version" available for this script like every 10 minutes. What gives?

 
Jun 3, 2007
Bjørn Rosell Script's author

Hi geweiyi,

Thanks for your input. I used to use encodeURI, but it was encoding danish letters wrong. Ie: 'å' is %E5, but encodeURI encodes it as %C3%A5. So, I don't want to simply go back to encodeURI. I guess a different approach is called for, but not sure which. The problem needs to be researched first. One solution could be to make a hybrid - ie use encodeURI, but fix the output. Another solution could be to let the encoding be configurable - maybe on each url.

 
Jun 1, 2007
geweiyi User

Hi
Your script is very useful,thanks.
But I think keywords in google's search are encoded by encodeURI() not encode().So it doesn't work well with non-English users. You can have a look at your code at line 518.

 
May 18, 2007
Bjørn Rosell Script's author

Hi Chad,
Thanks for your input. I think its a great idea with a search box on each frame. I also agree that it would be better if the searchbox could be opened without having to select text. I guess there is material here for a new update :). I don't expect it to be in the nearest future, though. The weather is too perfect in DK right now... :)

 
May 14, 2007
Chad-) User

Wonderful update esp. the clean-up features.

I like the "groups" idea: a list of sites with its own shortcut key, arranged in a grid.

Assigning the same key to diff sites & creating separate styles for them is just too cumbersome. Using the number keys to open the first 'n' styles requires you to set & remember the order of diff sites. Besides what if I want to open only the 4th, 6th & 8th sites? The "groups" idea would solve these problems.

And here's an idea for a slightly diff design incorporating a search box in the main frame:

http://royalcheetah.googlepages.com/lookitup_mo...

 
May 12, 2007
Bjørn Rosell Script's author

Hi parellel lines.
The reason is that I don't want to bug users with minor changes. The autoupdate works, but doesn't take effect because I don't change the version number in the script when I make the minor updates.

 
May 10, 2007
parallel lines Scriptwright

this script keeps updating but not auto updating. what gives?

 
May 8, 2007
Naja Melan Scriptwright

Hi,

it is lovely...

I also get interference when typing in gmail though...

cheers

 
May 6, 2007
znerp Scriptwright

It doesn't really bother me most of the time, just when using the userscripts top scripts table. I don't tend to look at the 'ever' table much, so it's mostly the 'day' and 'week' ones that it kinda bugs me on. So yeah, if you've fixed that, it ought to start decreasing that number relatively soon. Thanks!

 
May 6, 2007
Bjørn Rosell Script's author

hi znerp,
Thanks for letting me know. It was a slip-up. Its corrected now. I know its a little late, because most people probably installed v1.4 by now. Anyway, there is no way to reset the counter, so I guess its not so important now. The counter is already obscenely high. If I make a new script, it will have the bad effect that people will loose their settings :( - And bookmarks will have to be updated... Well well... I could perhaps ask the guys at userscript.org to reset the counter when i publish the next release

 
May 6, 2007
znerp Scriptwright

Hey, I quite like this script, although I noticed on this update that you've not fixed the xmlhttprequest to load the location that won't inflate the install count. Other than that small gripe, keep up the good work!

 
Apr 19, 2007
Stephen Paul... Scriptwright

Hello :)
I would like to use some of the code from this script in a Wordpress pluign. Please advise as to whether that would be legal, possible to make legal, and what implications that would have for the licensing on the plugin.

Please contact me: project (at$ singpolyma.net

 
Apr 15, 2007
Bjørn Rosell Script's author

There is a new beta available here: http://userscripts.org/scripts/show/8527. I would appreciate suggestions and comments. alien_scum: Yep, i noticed the counter was rocketing, but didn't know what to do about it. Thanks for the tip.

 
Apr 15, 2007
alien_scum Scriptwright

Sweet I think that it's great that you include xcrop and I like the idea of adding CSS, and javascript as well. Keep up the good work dude!

BTW, your auto update feature is artificially inflating you install count, try looking it up using the view sourec link at
http://userscripts.org/scripts/source/7715
instead of the install
http://userscripts.org/scripts/source/7715.user.js

 
Apr 7, 2007
alien_scum Scriptwright

This is brilliant script, but it lacks a way to clean up the definition pages so I created xStripper
which can clean any site and has examples for The Free Dictionary and Google's define

You could comment on this script if you were logged in.