Greasy Fork is available in English.

Google Search restore URLs (undo breadcrumbs)

Brings back the full URLs in results.

< Feedback on Google Search restore URLs (undo breadcrumbs)

Review: Good - script works

§
Posted: 2020-02-27

Great script, just added a line to get it back to the old green:

Added

linkElem.setAttribute("style", "color: green");

under

linkElem.setAttribute("data-full-link", link);
q1k
§
Posted: 2020-04-19
Edited: 2020-04-19

I added this to new userstyle in Stylus, to have the url below the title and change the color to green like it used to be

.g .r a br {
  display: none;
}
.g .r .NJjxre,
[data-full-link] {
  display: block;
  position: relative;
  margin-bottom: 2px;
}
[data-full-link] {
  color: green;
}
.g .r h3 {
  margin-bottom: 0;
}
.g .r {
  position: relative;
}
.g .r .B6fmyf {
  top: 30px;
}

I also added this in case the link is too long, on line 30 inside the forEach section:

if(link.length>50){
    link = link.substring(0,50) + "...";
}

Too bad that wasn't the way google handled long links before

§
Posted: 2020-04-20

Thanks for the ideas. I've now made the link green using a slightly different method. I'll be leaving it at the default position (top) for now because I'm not interested playing cat-and-mouse with Google's relatively frequent CSS changes.

As for long links, the script actually already accounts for for those. It should work for most links as long as the browser window isn't resized.

q1k
§
Posted: 2020-04-23
Edited: 2020-04-23

@MutationObserver said: Thanks for the ideas. I've now made the link green using a slightly different method. I'll be leaving it at the default position (top) for now because I'm not interested playing cat-and-mouse with Google's relatively frequent CSS changes.

As for long links, the script actually already accounts for for those. It should work for most links as long as the browser window isn't resized.

I disabled the on hover thing because I find it annoying the links just keep jumping up and down. Maybe if it was in title attribute it would be less annoying. And why are you going over the links twice? This causes the blinking issue, where the full link in multiple rows appears for a split second.

Also some links aren't truncated, such as cyrillic or some special characters displayed with % (ex. %d0)

The current way of truncating will cut after the first 37 chars, so if the domain including subdomains will cut that, we won't get an accurate picture of where the link is headed.

The best way to handle long links is with a regex, just like google used to do (shown in the image in my previous post). I don't know much about regex, so all I could do is get the link up to the domain and no further.

§
Posted: 2020-04-23

For the hover, do you mean that you prefer the link to always expand onto a single line? That was the goal, but for some links it doesn't always work.

The truncation actually doesn't use character counting, as that wouldn't be enough. Instead, it basically measures the width of the result container and only truncates if the link doesn't fit. Works most of the time.

Google's own truncation was more than just regex. It used semantics and other AI-based methods, which obviously won't ever be in a userscript. You do raise a good point about keeping the domain visible, so I might add something better than the current "cut in the middle" approach.

q1k
§
Posted: 2020-04-24
Edited: 2020-04-24

the html title attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title

btw, i've been messing with regex and this is what i've come up with to get as close as possible to the old way of handling urls https://jsfiddle.net/69bLnz24/

edit: [^:]+:\/\/[^\/]+\/.*?([^\/]+)\/?$ this regex will grab the last part after a single slash (there might be nothing though), it will be under group [1] https://jsfiddle.net/tz4bLkmu/

§
Posted: 2020-04-27

Oh, I didn't expect you to mean the literal title attribute. Although very easy to add, that would be slower and less unintuitive.

Anyway, try out today's update. It more reliably detects results and possibly fixes the following:

q1k said: Also some links aren't truncated, such as cyrillic or some special characters displayed with % (ex. %d0)

Soon I might also be ensuring that the domain is always visible.

Regarding your regex, it seems promising, so I'll consider something similar.

q1k
§
Posted: 2020-04-27
Edited: 2020-04-27

@MutationObserver said: Oh, I didn't expect you to mean the literal title attribute. Although very easy to add, that would be slower and less unintuitive.

Anyway, try out today's update. It more reliably detects results and possibly fixes the following:

q1k said: Also some links aren't truncated, such as cyrillic or some special characters displayed with % (ex. %d0)

Soon I might also be ensuring that the domain is always visible.

Regarding your regex, it seems promising, so I'll consider something similar.

You are adding the link twice now...

Anyway, I suggested title attribute because it's the simplest to add. But you could use pseudo element as well Something like this: https://jsfiddle.net/cm4b8kfy/

edit: here's a way to do it with the dataset attribute https://jsfiddle.net/smxe4dj7/

§
Posted: 2020-04-28

I only see the link once. Give me a sample search so I can try to reproduce your issue.

q1k
§
Posted: 2020-04-28

@MutationObserver said: I only see the link once. Give me a sample search so I can try to reproduce your issue.

Anything.

§
Posted: 2020-04-28

Something else on your end is causing that. I don't see it in Chrome or Firefox (via Tampermonkey).

q1k
§
Posted: 2020-04-28
Edited: 2020-04-28

@MutationObserver said: Something else on your end is causing that. I don't see it in Chrome or Firefox (via Tampermonkey).

I solved it by doing this

function urlTruncate(url) {
    if(url.length>80){
        return url.substr(0, 37) + '...' + url.substr(url.length-37, url.length);
    } else {
        return url;
    }
}

Post reply

Sign in to post a reply.