5

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.

2 Answers 2

3

Resolved in the new Google Books

I was able to reproduce your issue in Google Books classic, but when I switched over to the new Google Books, there was a dismissible lightbox instead. After closing that, the URL did not have the search terms: https://www.google.com/books/edition/Alice_in_Wonderland/4WsAENDgwVYC?hl=en&gbpv=0

Books with previews

I noticed it was a little different for books with previews for whatever reason. The interface still looks like Google Books classic, and there's no way to switch.

Take for example this URL linking to a specific page. Clicking on "About this book/magazine" takes you to the home page of the book, but with the query filled in still. You can click on "Preview this book/magazine" (or the image of the cover) to be taken back to the preview (without your query filled in) and then on "About this book/magazine" to go back to the main page without any query set.

Circuitous, but it works.

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 and acknowledge you have read our privacy policy.

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