Brings back the full URLs in results.
目前為
// ==UserScript==
// @name Google Search restore URLs (undo breadcrumbs)
// @namespace https://greasyfork.org/en/users/27283-mutationobserver
// @version 2019.09.10v3
// @description Brings back the full URLs in results.
// @author MutationObserver
// @match https://*.google.com/search?*
// @include /^https?://(?:www|encrypted|ipv[46])\.google\.[^/]+/(?:$|[#?]|search|webhp)/
// @grant none
// ==/UserScript==
var results = document.querySelectorAll(".r");
if (results) {
for (i=0; i < results.length; i++) {
try {
var originalWidth = results[i].offsetWidth;
var link = results[i].querySelector(".r a").getAttribute("href");
var linkElem = results[i].querySelector("cite");
linkElem.innerHTML = link;
if (linkElem.offsetWidth > originalWidth) {
linkElem.innerHTML = linkTruncate(link);
}
}
catch(e){
console.log("Google Search restore URLs - ERROR @: " + i + ": " + e.message);
continue;
}
}
document.querySelector("body").insertAdjacentHTML("afterbegin", `
<style id="breadcrumb-removal-userscript">
.r cite {
white-space: nowrap;
text-overflow: ellipsis;
}
.r > span {
position: absolute;
right: 0;
top: 5px;
}
</style>
`);
}
function linkTruncate(str) {
if (str.length > 80) {
return str.substr(0, 37) + '...' + str.substr(str.length-40, str.length);
}
return str;
}