Anyone write java? Can someone please make me a bookmarklet (simple) PLEASE :-)?

Ok, I can't write java, and i would like a bookmarklet to do a simple task.

I want it to amend the URL of the current page and refresh it.

Basically, it's to add my University E-Proxy to a URL, so i can quickly access a journal.

E.g.

Original URL is: http://www.nature.com/nature/journal/vaop/ncurrent...

Changes to: http://www.nature.com.ezproxy4.lib.le.ac.uk/nature...

Notice, ".ezproxy4.lib.le.ac.uk" is added after the root website.

It should then forward to a login page.

I would like a bookmarklet to add this automatically for me please.

This would be really helpful thanks!

Update:

Ok, it shortened the website.

it's basically (without the spaces):

www. nature. com.ezproxy4.lib. le.ac.uk /nature/journal/vaop/ncurrent/full/ nature 11729.html

Update 2:

Ok, i did this and it worked.

javascript:void(location.href=%22http://ezproxy4.lib.le.ac.uk/login?url=%22+locatio...

1 Answer

Relevance
  • 8 years ago
    Favorite Answer

    A bookmarklet is written in Javascript, not Java.

    Furthermore, it's not the right way to do this. A bookmarklet requires you to call it each time you want it to run. What you want is called a 'user script', that is to say, a Javascript program that runs automatically when you open the page.

    If you copy this code:

    // ==UserScript==

    // @name URL switcher

    // @author green_meklar

    // @include http://www.nature.com*

    // ==/UserScript==

    function switcher_check()

    {

    var url=document.URL;

    if(url.indexOf("ezproxy4.lib.le.ac.uk")<0)

    {

    window.location=url.replace( "www.nature.com", "www.nature.com.ezproxy4.lib.le.ac.uk" );

    }

    }

    switcher_check();

    and put it in a file ending in '.user.js', and open that file with your browser (with user script support), it should prompt you to install the user script. When the script is installed, it should perform the redirect as you wanted.

    If your browser doesn't support user scripts and has no extensions for making them work, then I can't really help you.

    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.