2

Say I search for a book on Google Books and then click through to it. If I copy that URL and send it to someone, they will be taken to the same page for the book, but the URL also contains a bunch of other metadata such as the search terms I used. Note: the actual URL contains way more data than this, but here's a simple example:

http://books.google.com/books?id=4WsAENDgwVYC&printsec=frontcover&dq=alice+in+wonderland

If you click through to that, you will see that the search field is already populated with search terms. What I want to do is get the main link to the book without any parameters or other settings already filled in. For example:

http://books.google.com/books?id=4WsAENDgwVYC

If you follow that link, you are taken to the page of the book with nothing already filled in. I manually deleted all the parameters after the id attribute. I'm wondering how I would get to this page without having to manually modify the URL attribute (i.e. some way via the GUI). A GUI solution is better because then you don't have to manually find the id attribute in the URL, and it means that Google is more likely to continue supporting the GUI's URL in the future.

The reason I'm asking is because usually when you copy a webpage's URL, all you want is the actual URL of the page, you don't want a list of all the search terms you used to get to that page. That's why I'm confused as to why this option isn't easily accessible on Google Books.

0

You can use a small JavaScript bookmarklet or user script.

A working JavaScript piece of code that I used in the past for multiple sites (adjusted to the current one):

var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = 0;
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
textArea.style.background = 'transparent';
textArea.value = document.location.href.match("https?:\/\/.*?\/books")[0] + "?id=" + document.location.href.match("id=([a-zA-Z0-9]{12})[?&]")[1];
document.body.appendChild(textArea);
textArea.select();

try {
    var successful = document.execCommand('copy');
    var msg = successful ? 'successful' : 'unsuccessful';
    console.log('Copying text command was ' + msg + ': ' + text);
} catch (err) {
    console.log('Oops, unable to copy');
}

document.body.removeChild(textArea);

I just tried it as a booklet and it works great (on Chrome at least).

A bookmarklet ready code (minimized):

javascript:var textArea=document.createElement("textarea");textArea.style.position="fixed",textArea.style.top=0,textArea.style.left=0,textArea.style.width="2em",textArea.style.height="2em",textArea.style.padding=0,textArea.style.border="none",textArea.style.outline="none",textArea.style.boxShadow="none",textArea.style.background="transparent",textArea.value=document.location.href.match("https?://.*?/books")[0]+"?id="+document.location.href.match("id=([a-zA-Z0-9]{12})[?&]")[1],document.body.appendChild(textArea),textArea.select();try{var successful=document.execCommand("copy"),msg=successful?"successful":"unsuccessful";console.log("Copying text command was "+msg+": "+text)}catch(e){console.log("Oops, unable to copy")}document.body.removeChild(textArea);

Side note

It was taken from a user script I created for eBay, to share easily a short and nice link.
If you want, you can look at the full script, which adds a small button to each item page on eBay and adjust it to Google Books.
You can find my script at one of those links: GitHub / OpenUserJS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.