Google無限滾動和Favicon

-

目前为 2022-02-04 提交的版本。查看 最新版本

// ==UserScript==
// @name:ko           구글 무한스크롤과 파비콘
// @name              Google Infinite scroll and Favicon
// @name:jp           Google無限スクロールおよびFavicon
// @name:zh-TW        Google无限滚动和Favicon
// @name:zh-CN        Google無限滾動和Favicon

// @description:ko    -
// @description       -
// @description:jp    -
// @description:zh-TW -
// @description:zh-CN -

// @namespace         https://ndaesik.tistory.com/
// @version           2022.02.05.08:22
// @author            ndaesik
// @icon              https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://www.google.com
// @include           https://www.google.com/search*
// ==/UserScript==
document.querySelector(`#xjs`).style.visibility = `hidden`; document.querySelector(`#xjs`).parentElement.style.height = `0`
for (let i = 0; i < document.querySelectorAll(`cite`).length; ++i) {
    let lnk = document.querySelector(`#center_col>[role="main"]`).querySelectorAll(`cite`)[i],
        txt = lnk.textContent,
        url = txt.match(/\./g) ? (txt.match(/\/\//g) ? txt.match(/(?<=\/\/)[^\s]*/g) : txt.match(/^[^\s]*/g)) : null,
        fav = url ? `/s2/favicons?domain=` + url : ``
    if (url) {
        let img = document.createElement(`div`)
        img.style.cssText = `background-image:url("`+ fav +`"); width:16px; height:16px; position:absolute`;
        lnk.prepend(img)
        lnk.style.cssText = `padding-left:23px`
    }
}
let numb = 1,
    func = () => {
        let next = new URL((document.querySelector(`#xjs a:first-child`).href).replace(/(?<=start=)(.*?)(?=\&)/g,numb * 10));
        fetch(next.href)
            .then(response => response.text())
            .then(text => {
            let html = (new DOMParser()).parseFromString(text, `text/html`),
                cont = html.documentElement.querySelector(`#center_col > [role="main"]`),
                addC = document.createElement(`div`);
            for (let i = 0; cont.querySelectorAll(`#center_col > [role="main"] #rso > div:not(.g)`).length; ++i) {
                cont.querySelectorAll(`#center_col > [role="main"] #rso > div:not(.g)`)[i].remove()
            }
            for (let i = 0; i < html.querySelectorAll(`cite`).length; ++i) {
                let lnk = html.querySelector(`#center_col>[role="main"]`).querySelectorAll(`cite`)[i],
                    txt = lnk.textContent,
                    url = txt.match(/\./g) ? (txt.match(/\/\//g) ? txt.match(/(?<=\/\/)[^\s]*/g) : txt.match(/^[^\s]*/g)) : null,
                    fav = url ? `/s2/favicons?domain=` + url : ``
                if (url) {
                    let img = html.createElement(`div`)
                    img.style.cssText = `background-image:url("`+ fav +`"); width:16px; height:16px; position:absolute`;
                    lnk.prepend(img)
                    lnk.style.cssText = `padding-left:23px`
                }
            }
            (html.querySelector(`.g`)) ? (addC.appendChild(cont), document.querySelector(`#center_col > [role='main']`).parentElement.appendChild(cont)) : null
        })
    }
document.addEventListener(`scroll`, () => {
  if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight - 2) {
      func()
      numb = numb + 1
  }
})

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址