Greasy Fork is available in English.
Display Favicons on Google Search
当前为
// ==UserScript==
// @name Google Favicon
// @namespace http://greasyfork.icu/en/users/943407-webchantment
// @version 1.0
// @description Display Favicons on Google Search
// @author Webchantment
// @match https://www.google.com/search?q=*
// @grant none
// ==/UserScript==
(function() {
const organic = document.querySelectorAll("#search > * cite");
const topAds = document.querySelectorAll("#tads > * span[role='text']");
const bottomAds = document.querySelectorAll("#tadsb > * span[role='text']");
organic.forEach(o => { prependFavicon(o, o.innerText); });
topAds.forEach(t => { prependFavicon(t, t.getAttribute("data-dtld")); });
bottomAds.forEach(b => { prependFavicon(b, b.getAttribute("data-dtld")); });
function prependFavicon(element, text)
{
let domain = text;
if (domain && domain !== "YouTube")
{
domain = domain.split(" ")[0];
const favicon = document.createElement("img");
favicon.src = `https://www.google.com/s2/favicons?domain=${domain}&sz=16`;
element.prepend(" ");
element.prepend(favicon);
}
}
})();